/* Vorta Clinical portal: a sidebar of sections, one working area; same indigo as the subject app. */
:root {
  --bg: #F4F6FB; --panel: #FFFFFF; --ink: #182033; --muted: #5E6780; --line: #E1E5EF;
  --brand: #26408B; --brand-ink: #FFFFFF; --brand-soft: #E8EDF9; --brand-strong: #1C3170;
  --good: #1F8A5B; --good-soft: #E1F4EA; --warn: #B7700E; --warn-soft: #FCF0DC;
  --bad: #C0392F; --bad-soft: #FBE5E3; --shadow: 0 1px 2px rgba(24,32,51,.06), 0 4px 14px rgba(24,32,51,.05);
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141E; --panel: #171C29; --ink: #E7EAF2; --muted: #9AA3B8; --line: #283043;
    --brand: #8EA6F0; --brand-ink: #10141E; --brand-soft: #222C47; --brand-strong: #B3C3F6;
    --good: #5FD39C; --good-soft: #173628; --warn: #F0BC5E; --warn-soft: #3A2E15;
    --bad: #F08A80; --bad-soft: #3D1E1B; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box }
html, body { height: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font) }
a { color: var(--brand) }
button, input, select { font: inherit; color: inherit }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted) }

/* sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px }
.signin-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px }
.signin-card .logo { width: 56px; height: 56px; border-radius: 16px; background: #fff; display: grid; place-items: center;
  border: 1px solid var(--line) }
.signin-card .logo img { width: 38px }
.signin-card h1 { margin: 0; font-size: 24px; letter-spacing: -.01em }
.signin-card p { margin: 0; color: var(--muted) }
.studies { display: flex; flex-direction: column; gap: 8px }
.study { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600 }
.study:hover { border-color: var(--brand); background: var(--brand-soft) }
.study:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 2px }
.study-name { overflow-wrap: anywhere }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line) }

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px }
.brand img { width: 30px }
.brand b { display: block; font-size: 16px }
.brand small { color: var(--muted); font-size: 12.5px }
.nav { display: flex; flex-direction: column; gap: 2px }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink);
  text-decoration: none; font-weight: 500 }
.nav a svg { width: 18px; height: 18px; flex: none; color: var(--muted) }
.nav a:hover { background: var(--bg) }
.nav a.on { background: var(--brand-soft); color: var(--brand-strong) }
.nav a.on svg { color: var(--brand) }
.me { margin-top: auto; padding: 12px; border-radius: 12px; background: var(--bg); font-size: 13.5px; display: flex; flex-direction: column; gap: 6px }
.me .email { font-weight: 600; overflow-wrap: anywhere }
.me-actions { display: flex; gap: 6px; flex-wrap: wrap }
.main { padding: 28px clamp(16px, 3vw, 40px) 60px; min-width: 0; display: flex; flex-direction: column; gap: 20px }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -.015em }
.page-head p { margin: 4px 0 0; color: var(--muted) }
.topbar { display: none }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px }
  .nav a { white-space: nowrap; padding: 8px 10px }
  .me { display: none }
}

/* cards and stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow) }
.card-pad { padding: 18px 20px }
.card h2 { margin: 0 0 4px; font-size: 16px }
.card .sub { color: var(--muted); font-size: 13.5px }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500 }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums }
.stat .hint { font-size: 12.5px; color: var(--muted) }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px }

/* tables */
.table-wrap { overflow-x: auto }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums }
th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap }
td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle }
tr:last-child td { border-bottom: 0 }
tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent) }
.mono { font-family: var(--mono); font-size: 13px }
.muted { color: var(--muted) }
.empty { padding: 36px 20px; text-align: center; color: var(--muted) }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--bg); color: var(--muted); white-space: nowrap }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor }
.chip.good { background: var(--good-soft); color: var(--good) }
.chip.warn { background: var(--warn-soft); color: var(--warn) }
.chip.bad { background: var(--bad-soft); color: var(--bad) }
.chip.brand { background: var(--brand-soft); color: var(--brand-strong) }

/* buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel);
  padding: 8px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; white-space: nowrap }
.btn:hover { border-color: var(--brand); color: var(--brand) }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: 2px }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink) }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-ink) }
.btn.danger { color: var(--bad) }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft) }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px }
.btn.big { padding: 12px 18px; font-size: 15.5px; border-radius: 12px }
.btn[disabled] { opacity: .5; cursor: default }
.btn svg { width: 16px; height: 16px }
.field { display: flex; flex-direction: column; gap: 6px }
.field label { font-size: 13px; font-weight: 600; color: var(--muted) }
input, select { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 12px; min-width: 0 }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end }
.form-row .field { flex: 1 1 180px }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line) }
.toolbar .field { flex: 0 1 200px }

/* dialog and toast */
.scrim { position: fixed; inset: 0; background: rgba(8,11,20,.6); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; z-index: 20 }
.dialog { width: 100%; max-width: 460px; background: var(--panel); border-radius: 18px; padding: 24px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25) }
.dialog h2 { margin: 0; font-size: 20px }
.dialog p { margin: 0; color: var(--muted) }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px }
.codebox { font-family: var(--mono); font-size: 28px; font-weight: 500; letter-spacing: .06em; text-align: center; padding: 18px;
  border-radius: 14px; background: var(--brand-soft); color: var(--brand-strong); user-select: all }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 500; z-index: 30; box-shadow: 0 8px 30px rgba(0,0,0,.2) }
.toast.bad { background: var(--bad); color: #fff }
/* data per day */
.days { display: flex; flex-direction: column }
.day { display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; padding: 16px 20px; border-top: 1px solid var(--line) }
.day-main { display: flex; flex-direction: column; gap: 10px; min-width: 0 }
.day-title { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap }
.day-title b { font-size: 16px }
.day-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 20px; font-variant-numeric: tabular-nums }
.fact { display: flex; flex-direction: column; gap: 2px; min-width: 0 }
.fact .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em }
.day-note { font-size: 13px; color: var(--warn) }
.day-actions { align-self: start }
.day-detail { grid-column: 1 / -1 }
.day-detail:empty { display: none }
.day-detail .table-wrap { border: 1px solid var(--line); border-radius: 12px }
@media (max-width: 700px) { .day { grid-template-columns: 1fr } .day-actions { justify-content: flex-start } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 }
.kv dt { color: var(--muted); font-size: 13.5px }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere }
.notice { padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 500 }
@media (prefers-reduced-motion: no-preference) { .dialog { animation: pop .14s ease-out } @keyframes pop { from { transform: scale(.97); opacity: 0 } } }
