/* =====================================================================
   GSMaRT Diagnostic Clinic System - interface
   Cool mineral surfaces, deep lab teal, specimen-cap colour coding.
   ===================================================================== */

@font-face {
  font-family: "Atkinson Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Atkinson Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Atkinson Next";
  src: url("../fonts/atkinson-hyperlegible-next-latin-wght-italic.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --ink: #14262b;
  --ink-2: #3c5359;
  --ink-3: #687d83;
  --bg: #e7eeed;
  --bg-deep: #dbe5e3;
  --surface: #ffffff;
  --surface-2: #f4f8f7;
  --surface-3: #ecf2f1;
  --line: #d2dddb;
  --line-strong: #b9c9c6;
  --teal: #0e6e6a;
  --teal-hi: #128580;
  --teal-deep: #0a524f;
  --teal-tint: #dcefec;
  --bench: #0f3a3c;
  --bench-2: #154b4c;
  --violet: #5b4bb5;
  --violet-tint: #ebe8f8;
  --red: #b3302a;
  --red-tint: #fbe9e7;
  --amber: #9a6211;
  --amber-tint: #fbf1de;
  --green: #2b7448;
  --green-tint: #e3f2e8;
  --blue: #2c5d8f;
  --focus: #f0b429;

  --cap-lavender: #8e7cc3;
  --cap-red: #c8463d;
  --cap-gold: #d9a62a;
  --cap-blue: #6fa8dc;
  --cap-gray: #8c8c8c;
  --cap-green: #3d8b5a;

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;

  --raise: 0 1px 0 rgba(255, 255, 255, .95) inset, 0 1px 2px rgba(15, 58, 60, .07), 0 6px 18px -8px rgba(15, 58, 60, .18);
  --raise-hi: 0 1px 0 rgba(255, 255, 255, .95) inset, 0 2px 4px rgba(15, 58, 60, .08), 0 18px 40px -14px rgba(15, 58, 60, .32);
  --well: inset 0 1px 2px rgba(15, 58, 60, .10), inset 0 0 0 1px rgba(15, 58, 60, .06);

  --font: "Atkinson Next", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-deep); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.005em; }
p { margin: 0 0 .6em; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 700; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.mt-0 { margin-top: 0; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--bench-2) 0%, var(--bench) 220px, #0c3133 100%);
  color: #d6e6e4;
  display: flex; flex-direction: column;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark svg { display: block; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: .01em; color: #fff; }
.brand-text small { font-size: 11.5px; color: #9fc0bd; }
.nav { padding: 4px 10px 16px; flex: 1; }
.nav-group { margin-top: 4px; }
.nav-group-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: 0; color: #8fb3af; font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 9px 10px 6px; cursor: pointer; border-radius: 6px;
}
.nav-group-head:hover { color: #d9ecea; }
.caret { width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.nav-group.is-open .caret { transform: rotate(45deg); }
.nav-group ul { list-style: none; margin: 0; padding: 0; display: none; }
.nav-group.is-open ul { display: block; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 1px 0;
  color: #cfe1df; border-radius: 8px; font-size: 13.8px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active {
  color: #fff; background: linear-gradient(180deg, #1a6764, #135753);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .16) inset, 0 2px 6px rgba(0, 0, 0, .25);
}
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.sidebar-foot { padding: 12px 18px 18px; display: flex; gap: 16px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 13px; }
.sidebar-foot a { color: #a9c9c5; }
.sidebar-foot a:hover { color: #fff; }

.scrim { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 8px 24px;
  background: rgba(244, 248, 247, .86); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.icon-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; box-shadow: var(--raise); }
.icon-btn svg { width: 18px; height: 18px; stroke: var(--ink); stroke-width: 1.7; fill: none; stroke-linecap: round; }
.icon-btn.menu-btn { display: none; }
.top-context { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-company { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.branch-switch select { padding: 6px 30px 6px 10px; min-height: 34px; font-size: 13.5px; min-width: 170px; width: auto; }
.top-search { flex: 1; max-width: 420px; margin-left: auto; }
.top-search input { width: 100%; }
.top-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.top-search + .top-user { margin-left: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  color: #fff; background: radial-gradient(circle at 35% 30%, #1d8f89, var(--teal-deep)); box-shadow: 0 2px 5px rgba(10, 82, 79, .35);
}
.top-user .who { display: flex; flex-direction: column; line-height: 1.2; }
.top-user .who strong { font-size: 13.5px; }
.top-user .who small { font-size: 12px; color: var(--ink-3); }

.pagebar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 18px 24px 6px; }
.pagebar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pagebar h1 { font-size: 22px; font-weight: 700; }
.subtitle { margin: 2px 0 0; color: var(--ink-3); font-size: 13.5px; }
.back-link { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--raise); flex: none; }
.back-link svg { width: 16px; height: 16px; stroke: var(--ink); stroke-width: 2; fill: none; }
.pagebar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 12px 24px 32px; flex: 1; }
.content-narrow { max-width: 980px; }
.foot { padding: 14px 24px 20px; color: var(--ink-3); font-size: 12px; }

/* ---------- surfaces ---------- */
.panel {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--raise);
  border: 1px solid rgba(15, 58, 60, .06); margin-bottom: 18px; min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { font-size: 15.5px; font-weight: 700; }
.panel-head .hint { color: var(--ink-3); font-size: 13px; }
.panel-body { padding: 16px 18px; }
.panel-body.tight { padding: 0; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.panel.flat { box-shadow: none; border-color: var(--line); }
.inset { background: var(--surface-2); border-radius: var(--r-md); box-shadow: var(--well); padding: 12px 14px; }

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* key-value pairs */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 16px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: 13px; }
.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.kv-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 20px; }
.kv-cols div span { display: block; color: var(--ink-3); font-size: 12.5px; }
.kv-cols div strong { font-weight: 650; overflow-wrap: anywhere; }

/* stat trays */
.trays { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tray {
  position: relative; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--raise); padding: 14px 16px 14px 18px;
  border: 1px solid rgba(15, 58, 60, .06); overflow: hidden;
}
.tray::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--tone, var(--teal)); }
.tray .t-val { font-size: 26px; font-weight: 750; line-height: 1.1; display: block; }
.tray .t-lbl { color: var(--ink-2); font-size: 13px; display: block; margin-top: 4px; }
.tray .t-sub { color: var(--ink-3); font-size: 12px; display: block; }
.tray a.t-link { position: absolute; inset: 0; }
.tone-red { --tone: var(--red); }
.tone-amber { --tone: var(--amber); }
.tone-green { --tone: var(--green); }
.tone-violet { --tone: var(--violet); }
.tone-blue { --tone: var(--blue); }

/* ---------- controls ---------- */
label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input:not([type]), input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=time], input[type=tel], input[type=url], input[type=month], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: #fbfdfd; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 8px 11px; min-height: 38px; width: 100%; box-shadow: var(--well);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
select { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6 8l4 4 4-4' fill='none' stroke='%233c5359' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 16px; }
select[multiple] { background-image: none; padding-right: 11px; min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: var(--well), 0 0 0 3px rgba(14, 110, 106, .18); }
input[readonly], input:disabled, select:disabled, textarea[readonly] { background: var(--surface-3); color: var(--ink-2); }
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--teal); vertical-align: -3px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field .help { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.field.req > label::after { content: " *"; color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .c12 { grid-column: span 12; } .form-grid .c9 { grid-column: span 9; } .form-grid .c8 { grid-column: span 8; }
.form-grid .c6 { grid-column: span 6; } .form-grid .c4 { grid-column: span 4; } .form-grid .c3 { grid-column: span 3; }
.form-grid .c2 { grid-column: span 2; } .form-grid .c1 { grid-column: span 1; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; color: var(--ink); font-size: 14px; }
.check input { margin-top: 2px; flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.form-section { font-size: 14px; font-weight: 700; color: var(--ink); grid-column: span 12; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.input-group { display: flex; }
.input-group > input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; }

.btn {
  --b1: #13827d; --b2: #0e6e6a; --b3: #0a524f;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-size: 14px; font-weight: 650;
  line-height: 1; padding: 0 15px; min-height: 38px; border-radius: 9px; cursor: pointer; white-space: nowrap;
  color: #fff; background: linear-gradient(180deg, var(--b1), var(--b2)); border: 1px solid var(--b3);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .22) inset, 0 2px 0 var(--b3), 0 4px 10px -4px rgba(10, 82, 79, .55);
  transition: transform .06s, box-shadow .06s, filter .12s; text-decoration: none;
}
.btn:hover { filter: brightness(1.05); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 0 0 var(--b3); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.btn-ghost {
  --b3: #b9c9c6; color: var(--ink); background: linear-gradient(180deg, #ffffff, #f1f6f5); border-color: var(--line-strong);
  box-shadow: 0 1px 0 #fff inset, 0 2px 0 #c7d4d2, 0 4px 10px -6px rgba(15, 58, 60, .35);
}
.btn-ghost:hover { color: var(--ink); }
.btn-danger { --b1: #c23c35; --b2: #b3302a; --b3: #8d221d; }
.btn-violet { --b1: #6a5ac4; --b2: #5b4bb5; --b3: #45378f; }
.btn-amber { --b1: #b0761a; --b2: #9a6211; --b3: #774a0c; }
.btn-sm { min-height: 31px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: 15.5px; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--teal); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: var(--red); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.8px; }
.tbl th {
  text-align: left; font-weight: 650; font-size: 12.8px; color: var(--ink-2); background: var(--surface-2);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
.tbl th.num, .tbl th.right { text-align: right; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #e6eceb; vertical-align: top; }
.tbl tbody tr:hover td { background: #f6faf9; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
.tbl .sub { display: block; font-size: 12.5px; color: var(--ink-3); }
.tbl .sub.st { white-space: normal; }
.tbl .sub.st-bad { color: var(--red); } .tbl .sub.st-warn { color: var(--amber); } .tbl .sub.st-ok { color: var(--green); }
.tbl .sub.st-info { color: var(--blue); } .tbl .sub.st-violet { color: var(--violet); }
.tbl td.actions { white-space: nowrap; text-align: right; }
.tbl tr.is-flag td { background: #fff7f6; }
.tbl tr.is-muted td { color: var(--ink-3); }
.tbl input, .tbl select { min-height: 34px; padding: 6px 9px; }
.panel > .table-wrap:first-child .tbl th:first-child { border-top-left-radius: var(--r-lg); }
.panel > .table-wrap:first-child .tbl th:last-child { border-top-right-radius: var(--r-lg); }

/* ---------- status text (plain labels, coloured) ---------- */
.st { font-weight: 650; font-size: 13px; white-space: nowrap; }
.st::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; background: currentColor; opacity: .85; }
.st-ok { color: var(--green); }
.st-info { color: var(--blue); }
.st-warn { color: var(--amber); }
.st-bad { color: var(--red); }
.st-muted { color: var(--ink-3); }
.st-violet { color: var(--violet); }
.flag-h, .flag-l { color: var(--amber); font-weight: 750; }
.flag-c { color: var(--red); font-weight: 800; }

/* specimen tube cap marker */
.tube {
  --cap: var(--cap-gray);
  display: inline-block; width: 11px; height: 22px; border-radius: 3px 3px 6px 6px; vertical-align: middle; position: relative;
  background: linear-gradient(90deg, #eef3f2, #ffffff 45%, #dfe7e6); box-shadow: inset 0 0 0 1px rgba(20, 38, 43, .18);
  margin-right: 6px;
}
.tube::before {
  content: ""; position: absolute; left: -1.5px; right: -1.5px; top: -2px; height: 8px; border-radius: 3px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--cap) 80%, #000), var(--cap) 45%, color-mix(in srgb, var(--cap) 75%, #fff));
  background-color: var(--cap); box-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}

/* ---------- alerts, empty, callouts ---------- */
.alert { position: relative; padding: 11px 40px 11px 14px; border-radius: var(--r-md); margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.alert-success { background: var(--green-tint); border-color: #b9dcc6; color: #1d5634; }
.alert-error { background: var(--red-tint); border-color: #efc0bb; color: #852520; }
.alert-info { background: #e5eef7; border-color: #bdd1e6; color: #24496f; }
.alert-warn { background: var(--amber-tint); border-color: #ead1a2; color: #6e470c; }
.alert-x { position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; padding: 4px 6px; }
.callout { border-left: 4px solid var(--teal); background: var(--surface-2); padding: 10px 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-bottom: 14px; font-size: 13.8px; }
.callout.warn { border-left-color: var(--amber); background: var(--amber-tint); }
.callout.bad { border-left-color: var(--red); background: var(--red-tint); }
.callout.violet { border-left-color: var(--violet); background: var(--violet-tint); }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-3); }
.empty p { margin-bottom: 12px; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.toolbar .field { min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 18px; flex-wrap: wrap; font-size: 13.5px; }
.pager a, .pager span.cur { min-width: 32px; height: 32px; padding: 0 9px; display: inline-grid; place-items: center; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); }
.pager span.cur { background: var(--teal); color: #fff; border-color: var(--teal-deep); }
.pager-info { margin-right: auto; color: var(--ink-3); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--teal-deep); border-bottom-color: var(--teal); }

/* custody rail: the specimen journey */
.rail { display: flex; gap: 0; overflow-x: auto; padding: 6px 2px 2px; }
.rail-step { flex: 1; min-width: 104px; position: relative; text-align: center; font-size: 12.5px; color: var(--ink-3); padding-top: 26px; }
.rail-step::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 3px; background: var(--line); }
.rail-step:first-child::before { left: 50%; }
.rail-step:last-child::before { right: 50%; }
.rail-step .dot { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); width: 17px; height: 17px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 3px var(--line-strong); }
.rail-step.done { color: var(--ink); }
.rail-step.done::before { background: var(--teal); }
.rail-step.done .dot { background: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }
.rail-step.now .dot { background: var(--surface); box-shadow: inset 0 0 0 4px var(--teal), 0 0 0 4px var(--teal-tint); }
.rail-step.bad .dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-tint); }
.rail-step strong { display: block; font-weight: 650; }
.rail-step small { display: block; font-size: 11.5px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 3px var(--teal); }
.timeline .when { color: var(--ink-3); font-size: 12.5px; }

/* order/patient header block */
.idcard { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.idcard .id-main { min-width: 220px; }
.idcard .id-name { font-size: 18px; font-weight: 750; }
.idcard .id-meta { color: var(--ink-2); font-size: 13.5px; }

/* line editor */
.lines .tbl td { vertical-align: middle; }
.line-remove { color: var(--red); background: none; border: 0; cursor: pointer; font-size: 18px; padding: 2px 6px; }
.totals { margin-left: auto; min-width: 260px; }
.totals div { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; }
.totals .grand { font-size: 17px; font-weight: 750; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }

/* autocomplete */
.ac { position: relative; }
.ac-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border-radius: var(--r-md); box-shadow: var(--raise-hi); border: 1px solid var(--line); max-height: 300px; overflow-y: auto; }
.ac-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #edf2f1; font-size: 13.8px; }
.ac-item:last-child { border-bottom: 0; }
.ac-item:hover, .ac-item.is-active { background: var(--teal-tint); }
.ac-item small { display: block; color: var(--ink-3); }

/* dialog */
dialog.modal { border: 0; padding: 0; border-radius: var(--r-lg); box-shadow: var(--raise-hi); width: min(560px, calc(100vw - 24px)); color: var(--ink); }
dialog.modal::backdrop { background: rgba(12, 40, 42, .45); }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); }

/* mini charts */
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 90px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 6px; box-shadow: var(--well); overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(180deg, var(--teal-hi), var(--teal)); border-radius: 6px; }

/* queue display */
.queue-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.token-big { font-size: 40px; font-weight: 800; letter-spacing: .02em; }

/* auth screens */
.auth-body { background: var(--bg); min-height: 100vh; }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); }
.auth-art {
  position: relative; overflow: hidden; color: #e3f0ee;
  background: radial-gradient(120% 90% at 20% 10%, #1c6461 0%, #0f3a3c 55%, #0b2c2e 100%);
  display: flex; flex-direction: column; justify-content: space-between; padding: 36px 40px;
}
.auth-art .brand { padding: 0; }
.auth-art h2 { font-size: 30px; font-weight: 750; line-height: 1.15; max-width: 16ch; color: #fff; margin-bottom: 14px; }
.auth-art p { color: #a8c8c4; max-width: 44ch; }
.rack { display: flex; align-items: flex-end; gap: 18px; padding: 0 8px 0; margin: 28px 0 8px; position: relative; }
.rack::after { content: ""; position: absolute; left: -10px; right: -10px; bottom: -14px; height: 22px; border-radius: 8px; background: linear-gradient(180deg, #0c4a4a, #083435); box-shadow: 0 10px 24px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .12); }
.vial { --cap: #8e7cc3; --fill: 55%; --liq: #b3433b; position: relative; width: 34px; height: 150px; border-radius: 6px 6px 17px 17px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, .95) 35%, rgba(255, 255, 255, .5) 70%, rgba(255, 255, 255, .75));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .6), 0 6px 14px rgba(0, 0, 0, .35); z-index: 1; overflow: hidden; }
.vial::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--fill); background: linear-gradient(90deg, color-mix(in srgb, var(--liq) 75%, #000), var(--liq) 40%, color-mix(in srgb, var(--liq) 80%, #fff)); opacity: .9; }
.vial .cap { position: absolute; left: -3px; right: -3px; top: 0; height: 34px; border-radius: 6px; background: linear-gradient(90deg, color-mix(in srgb, var(--cap) 70%, #000), var(--cap) 40%, color-mix(in srgb, var(--cap) 70%, #fff)); background-color: var(--cap); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18); z-index: 2; }
.vial .lbl { position: absolute; left: 3px; right: 3px; top: 48px; height: 46px; background: #fff; border-radius: 2px; z-index: 2;
  background-image: repeating-linear-gradient(90deg, #222 0 1px, #fff 1px 3px, #222 3px 5px, #fff 5px 6px); background-size: 80% 62%; background-repeat: no-repeat; background-position: center 30%; opacity: .9; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 22px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; box-shadow: var(--raise-hi); padding: 30px 28px; border: 1px solid rgba(15, 58, 60, .06); }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .lead { color: var(--ink-3); margin-bottom: 20px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: 13.5px; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-wide { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .2s ease; }
  .app.nav-open .sidebar { transform: translateX(0); box-shadow: 12px 0 40px rgba(0, 0, 0, .35); }
  .scrim { position: fixed; inset: 0; background: rgba(12, 40, 42, .45); z-index: 50; display: none; }
  .app.nav-open .scrim { display: block; }
  .icon-btn.menu-btn { display: inline-grid; }
  .top-user .who { display: none; }
  .g3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: 24px 22px; }
  .auth-art h2 { font-size: 24px; }
  .rack { display: none; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 8px 14px; gap: 10px; }
  .top-search { order: 5; flex-basis: 100%; max-width: none; margin-left: 0; }
  .top-context { flex: 1; min-width: 0; gap: 8px; }
  .top-company { max-width: 34vw; font-size: 13.5px; }
  .branch-switch { flex: 1; min-width: 0; }
  .branch-switch select { min-width: 0; width: 100%; }
  .top-user { margin-left: 0; }
  .pagebar { padding: 14px 16px 4px; }
  .pagebar h1 { font-size: 19px; }
  .content { padding: 10px 16px 28px; }
  .g2, .g4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .c9, .form-grid .c8, .form-grid .c6, .form-grid .c4, .form-grid .c3, .form-grid .c2, .form-grid .c1 { grid-column: span 12; }
  .form-grid .c3.keep, .form-grid .c4.keep { grid-column: span 6; }
  .panel-body { padding: 14px; }
  .panel-head { padding: 12px 14px; }
  .toolbar { padding: 12px 14px; }
  .toolbar .field, .toolbar .grow { min-width: 0; flex: 1 1 100%; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .bar-row { grid-template-columns: 90px minmax(0, 1fr) 70px; }
  /* stacked tables */
  table.tbl.stack-sm thead { display: none; }
  table.tbl.stack-sm, table.tbl.stack-sm tbody, table.tbl.stack-sm tr, table.tbl.stack-sm td { display: block; width: 100%; }
  table.tbl.stack-sm tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.tbl.stack-sm td { border: 0; padding: 4px 14px; text-align: right; overflow: hidden; }
  table.tbl.stack-sm td::before { content: attr(data-label); float: left; color: var(--ink-3); font-size: 12.5px; text-align: left; font-weight: 600; margin-right: 12px; }
  table.tbl.stack-sm td .sub { display: block; }
  table.tbl.stack-sm td.actions { text-align: right; }
  table.tbl.stack-sm td.actions::before { content: none; }
  table.tbl.stack-sm tfoot { display: block; }
  .totals { min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
