/* WAVS Bridge panel. Brand: abyss navy, signal cyan -> pulse violet, the waveform. */
:root {
  --abyss: #04060d;
  --deep: #0a1124;
  --deep-2: #0e1730;
  --rim: #1a2442;
  --rim-2: #243156;
  --signal: #2cc6f2;
  --pulse: #6e5bff;
  --ink: #e9eefb;
  --ink-2: #b9c3dc;
  --mist: #8390b0;
  --ok: #33d69f;
  --warn: #f4b64e;
  --err: #ff5d7d;
  --grad: linear-gradient(90deg, var(--signal), var(--pulse));
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --text: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-lg: 18px; --r-md: 12px; --r-sm: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--abyss);
  background-image:
    radial-gradient(1200px 700px at -10% -20%, rgba(36, 70, 170, .28), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(110, 91, 255, .12), transparent 60%),
    linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
  background-size: auto, auto, 64px 64px, 64px 64px;
  background-attachment: fixed;
  color: var(--ink); font: 14px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell {
  display: grid; grid-template-columns: 252px 1fr; min-height: 100vh;
  background: linear-gradient(90deg, rgba(6,10,22,.72) 0 251px, var(--rim) 251px 252px, transparent 252px);
}
.rail {
  position: sticky; top: 0; height: 100vh; padding: 24px 18px;
  background: transparent;
  display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; text-decoration: none; }
.brand img { width: 38px; height: 38px; filter: drop-shadow(0 0 14px rgba(44, 198, 242, .35)); }
.wordmark { font: 500 17px/1 var(--display); letter-spacing: .42em; }
.wordmark small { display: block; margin-top: 6px; font: 500 12px/1 var(--text); letter-spacing: .02em; color: var(--mist); }
.clinic { padding: 14px; border: 1px solid var(--rim); border-radius: var(--r-md); background: var(--deep); }
.clinic b { display: block; font: 500 14px/1.3 var(--display); }
.clinic span { color: var(--mist); font-size: 12px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; opacity: .8; }
.nav a:hover { background: rgba(255,255,255,.04); color: var(--ink); }
.nav a[aria-current="page"] { background: linear-gradient(90deg, rgba(44,198,242,.14), rgba(110,91,255,.08)); color: var(--ink); box-shadow: inset 2px 0 0 var(--signal); }
.nav .count { margin-left: auto; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: rgba(255,93,125,.16); color: var(--err); }
.rail-foot { margin-top: auto; display: grid; gap: 8px; }
.linkbtn { background: none; border: 0; padding: 8px 12px; color: var(--mist); text-align: left; cursor: pointer; border-radius: 8px; }
.linkbtn:hover { color: var(--ink); background: rgba(255,255,255,.04); }

main { padding: 28px 36px 64px; max-width: 1280px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
h1 { font: 500 28px/1.15 var(--display); letter-spacing: -.01em; margin: 0; }
h2 { font: 500 17px/1.3 var(--display); margin: 0; }
.sub { color: var(--mist); margin: 4px 0 0; }

/* ---------- status chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 99px;
  border: 1px solid var(--rim); background: var(--deep); font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mist); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(51,214,159,.14); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(244,182,78,.14); }
.dot.err { background: var(--err); box-shadow: 0 0 0 4px rgba(255,93,125,.14); }
.chip time { color: var(--mist); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--rim-2); background: var(--deep-2);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #33427a; background: #121d3b; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { border: 0; background: var(--grad); color: #050815; font-weight: 600; box-shadow: 0 6px 24px rgba(60, 120, 255, .28); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(255,93,125,.4); color: #ffb3c2; background: rgba(255,93,125,.08); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- panels ---------- */
.panel { border: 1px solid var(--rim); border-radius: var(--r-lg); background: linear-gradient(180deg, rgba(14,23,48,.9), rgba(10,17,36,.9)); }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 0; flex-wrap: wrap; }
.panel-b { padding: 20px 24px 24px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-top: 20px; }
.stack { display: grid; gap: 20px; align-content: start; }

/* ---------- the wave (signature) ---------- */
.wave-legend { display: flex; gap: 22px; flex-wrap: wrap; }
.legend { display: flex; align-items: baseline; gap: 10px; color: var(--ink-2); }
.legend i { width: 18px; height: 3px; border-radius: 3px; display: inline-block; transform: translateY(-3px); }
.legend .num { font-size: 22px; color: var(--ink); }
.wave { position: relative; margin: 8px 0 0; }
.wave svg { width: 100%; height: 210px; display: block; overflow: visible; }
.wave .axis { position: relative; height: 20px; margin-top: 6px; }
.wave .axis span { position: absolute; top: 0; color: var(--mist); font-size: 11px; white-space: nowrap; }
.wave .gridline { stroke: rgba(255,255,255,.05); }
.wave .line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.wave .tip { position: absolute; pointer-events: none; padding: 8px 10px; border-radius: 10px; background: #0f1a38; border: 1px solid var(--rim-2); font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); display: none; }
.wave .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mist); text-align: center; }
@media (prefers-reduced-motion: no-preference) {
  .wave .line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.6s cubic-bezier(.6,.05,.2,1) forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rim); }
.stat { padding: 18px 24px; }
.stat + .stat { border-left: 1px solid var(--rim); }
.stat .num { font-size: 26px; line-height: 1.1; display: block; }
.stat span { color: var(--mist); font-size: 13px; }

/* ---------- feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; padding: 12px 0; align-items: start; }
.feed li + li { border-top: 1px solid rgba(255,255,255,.05); }
.ev-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(44,198,242,.1); color: var(--signal); }
.ev-ic svg { width: 16px; height: 16px; stroke: currentColor; }
.ev-ic.w2z { background: rgba(110,91,255,.14); color: #a89dff; }
.ev-ic.sys { background: rgba(255,255,255,.06); color: var(--ink-2); }
.ev-ic.error { background: rgba(255,93,125,.12); color: var(--err); }
.ev-t { font-weight: 500; }
.ev-d { color: var(--mist); font-size: 13px; }
.ev-links { display: flex; gap: 10px; font-size: 12px; margin-top: 2px; }
.ev-links a { color: var(--signal); text-decoration: none; }
.ev-links a:hover { text-decoration: underline; }
.ev-time { color: var(--mist); font-size: 12px; white-space: nowrap; }

/* ---------- attention ---------- */
.att { display: grid; gap: 10px; }
.att-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: start; padding: 14px; border-radius: var(--r-md); background: rgba(255,255,255,.025); border: 1px solid var(--rim); }
.att-item .dot { margin-top: 6px; }
.att-item b { font-weight: 500; display: block; }
.att-item p { margin: 2px 0 0; color: var(--mist); font-size: 13px; }
.allclear { display: flex; gap: 12px; align-items: center; color: var(--ink-2); padding: 6px 0; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--mist); }
.kv dd { margin: 0; text-align: right; }

/* ---------- tables / lists ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border-radius: 99px; border: 1px solid var(--rim); background: transparent; cursor: pointer; color: var(--ink-2); }
.tab[aria-pressed="true"] { background: rgba(44,198,242,.12); border-color: rgba(44,198,242,.4); color: var(--ink); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--mist); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--rim); }
td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
.yes { color: var(--ok); } .no { color: var(--warn); }
.muted { color: var(--mist); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: rgba(255,255,255,.06); color: var(--ink-2); }

.search { display: flex; gap: 10px; }
.input {
  flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--rim-2); background: var(--abyss);
  outline: none; min-width: 0;
}
.input:focus { border-color: var(--signal); box-shadow: 0 0 0 4px rgba(44,198,242,.12); }

/* ---------- import ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { padding: 20px; border-radius: var(--r-md); border: 1px solid var(--rim); background: rgba(255,255,255,.02); display: flex; flex-direction: column; gap: 10px; }
.step .btn { margin-top: auto; }
.step .n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font: 500 13px var(--display); border: 1px solid var(--rim-2); color: var(--ink-2); }
.step p { margin: 0; color: var(--mist); font-size: 13px; }
.bar { height: 10px; border-radius: 99px; background: var(--abyss); border: 1px solid var(--rim); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .6s ease; }
.progress-meta { display: flex; justify-content: space-between; color: var(--mist); font-size: 13px; margin-top: 8px; gap: 12px; flex-wrap: wrap; }
.statline { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 16px; }
.statline div { display: grid; }
.statline .num { font-size: 20px; }
.statline span { color: var(--mist); font-size: 12px; }

/* ---------- settings ---------- */
.rows { display: grid; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 18px 0; }
.row + .row { border-top: 1px solid rgba(255,255,255,.06); }
.row b { font-weight: 500; display: block; }
.row p { margin: 2px 0 0; color: var(--mist); font-size: 13px; max-width: 62ch; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--rim-2); transition: background .2s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--signal); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
.copy { display: flex; gap: 8px; align-items: center; }
.copy code { flex: 1; padding: 10px 12px; border-radius: 10px; background: var(--abyss); border: 1px solid var(--rim); font-size: 12px; overflow-x: auto; white-space: nowrap; color: var(--ink-2); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); text-align: center; }
.login-card img { width: 72px; height: 72px; filter: drop-shadow(0 0 28px rgba(44,198,242,.45)); }
.login-card .wordmark { font-size: 26px; margin: 18px 0 6px; padding-left: .42em; }
.login-card form { margin-top: 28px; display: grid; gap: 12px; text-align: left; }
.login-card label { color: var(--ink-2); font-size: 13px; }
.err-msg { color: var(--err); font-size: 13px; min-height: 18px; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; transition: .25s; padding: 12px 18px; border-radius: 12px; background: #13204a; border: 1px solid var(--rim-2); box-shadow: 0 10px 40px rgba(0,0,0,.4); pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgba(255,93,125,.5); }

.skeleton { color: var(--mist); padding: 40px 0; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > .stack { order: -1; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--rim); background: rgba(6,10,22,.72); }
  .clinic, .rail-foot { display: none; }
  .nav { grid-auto-flow: column; overflow-x: auto; width: 100%; }
  .nav a { padding: 8px 10px; }
  .nav a span.label { display: none; }
  main { padding: 20px 16px 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--rim); }
}
