/* TADSCAN styles */
:root {
  --ground: #F3F5F4;
  --paper: #FFFFFF;
  --ink: #0F1D1A;
  --ink-2: #33413D;
  --muted: #55625E;
  --line: #DDE3E0;
  --line-2: #C9D2CE;
  --accent: #0B6E5F;
  --accent-dark: #08554A;
  --accent-soft: #E3F1EE;
  --amber: #A04A06;
  --amber-soft: #FBEEDF;
  --red: #A61B1B;
  --red-soft: #FBE8E6;
  --blue: #173B6B;
  --blue-soft: #E6EEF8;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: Figtree, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #7CC3B6; outline-offset: 2px;
}
.muted { color: var(--muted); }
.center { text-align: center; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* ---------- App shell ---------- */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
  flex: 1 1 240px; max-width: 100%;
  background: var(--paper); border-right: 1px solid var(--line);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 0 8px; }
.brand span { display: flex; flex-direction: column; }
.brand strong { font-size: 17px; letter-spacing: .04em; }
.brand small { font-size: 12px; color: var(--muted); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none;
}
.side nav a:hover { background: #F0F3F2; }
.side nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #6B7773; padding: 12px 10px 4px; }
.who { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.who-text { flex: 1; display: flex; flex-direction: column; min-width: 0; color: inherit; text-decoration: none; }
.who-links { display: flex; flex-direction: column; align-items: flex-end; }
.who-links .link-btn { padding: 2px 4px; }
.who-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { font-size: 12px; color: var(--muted); }
.who form { margin: 0; }
.link-btn { background: none; border: 0; padding: 4px; font: inherit; font-size: 13px; color: var(--accent); cursor: pointer; text-decoration: underline; }

.main { flex: 999 1 560px; min-width: 0; padding: 24px clamp(16px, 3vw, 40px) 56px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Panels, messages ---------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 12px; }
.panel .field + h2, .panel .grid-2 + h2, .panel fieldset + h2 { margin-top: 28px; }
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; background: var(--blue-soft); color: var(--blue); }
.flash.success { background: var(--accent-soft); color: var(--accent-dark); }
.flash.error { background: var(--red-soft); color: #8A1616; }
.notice { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; background: var(--amber-soft); color: #6E3304; }

/* ---------- Forms ---------- */
.field { margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.field input[type=text], .field input:not([type]), .field input[type=email], .field input[type=password],
.field input[type=tel], .field input[type=number], .field input[type=date], .field input[type=month], .field input[type=search],
.field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--radius);
  font: inherit; color: var(--ink); background: var(--paper);
}
.field textarea { resize: vertical; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field .radio, .field .check {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 44px; margin: 0;
  border: 1px solid var(--line-2); border-radius: var(--radius); font-weight: 500; cursor: pointer; background: var(--paper);
}
.field .radio:has(input:checked), .field .check:has(input:checked) { border-color: var(--accent); background: #F3FAF8; }
.radio input, .check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: #F0F3F2; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-block { width: 100%; min-height: 48px; font-size: 16px; }

/* ---------- Sign in / register ---------- */
.auth-main { min-height: 100vh; }
.auth-split { display: flex; flex-wrap: wrap; min-height: 100vh; }
.auth-intro {
  flex: 1 1 420px; background: #0A1210; color: #fff; padding: clamp(28px, 5vw, 64px);
  display: flex; flex-direction: column; gap: 28px;
}
.auth-intro h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.1; max-width: 480px; }
.auth-intro p { color: #B8C6C1; font-size: 17px; max-width: 480px; }
.auth-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.auth-brand strong { font-size: 22px; letter-spacing: .06em; }
.auth-brand.dark { color: var(--ink); margin-bottom: 24px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; max-width: 460px; }
.steps li { display: flex; gap: 14px; color: #B8C6C1; }
.steps li span { font-family: "JetBrains Mono", monospace; color: #7CC3B6; font-size: 14px; padding-top: 2px; }
.steps strong { display: block; color: #fff; }
.auth-form { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: clamp(24px, 5vw, 64px); }
.auth-box { width: 100%; max-width: 440px; margin: 0 auto; }
.auth-box.wide { max-width: 680px; padding: clamp(24px, 5vw, 56px) 16px; }
.auth-box > h2 { font-size: 26px; }
.choice-list { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
.choice {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--paper); text-decoration: none; color: var(--ink);
}
.choice:hover { border-color: var(--accent); background: #F3FAF8; color: var(--ink); }
.choice strong { font-size: 17px; }
.choice span { color: var(--muted); font-size: 14px; }

/* ---------- Small helpers ---------- */
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; margin: 0; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.label-text { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin: 20px 0; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form .field { flex: 1 1 260px; margin: 0; }

/* ---------- Tables ---------- */
.table-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; position: relative; } /* relative keeps hidden labels inside the scroll area */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); background: #F6F8F7;
}
table.data td { padding: 12px 16px; border-top: 1px solid #EBEFED; vertical-align: middle; }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; background: #EEF1F0; color: var(--ink-2); }
.pill.active { background: var(--accent-soft); color: var(--accent-dark); }
.pill.pending { background: var(--amber-soft); color: #6E3304; }
.pill.suspended, .pill.rejected { background: var(--red-soft); color: #8A1616; }
.pill.view { background: var(--blue-soft); color: var(--blue); }

/* ---------- Access matrix ---------- */
.perm-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.perm-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  margin: 0; padding: 12px 16px; border: 0; border-top: 1px solid #EBEFED; min-width: 0;
}
.perm-row:first-child { border-top: 0; }
.perm-name { flex: 1 1 260px; float: left; padding: 0; display: flex; flex-direction: column; }
.perm-name span { font-size: 13px; color: var(--muted); }
.seg { display: inline-flex; background: #EEF1F0; border-radius: 10px; padding: 3px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-flex; align-items: center; justify-content: center; min-width: 76px; height: 38px; padding: 0 12px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg input[value=none]:checked + span { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(15,29,26,.12); }
.seg input:focus-visible + span { outline: 3px solid #7CC3B6; outline-offset: 1px; }
.access-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.access-list li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid #EBEFED; }

/* ---------- Lists, filters, detail pages ---------- */
.btn-danger { background: var(--paper); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); color: #8A1616; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 20px;
  border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2); text-decoration: none; font-size: 14px;
}
.tabs a.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tabs .count { font-size: 12px; font-weight: 700; opacity: .8; }
.search { display: flex; gap: 8px; flex: 0 1 380px; }
.search input { flex: 1; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius); font: inherit; background: var(--paper); }
.filters { justify-content: flex-start; }
.filters .field { margin: 0; flex: 0 1 200px; }
.filters .field.grow { flex: 1 1 240px; }
.two-col { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 999 1 520px; min-width: 0; }
.col-side { flex: 1 1 300px; min-width: 0; }
.facts { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 10px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.history li { display: flex; gap: 14px; font-size: 14px; }
.history .when { flex: 0 0 150px; color: var(--muted); font-size: 13px; }
.panel-title { padding: 18px 20px 6px; margin: 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat span { color: var(--muted); font-size: 14px; }
.stat strong { font-size: 28px; letter-spacing: -.02em; }
.notice.small { padding: 8px 12px; font-size: 13px; }

/* ---------- Studies and uploads ---------- */
.card-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card-choices.three { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card-choice { position: relative; display: block; cursor: pointer; margin: 0 !important; }
.card-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.card-choice span {
  display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--paper); font-weight: 400;
}
.card-choice strong { font-size: 15px; }
.card-choice small { font-size: 13px; color: var(--muted); }
.card-choice input:checked + span { border: 2px solid var(--accent); padding: 11px; background: #F3FAF8; }
.card-choice input:focus-visible + span { outline: 3px solid #7CC3B6; outline-offset: 2px; }
.pri-urgent strong { color: var(--amber); }
.pri-stat strong { color: var(--red); }
.pick-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pick {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; min-height: 44px;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--paper); font: inherit; color: var(--ink); cursor: pointer; text-align: left;
}
.pick small { color: var(--muted); font-size: 13px; }
.pick:hover { border-color: var(--accent); }
.pick.picked { border: 2px solid var(--accent); background: #F3FAF8; }
.summary .total { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 10px; }
.summary .btn-block + .btn-block { margin-top: 8px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 32px 16px;
  border: 2px dashed #A9B6B1; border-radius: 12px; background: #F8FAF9; color: var(--accent); cursor: pointer;
}
.dropzone strong { color: var(--ink); font-size: 16px; }
.dropzone span { color: var(--muted); font-size: 14px; }
.dropzone.over { border-color: var(--accent); background: #EAF5F2; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.upload-progress { margin-top: 16px; }
.upload-progress .bar { height: 8px; border-radius: 4px; background: #EEF1F0; overflow: hidden; }
.upload-progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-progress p { margin: 8px 0 0; }
.upload-errors { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; color: #8A1616; display: flex; flex-direction: column; gap: 4px; }
.panel-foot { padding: 10px 20px; margin: 0; border-top: 1px solid #EBEFED; }
.link-btn.danger { color: var(--red); margin-top: 10px; }
.pri { font-size: 12px; font-weight: 700; padding: 1px 6px; border-radius: 5px; }
.pri.pri-urgent { color: #6E3304; background: var(--amber-soft); }
.pri.pri-stat { color: #fff; background: var(--red); }
.pill.st-awaiting_payment, .pill.st-cancelled { background: #EEF1F0; color: var(--ink-2); }
.pill.st-waiting { background: var(--amber-soft); color: #6E3304; }
.pill.st-reading, .pill.st-submitted, .pill.st-returned { background: var(--blue-soft); color: var(--blue); }
.pill.st-approved { background: var(--accent-soft); color: var(--accent-dark); }
.plain { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.file-links a { overflow-wrap: anywhere; }
h3.sub { font-size: 14px; margin: 18px 0 6px; color: var(--muted); }
.pre { white-space: pre-wrap; margin: 0; }
[hidden] { display: none !important; }

/* ---------- Pricing ---------- */
.price-table input.num { width: 140px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; font: inherit; text-align: right; background: var(--paper); }
.price-table input.num.short { width: 90px; }
.price-table input:disabled { background: #F6F8F7; color: var(--ink-2); }
.price-table tr.inactive td { color: var(--muted); }
.price-table tr.inactive input.num { opacity: .6; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.flash.info { background: var(--blue-soft); color: var(--blue); }

/* ---------- Image viewer ---------- */
.viewer { background: #0A0F0E; color: #D5DEDB; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; outline: none; }
.viewer:focus-visible { box-shadow: 0 0 0 3px #7CC3B6; }
.vw-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid #1C2724; }
.vw-bar button, .vw-bar select {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: #C4CFCB; font: inherit; font-size: 13px; cursor: pointer;
}
.vw-bar button:hover { background: #15201D; }
.vw-bar button[aria-pressed=true] { border-color: #2E6F62; background: #12332D; color: #fff; font-weight: 600; }
.vw-bar select { border-color: #2A3633; background: #0F1715; }
.vw-bar [data-act=download] { border-color: #2A3633; }
.vw-sep { width: 1px; height: 24px; background: #24302D; margin: 0 4px; }
.vw-grow { flex: 1; }
.vw-warn { margin: 0; padding: 10px 14px; background: #3A2A0D; color: #F6D9A8; font-size: 13px; }
.vw-body { display: flex; min-height: 520px; flex: 1; }
.vw-series { width: 150px; flex: none; border-right: 1px solid #1C2724; padding: 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 70vh; }
.vw-ser { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border-radius: 8px; border: 2px solid transparent; background: #111A18; color: #C4CFCB; font: inherit; font-size: 12px; cursor: pointer; }
.vw-ser strong { font-size: 12px; color: #E8EEEC; overflow-wrap: anywhere; }
.vw-ser small { color: #9FB0AA; }
.vw-ser.on { border-color: #3FA08D; }
.vw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vw-stage { position: relative; flex: 1; min-height: 460px; touch-action: none; cursor: crosshair; overflow: hidden; }
.vw-stage[data-tool=pan] { cursor: grab; }
.vw-stage[data-tool=zoom] { cursor: zoom-in; }
.vw-canvas { position: absolute; inset: 0; display: block; }
.ov { position: absolute; margin: 0; font: 12px/1.5 "JetBrains Mono", monospace; color: #C4CFCB; pointer-events: none; text-shadow: 0 1px 2px #000; white-space: pre; }
.ov-tl { top: 10px; left: 12px; } .ov-tr { top: 10px; right: 12px; text-align: right; }
.ov-bl { bottom: 10px; left: 12px; } .ov-br { bottom: 10px; right: 12px; text-align: right; }
.vw-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; padding: 10px 16px; border-radius: 8px; background: rgba(10,15,14,.85); color: #E8EEEC; font-size: 14px; text-align: center; max-width: 80%; }
.vw-scroll { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-top: 1px solid #1C2724; font-size: 13px; }
.vw-scroll input { flex: 1; accent-color: #3FA08D; }
.vw-help { margin: 0; padding: 0 14px 10px; font-size: 12px; color: #8FA19B; }
@media (max-width: 700px) { .vw-body { flex-direction: column; } .vw-series { width: auto; flex-direction: row; max-height: none; overflow-x: auto; border-right: 0; border-bottom: 1px solid #1C2724; } .vw-ser { min-width: 130px; } }

/* ---------- Worklist and reading screen ---------- */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 16px 20px 10px; }
.panel-head h2 { margin: 0; }
.panel-head.tight { padding: 0 0 10px; }
.pri-dot { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.pri-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pri-dot.p-stat { color: var(--red); } .pri-dot.p-urgent { color: var(--amber); } .pri-dot.p-routine { color: var(--muted); }
.late { color: var(--red); font-weight: 600; }
.clamp { max-width: 280px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
td.clamp { display: table-cell; }
.avail .btn { gap: 10px; }
.avail .dot { width: 10px; height: 10px; border-radius: 50%; background: #8B9792; }
.avail .dot.on { background: var(--accent); }
.read-head h1 .small { font-weight: 500; }
.due { font-weight: 600; color: var(--ink-2); margin: 0; }
.due.late { color: var(--red); }
.read-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.read-images { flex: 999 1 560px; min-width: 0; }
.read-side { flex: 1 1 360px; min-width: 0; }
.report-form textarea { font-size: 15px; line-height: 1.55; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line-2); background: var(--paper); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.critical { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--radius); margin-bottom: 14px; cursor: pointer; }
.critical:has(input:checked) { border-color: var(--red); background: #FDF3F2; }
.critical input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); }
.critical span { display: flex; flex-direction: column; }
.critical small { color: var(--muted); font-size: 13px; }
.btn.grow { flex: 1 1 200px; }
.tpl-save { margin-top: 14px; font-size: 14px; }
.tpl-save summary, details.panel summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.tpl-save .inline-form { margin-top: 10px; }
.check-inline { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.release { margin: -8px 0 20px; }
.tpl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tpl-row form { margin: 0; }
.crit-tag { display: inline-block; margin: 0 0 8px; padding: 2px 10px; border-radius: 10px; background: var(--red); color: #fff; font-size: 13px; font-weight: 700; }
.priors li { padding-bottom: 6px; border-bottom: 1px solid #EBEFED; }
form.inline { display: inline; margin-left: 10px; }
.btn-row form { margin: 0; }

/* ---------- Reports ---------- */
.report-card { border-left: 0; }
.report-card .pre { font-size: 15px; }
.new-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.crit-tag.small { font-size: 11px; padding: 1px 8px; margin: 2px 0 0; }

/* ---------- Admin dashboard ---------- */
.dash-search { flex: 0 1 340px; }
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.alerts:empty { display: none; }
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 15px; }
.alert a { font-weight: 600; color: inherit; }
.alert.crit { background: var(--red-soft); color: #8A1616; }
.alert.warn { background: var(--amber-soft); color: #6E3304; }
.alert.info { background: var(--blue-soft); color: var(--blue); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
a.kpi:hover { border-color: var(--accent); color: var(--ink); }
.kpi span { color: var(--muted); font-size: 14px; }
.kpi strong { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi small { color: var(--muted); font-size: 13px; }
.kpi small.bad { color: var(--red); font-weight: 600; }
.kpi.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi.dark span, .kpi.dark small { color: #B8C6C1; }
.dash-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.dash-main { flex: 999 1 560px; min-width: 0; }
.dash-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; }
.people-list { gap: 0; margin: 0; }
.people-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid #EBEFED; }
.people-list li:first-child { border-top: 0; }
.people-list .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.people-list small { color: var(--muted); font-size: 13px; }
.avatar.soft { background: var(--accent-soft); color: var(--accent); }
.bars { gap: 12px; margin: 0; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.bar-track { display: block; height: 8px; border-radius: 4px; background: #EEF1F0; }
.bar-fill { display: block; height: 8px; border-radius: 4px; background: var(--accent); }
.bars li:hover .bar-fill { background: var(--accent-dark); }
.meter { height: 10px; border-radius: 5px; background: #EEF1F0; overflow: hidden; margin: 8px 0 10px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.meter.high span { background: var(--amber); }
.storage-line { margin: 0; }
.feed { gap: 10px; margin: 0; font-size: 14px; }
.feed li { display: flex; gap: 12px; }
.feed .when { flex: 0 0 44px; font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); padding-top: 2px; }
table.data.compact td, table.data.compact th { padding: 9px 16px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.pager span { display: flex; gap: 8px; }
.pill { white-space: nowrap; }
table.data a.mono, table.data .mono { white-space: nowrap; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.page-head .btn-row { align-items: center; }
.dash-search { width: 320px; max-width: 100%; }

/* ---------- Passwords and account ---------- */
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.label-row label { margin-bottom: 0 !important; }
.auth-box.wide.narrow { max-width: 480px; }
.facts.stack { grid-template-columns: 1fr; gap: 2px; }
.facts.stack dd { margin-bottom: 10px; }
.check-grid.one { grid-template-columns: 1fr; }
.waiting-box { border: 1px dashed var(--line-2); border-radius: 10px; padding: 14px 16px; margin: 0 0 18px; background: #FFFCF6; }
.waiting-box p { margin: 0 0 10px; }
.waiting-box .hint { margin: 10px 0 0; }
.panel.highlight { border-color: #E9B872; box-shadow: 0 0 0 3px #FBEFD9; }
form.sep { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Team ---------- */
.team-table tr.dim td { color: var(--muted); }
.role-form select { min-height: 36px; padding: 4px 8px; font: inherit; font-size: 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--paper); }
.role-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.field .role-choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 10px; cursor: pointer; font-weight: 400; margin: 0; }
.field .role-choice:has(input:checked) { border-color: var(--accent); background: #F3FAF8; }
.role-choice input { margin-top: 3px; }
.role-choice strong { display: block; font-size: 15px; }
.role-choice small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.team-table form.inline { margin-left: 6px; }

/* ---------- Payments and payouts ---------- */
.row-notice { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.earn-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.earn-list li:last-child { border-bottom: 0; }
.earn-list small { display: block; color: var(--muted); font-size: 13px; }
.earn-total { display: flex; justify-content: space-between; margin: 10px 0 0; padding-top: 10px; border-top: 2px solid var(--line); }
.payout-list { display: grid; gap: 16px; }
.payout { margin: 0; }
.payout.paid, .payout.skipped { background: #FAFBFA; }
.payout-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.payout-head h2 { margin: 0 0 2px; }
.payout .amount { font-size: 22px; }
.bank-facts { margin: 14px 0; padding: 12px 14px; background: #F6F8F7; border-radius: 10px; }
.payout-actions { display: grid; gap: 10px; margin-top: 12px; }
.payout-actions details.skip summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.payout-actions details.skip[open] summary { margin-bottom: 10px; }

/* ---------- Show / hide password ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 72px !important; }
.pw-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); min-height: 34px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.pw-toggle:hover { background: #EEF6F4; }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Phones and tablets ---------- */
.topbar, .side-backdrop { display: none; }
/* Phones and tablets (including a tablet held sideways) get the folding menu, so pages have the full width */
@media (max-width: 1199px) {
  .app { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
  }
  .topbar .brand { flex: 1; padding: 0; }
  .topbar .brand strong { font-size: 16px; }
  .topbar .avatar { width: 34px; height: 34px; text-decoration: none; }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -8px;
    border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer;
  }
  .menu-btn:hover { background: #F0F3F2; }
  .side {
    position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); max-width: none;
    overflow-y: auto; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .side.open { transform: none; box-shadow: 0 10px 40px rgba(10, 20, 18, .25); }
  .side-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 20, 18, .4); }
  body.nav-open { overflow: hidden; }
  .main { padding: 20px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .page-head { align-items: stretch; }
  .page-head > .btn, .page-head .btn-row { width: 100%; }
  .page-head .btn-row .btn, .page-head > .btn { flex: 1 1 auto; }
  .toolbar { align-items: stretch; }
  .toolbar .search, .toolbar .field { width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi strong { font-size: 22px; }
  .panel { padding: 16px; }
  .table-panel { padding: 0; }

  /* Table rows become cards: each cell shows its column name */
  table.data.stackable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data.stackable, table.data.stackable tbody, table.data.stackable tr, table.data.stackable td { display: block; width: 100%; }
  table.data.stackable tr { padding: 12px 16px; border-top: 1px solid #EBEFED; }
  table.data.stackable tbody tr:first-child { border-top: 0; }
  table.data.stackable td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; align-items: baseline; text-align: right; }
  table.data.stackable td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  table.data.stackable td.no-label { display: block; text-align: left; padding-top: 10px; }
  table.data.stackable td.no-label::before { content: none; }
  table.data.stackable td.no-label .btn, table.data.stackable td.no-label form { width: 100%; }
  table.data.stackable td.no-label form.inline { display: block; margin: 6px 0 0; }
  table.data.stackable td > .cell-v { min-width: 0; flex: 1 1 auto; }
  table.data.stackable td.no-label > .cell-v { display: flex; flex-wrap: wrap; gap: 8px; }
  table.data.stackable td.no-label > .cell-v > * { flex: 1 1 auto; }
  table.data.stackable td.right, table.data.stackable .right { text-align: right; }
  table.data.stackable .mono { white-space: normal; overflow-wrap: anywhere; }
  .table-wrap { overflow-x: visible; }
}

.vw-help-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .vw-help-mouse { display: none; } .vw-help-touch { display: inline; } }

/* ---------- Signature ---------- */
.sig-current { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.sig-current img, .sig-img-screen { max-width: 240px; max-height: 80px; object-fit: contain; background: #fff; }
.sig-img-screen { display: block; margin: 12px 0 4px; }
.sig-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.sig-tabs button { min-height: 38px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.sig-tabs button[aria-selected=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.sig-pad { display: block; width: 100%; max-width: 600px; aspect-ratio: 3 / 1; border: 1px dashed var(--line-2); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }

/* ---------- Viewer: documents, videos and reports ---------- */
.vw-doc { position: absolute; inset: 0; z-index: 2; background: #0B1210; display: flex; }
.vw-doc > * { flex: 1; min-width: 0; }
.vw-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.vw-pdf { display: flex; flex-direction: column; }
.vw-pdf .vw-frame { flex: 1; }
.vw-open { display: block; padding: 8px 12px; color: #9FE0D2; font-size: 13px; background: #0F1715; }
.vw-video { width: 100%; height: 100%; background: #000; object-fit: contain; }
.vw-pane-msg { display: flex; align-items: center; justify-content: center; padding: 24px; color: #C4CFCB; text-align: center; }
.vw-stage.doc-mode { cursor: default; touch-action: auto; }

/* ---------- Pages opened inside the mobile app: no menu or header, the content fills the screen ---------- */
.in-app .topbar, .in-app .side, .in-app .side-backdrop { display: none !important; }
.in-app .app { display: block; }
.in-app .main { margin: 0; padding: 12px; max-width: none; }

/* ---------- Earlier versions of an updated report ---------- */
.version { border-top: 1px solid var(--line, #DCE3E0); padding-top: 10px; margin-top: 10px; }
.version p { margin: 0 0 6px; }
td .btn-row { flex-wrap: nowrap; justify-content: flex-end; gap: 6px; margin-top: 0; }
