/* Lung26 design system — clinical, calm, high-contrast. Light + dark. */
:root {
  --bg: #f5f6fa; --bg-2: #eef0f6; --surface: #ffffff; --surface-2: #f9fafc;
  --ink: #0e1222; --ink-2: #2a3045; --muted: #616a80; --faint: #8e95a8;
  --line: #e3e6ee; --line-2: #d4d8e3;
  --brand: #4a18e0; --brand-2: #2b1bff; --brand-soft: #eeeaff; --brand-ink: #3510b8;
  --accent: #ff7438; --ok: #12876f; --ok-soft: #e3f5ef; --warn: #b8660a; --warn-soft: #fff3e0;
  --bad: #c62839; --bad-soft: #fde8ea; --info: #1f6feb; --info-soft: #e6f0ff;
  --viewer: #05070d;
  --shadow-1: 0 1px 2px rgba(14,18,34,.06), 0 1px 1px rgba(14,18,34,.04);
  --shadow-2: 0 10px 30px -12px rgba(14,18,34,.18), 0 2px 6px rgba(14,18,34,.05);
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0c14; --bg-2: #10131e; --surface: #131725; --surface-2: #171c2c;
    --ink: #eef0f7; --ink-2: #cfd3e1; --muted: #9aa1b5; --faint: #6f768b;
    --line: #242a3c; --line-2: #2f364b;
    --brand: #8a6cff; --brand-2: #6f5bff; --brand-soft: #211a45; --brand-ink: #b8a8ff;
    --ok: #3fc9a6; --ok-soft: #10302a; --warn: #f0a24a; --warn-soft: #33240f;
    --bad: #ff6b7a; --bad-soft: #3a1219; --info: #6aa5ff; --info-soft: #11243f;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 14px 34px -14px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0c14; --bg-2: #10131e; --surface: #131725; --surface-2: #171c2c;
  --ink: #eef0f7; --ink-2: #cfd3e1; --muted: #9aa1b5; --faint: #6f768b;
  --line: #242a3c; --line-2: #2f364b;
  --brand: #8a6cff; --brand-2: #6f5bff; --brand-soft: #211a45; --brand-ink: #b8a8ff;
  --ok: #3fc9a6; --ok-soft: #10302a; --warn: #f0a24a; --warn-soft: #33240f;
  --bad: #ff6b7a; --bad-soft: #3a1219; --info: #6aa5ff; --info-soft: #11243f;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 14px 34px -14px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── controls ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn svg { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
label.f > :is(input, select, textarea) { display: block; margin-top: 5px; }
label.f > div { margin-top: 5px; }
label.f > span.hint { font-weight: 400; color: var(--faint); margin-left: 4px; }
input, select, textarea { font: 14px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 8px 11px; min-height: 38px; width: 100%; }
textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ── surfaces ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card.pad { padding: 18px 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-b { padding: 16px 18px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; background: var(--bg-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.lr { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 24px; padding: 0 7px; border-radius: 7px;
  color: #fff; font-weight: 750; font-size: 12px; letter-spacing: .02em; }
.lr.c0 { background: #7c7895; } .lr.c1, .lr.c2 { background: #1b998b; } .lr.c3 { background: #d98a0b; }
.lr.c4A { background: #f2682f; } .lr.c4B { background: #d64550; } .lr.c4X { background: #a3001b; }
.lr.cpending { background: var(--bg-2); color: var(--muted); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* ── toast & modal ── */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-2); font-weight: 550;
  max-width: 380px; animation: tin .2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
.modal-bg { position: fixed; inset: 0; background: rgba(8,10,20,.5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--r-lg);
  border: 1px solid var(--line); box-shadow: var(--shadow-2); }
.modal .card-b { display: flex; flex-direction: column; gap: 12px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }

/* ── logo ── */
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 750; font-size: 17px; letter-spacing: -.02em; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo .mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4a18e0, #2b1bff 55%, #ff7438); color: #fff; }
.logo .mark svg { width: 19px; height: 19px; }
.logo small { font-weight: 600; font-size: 11px; color: var(--faint); letter-spacing: .02em; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.disclaimer { font-size: 12px; color: var(--muted); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: 10px; padding: 9px 12px; }
.disclaimer b { color: var(--warn); }
