/* IntegratorLog: one accent (the company's brand colour), neutrals, content first. */
:root {
  --brand: #16324f;
  --bg: #f5f6f8; --card: #fff; --ink: #17212b; --muted: #5d6b78; --line: #dde2e7; --soft: #eef1f4;
  --ok: #1d7a3d; --warn: #8a5300; --bad: #b3261e; --warn-bg: #fff4e0; --bad-bg: #fdecea;
  --accent: var(--brand); --on-accent: #fff;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419; --card: #171e25; --ink: #e6ebf0; --muted: #98a5b1; --line: #2a343e; --soft: #1e2730;
    --ok: #5fd08a; --warn: #f0b45a; --bad: #ff8a80; --warn-bg: #3a2c12; --bad-bg: #3b1715;
    --accent: #8fb8e0; --on-accent: #0f1419;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 12px; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 24px 0 8px; }
h3 { font-size: 1rem; margin: 16px 0 6px; }
h2.inline { display: inline; margin: 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 20; background: var(--card); padding: 8px; }

/* Layout */
.top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "brand nav who"; align-items: center; gap: 8px 16px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.top .brand { grid-area: brand; font-weight: 700; color: var(--ink); text-decoration: none; }
.top nav { grid-area: nav; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.top nav a { white-space: nowrap; }
.top .who { grid-area: who; }
@media (max-width: 700px) {
  .top { grid-template-columns: 1fr auto; grid-template-areas: "brand who" "nav nav"; }
  .top nav { margin: 0 -16px; padding: 0 12px; }
  .top .who span.muted { display: none; }
}
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.top nav a.on { color: var(--ink); background: var(--soft); font-weight: 600; }
.top nav a.badge span { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .8rem; margin-left: 4px; }
.top .who { display: flex; flex-direction: column; align-items: flex-end; text-decoration: none; color: var(--ink); font-size: .9rem; line-height: 1.25; max-width: 45vw; text-align: right; }
.top .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.more { font-size: .9rem; margin: 4px 0 8px; }
main#main { max-width: 960px; margin: 0 auto; padding: 16px 16px 64px; }
section + section { margin-top: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1, .page-head h2, .page-head h3 { margin-bottom: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.narrow { max-width: 480px; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 12px; margin-top: 16px; }
.panel summary { cursor: pointer; padding: 12px 0; }
.network { border-left: 4px solid var(--accent); }
.system { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px 12px; margin-top: 12px; }

/* Auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: 100%; max-width: 440px; }
.auth-card .brand { font-weight: 700; color: var(--accent); margin: 0 0 4px; }
.links { font-size: .9rem; margin-top: 16px; }
.qr { width: 200px; height: 200px; display: block; margin: 8px 0; border-radius: 8px; }
.secret code { word-break: break-all; }
.codes { columns: 2; font-size: 1.05rem; }
.steps { padding-left: 20px; }

/* Forms */
.field { margin: 0 0 14px; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
.req { color: var(--bad); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
[aria-invalid=true] { border-color: var(--bad); }
.hint { font-size: .85rem; color: var(--muted); margin: 4px 0 0; }
.warn-hint { color: var(--warn); }
.field-error, .error { color: var(--bad); font-size: .9rem; margin: 4px 0 0; }
.error { background: var(--bad-bg); padding: 10px 12px; border-radius: 8px; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 8px; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0 14px; }
.search { margin-bottom: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 14px; padding: 8px 12px; }
.contact-row { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
input[type=color] { width: 64px; height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--card); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .92rem; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: default; }

/* Lists and tables */
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px 0 0; }
.list li:first-child { border-top: 0; }
.list li > a, .list li > span { display: flex; flex-direction: column; padding: 12px 16px; text-decoration: none; color: var(--ink); flex: 1; min-width: 0; }
.list li > a span { font-size: .9rem; }
.tree { list-style: none; padding: 0; margin: 0; }
.tree ul { list-style: none; padding-left: 20px; margin: 0; border-left: 2px solid var(--line); }
.tree li > a { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 8px 4px; text-decoration: none; color: var(--ink); border-radius: 6px; }
.tree li > a:hover { background: var(--soft); }
.tree .muted { font-size: .9rem; }
.ip { font-family: ui-monospace, Menlo, monospace; font-size: .88rem; margin-left: auto; }
.ip.dup { color: var(--bad); font-weight: 600; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: .93rem; display: block; overflow-x: auto; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tr.off { opacity: .55; }
.table tr.bad td { background: var(--bad-bg); }
.table tr.warnrow td { background: var(--warn-bg); }
.table select { min-height: 36px; padding: 4px 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.facts dt { color: var(--muted); font-size: .92rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: 6px; } }
.contacts { padding-left: 18px; margin: 0; }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.stepper { display: flex; gap: 8px; padding: 0; list-style: none; counter-reset: s; flex-wrap: wrap; }
.stepper li { counter-increment: s; color: var(--muted); font-size: .9rem; }
.stepper li::before { content: counter(s) ". "; }
.stepper li.on { color: var(--ink); font-weight: 700; }
.history { padding-left: 18px; font-size: .93rem; }
.history li { margin-bottom: 8px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: var(--soft); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
img.full { max-width: 100%; border-radius: 8px; }
img.logo { max-width: 200px; max-height: 80px; display: block; margin-bottom: 8px; }
.conflicts { background: var(--warn-bg); border-radius: var(--radius); padding: 8px 16px 12px; margin-bottom: 12px; }
.conflicts h3 { color: var(--warn); }
.conflict { border-top: 1px solid var(--line); padding-top: 8px; }
.summary { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; margin-bottom: 12px; }
progress { width: 100%; height: 10px; }

/* Modal and toasts */
.modal { border: 0; border-radius: 14px; padding: 16px 20px 20px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--card); color: var(--ink); }
.modal::backdrop { background: rgb(0 0 0 / .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-head h2 { margin: 0; }
.toasts { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 30; width: min(480px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 4px 16px rgb(0 0 0 / .2); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }
