/* ScanDesk — UI styles. Brand: navy #0B1F3A, cyan #00B8D9, blue #2878E8. */

:root {
  --navy: #0B1F3A;
  --navy-2: #13294A;
  --cyan: #00B8D9;
  --blue: #2878E8;
  --brand-gradient: linear-gradient(135deg, var(--cyan), var(--blue));

  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --text: #0B1F3A;
  --muted: #526782;
  --border: #DCE4EE;
  --focus: #2878E8;
  --link: #1C68D6;

  --ok-bg: #E2F7FB;  --ok-text: #006E82;
  --err-bg: #FDECEC; --err-text: #A32121;
  --danger: #C62828;
  --new-row: rgba(0, 184, 217, .16);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 4px 16px rgba(11, 31, 58, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07152A;
    --surface: #0E2240;
    --surface-2: #122A4D;
    --text: #E8EEF6;
    --muted: #B7C7D9;
    --border: #1F3A60;
    --focus: #00B8D9;
    --link: #4FD3EA;
    --ok-bg: #0B3A4A;  --ok-text: #7FE3F3;
    --err-bg: #46171B; --err-text: #FFB4B4;
    --danger: #FF6B6B;
    --new-row: rgba(0, 184, 217, .22);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #07152A;
    --surface: #0E2240;
    --surface-2: #122A4D;
    --text: #E8EEF6;
    --muted: #B7C7D9;
    --border: #1F3A60;
    --focus: #00B8D9;
    --link: #4FD3EA;
    --ok-bg: #0B3A4A;  --ok-text: #7FE3F3;
    --err-bg: #46171B; --err-text: #FFB4B4;
    --danger: #FF6B6B;
    --new-row: rgba(0, 184, 217, .22);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header { background: var(--navy); color: #fff; }
.site-header .inner {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  max-width: 1040px; margin: 0 auto; padding: 12px 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none; font-weight: 700; font-size: 1.3rem; letter-spacing: -.02em;
}
.brand svg { width: 34px; height: 34px; flex: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a, .nav button {
  color: #DCE6F2; text-decoration: none; padding: 8px 12px; border-radius: 8px;
  font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer;
}
.nav a:hover, .nav button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a[aria-current="page"] { color: #fff; background: rgba(0, 184, 217, .18); }
.nav .user { color: #8FA6C2; font-size: .9rem; padding: 0 4px 0 12px; }
.nav form { margin: 0; }

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 28px 16px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.site-footer {
  color: var(--muted); font-size: .85rem; text-align: center; padding: 24px 16px 28px;
  border-top: 1px solid var(--border); display: grid; gap: 10px; justify-items: center;
}
.site-footer p { margin: 0; }
.site-footer .credit { font-size: .8rem; }
.site-footer .credit a { color: var(--muted); font-weight: 600; text-decoration: none; }
.site-footer .credit a:hover { color: var(--cyan); text-decoration: underline; }
.footer-links { display: flex; gap: 6px 18px; flex-wrap: wrap; justify-content: center; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 0; }
.lang-switch button {
  font: 600 .8rem var(--font); padding: 4px 12px; border: 0; cursor: pointer;
  background: transparent; color: var(--muted);
}
.lang-switch button[aria-current="true"] { background: var(--navy); color: #fff; }

/* ---------- Long-form pages (how it works, legal) ---------- */
.prose { max-width: 760px; margin: 0 auto; }
.prose h1 { margin-bottom: 6px; }
.prose h2 { font-size: 1.25rem; margin: 32px 0 10px; }
.prose h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 4px; }
.prose .updated { color: var(--muted); font-size: .9rem; margin-top: 0; }
.prose table { margin: 12px 0; font-size: .92rem; }
.prose .table-wrap { margin: 12px 0; }
.prose .table-wrap table { margin: 0; }
.todo { background: #FFF4D6; color: #6B4E00; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.toc ol { margin: 6px 0 0; }
.prose .steps, .steps { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 14px; counter-reset: step; }
.steps li {
  counter-increment: step; position: relative; padding: 18px 18px 18px 68px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.steps li::before {
  content: counter(step); position: absolute; left: 18px; top: 16px;
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-gradient); color: #fff; font-weight: 700;
}
.steps h3 { margin: 0 0 4px; }
.steps p { margin: 0; color: var(--muted); }
.features { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 16px 0; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.feature h3 { margin: 0 0 4px; font-size: 1rem; }
.feature p { margin: 0; color: var(--muted); font-size: .92rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.card + .card { margin-top: 16px; }
.narrow { max-width: 440px; margin: 0 auto; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: var(--radius-sm);
  font: 600 .95rem var(--font); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: filter .15s, background .15s; white-space: nowrap;
}
.btn-primary { background: var(--brand-gradient); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: currentColor; }
.btn-danger:hover { background: var(--err-bg); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input[type="text"], input[type="password"], input:not([type]) {
  width: 100%; min-height: 44px; padding: 8px 12px;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent); border-color: var(--focus); }
.field { margin-bottom: 16px; }
.field .errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--err-text); font-size: .9rem; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 32px 0 16px; }
.hero svg { width: 112px; height: 112px; }
.hero h1 { font-size: 2.4rem; margin-top: 16px; }
.tagline { color: var(--muted); letter-spacing: .25em; text-transform: none; margin: 8px 0 24px; font-size: .95rem; }
.hero p.lead { max-width: 520px; margin: 0 auto 28px; color: var(--muted); }
.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tile {
  display: block; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--cyan); transform: translateY(-2px); }
.tile .icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--brand-gradient); color: #fff; margin-bottom: 12px;
}
.tile .icon svg { width: 22px; height: 22px; }
.tile p { margin: 0; color: var(--muted); font-size: .92rem; }

/* ---------- Scanner frame (brand corners) ---------- */
.frame { position: relative; padding: 22px 26px; display: inline-block; }
.frame::before, .frame::after, .frame > .c3, .frame > .c4 {
  content: ""; position: absolute; width: 22px; height: 22px; border: 4px solid var(--cyan);
}
.frame::before { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; border-color: var(--text); }
.frame::after { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; border-color: var(--text); }
.frame > .c3 { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.frame > .c4 { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }
.pair-code {
  font: 700 clamp(1.8rem, 7vw, 2.6rem)/1 var(--mono); letter-spacing: .12em; white-space: nowrap;
}
.center { text-align: center; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.badge-ok { background: var(--ok-bg); color: var(--ok-text); border-color: transparent; }

/* ---------- Device list ---------- */
.device-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.device {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.device.is-revoked { opacity: .65; box-shadow: none; }
.device .dev-icon {
  grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--blue); border: 1px solid var(--border);
}
.device .dev-icon svg { width: 22px; height: 22px; }
.device .dev-name, .device .dev-meta { grid-column: 2; }
.device .dev-name { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.device .dev-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .85rem; }
.device .dev-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-top: 8px; }
.device .dev-actions form { display: flex; gap: 8px; align-items: end; margin: 0; }
.device .rename { flex: 1 1 260px; }
.device .rename input { min-height: 36px; min-width: 200px; }
@media (min-width: 720px) {
  .device { grid-template-columns: auto 1fr auto; }
  .device .dev-actions { grid-column: 3; grid-row: 1 / span 2; margin-top: 0; }
  .device .rename { flex: 0 1 260px; }
}

/* ---------- Live scans ---------- */
.live {
  display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px;
}
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #9AA9BC; }
.live[data-state="live"] .dot { background: var(--cyan); animation: pulse 1.8s infinite; }
.live[data-state="offline"] .dot { background: var(--danger); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 184, 217, .6); }
  70% { box-shadow: 0 0 0 9px rgba(0, 184, 217, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 184, 217, 0); }
}
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.code { font-family: var(--mono); font-size: .95rem; overflow-wrap: anywhere; word-break: break-word; min-width: 180px; }
td.time { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
tr.is-new td { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--new-row); } to { background: transparent; } }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; opacity: .5; margin-bottom: 8px; }
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .nav .user { display: none; }
  .nav { margin-left: 0; width: 100%; justify-content: space-between; }
  .nav a, .nav button { padding: 8px 10px; }
  th, td { padding: 10px 12px; }
  h1 { font-size: 1.45rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
