/* MedCabinet — console theme (matches the approved mockups) */
@import url("../fonts/fonts.css");

:root {
  --bg: #0B0F14; --side: #0E131A; --card: #121821; --card2: #0F151D; --input: #0B1017;
  --line: #243041; --line2: #1E2836; --line3: #2A3647; --hover: #141C26; --sel: #16202C;
  --text: #E6EDF3; --text2: #C9D4E0; --muted: #93A1B3; --nav: #AEBACB;
  --accent: #2DD4BF; --accent-ink: #04201C; --accent-soft: #5EEAD4;
  --ok-bg: #0F2E2A; --ok-fg: #5EEAD4; --ok-line: #155E56;
  --warn-bg: #33250A; --warn-fg: #FBBF24; --warn-line: #6B4E0F;
  --bad-bg: #3A1418; --bad-fg: #FCA5A5; --bad-line: #7F1D1D;
  --info-bg: #0F2340; --info-fg: #93C5FD; --info-line: #1E3A8A;
  --r: 14px; --r-sm: 10px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--sans); }
a { color: var(--accent-soft); }
a:hover { color: #99F6E4; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.lbl { font: 600 11px/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lbl.bad { color: var(--bad-fg); } .lbl.warn { color: var(--warn-fg); }
.pre { white-space: pre-line; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.ml-auto { margin-left: auto; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 248px; flex: none; background: var(--side); border-right: 1px solid #1C2532; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; flex: none; }
.brand-logo { display: block; flex: none; border-radius: 22%; }
.brand-name { font: 700 15px var(--display); }
.brand-sub { font: 400 11px var(--mono); color: var(--muted); }
.ws-switch { margin: 0 0 12px; }
.ws-switch select, .ws-static { width: 100%; height: 44px; border-radius: var(--r-sm); background: var(--card); border: 1px solid var(--line);
  color: var(--text); font: 500 13px var(--sans); padding: 0 10px; }
.ws-static { display: flex; flex-direction: column; justify-content: center; }
.nav { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  color: var(--nav); text-decoration: none; font: 500 14px var(--sans); }
.nav:hover { color: var(--text); background: var(--hover); }
.nav.on { background: var(--sel); color: var(--text); box-shadow: inset 0 0 0 1px #24344A; }
.nav .count { margin-left: auto; }
.nav-sep { flex: 1 1 18px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid #1C2532; margin-top: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #1E3A5F; color: #BFDBFE; display: flex;
  align-items: center; justify-content: center; font: 600 13px var(--sans); flex: none; text-transform: uppercase; }
.side-user button { margin-left: auto; }
.main { flex: 1 1 auto; min-width: 0; padding: 28px 36px 48px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head .title { display: flex; flex-direction: column; gap: 6px; }
.crumbs { font-size: 13px; color: var(--muted); }
.topbar, .tabbar { display: none; }

/* ---------- surfaces ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.pad { padding: 20px 22px; }
.pad-sm { padding: 16px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; flex-wrap: wrap; }
.fact { background: var(--card2); border: 1px solid var(--line2); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; }
.fact.ok { border-color: var(--ok-line); } .fact.warn { border-color: var(--warn-line); } .fact.bad { border-color: var(--bad-line); }
.fv { font: 600 16px/1.35 var(--sans); color: var(--text); white-space: pre-line; }
.fs { font-size: 13px; color: var(--muted); line-height: 1.45; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.col-main { flex: 2 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.col-side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.stat { padding: 18px 20px; text-decoration: none; color: var(--text); display: block; }
.stat-num { font: 700 40px/1.1 var(--display); margin-top: 10px; }
.stat:hover { border-color: #33445C; }
.rowi { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-top: 1px solid var(--line2); }
.rowi .grow > a, .rowi .name { font-weight: 600; color: var(--text); text-decoration: none; }
.empty { padding: 28px 22px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.p { font-size: 15px; line-height: 1.6; color: var(--text2); }
.li { display: flex; gap: 10px; font-size: 14px; line-height: 1.5; color: var(--text2); }
.dot { flex: none; width: 6px; height: 6px; border-radius: 50%; margin-top: 8px; background: var(--muted); }
.dot.bad { background: var(--bad-fg); } .dot.warn { background: var(--warn-fg); }

/* ---------- chips & alerts ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 2px 10px; border-radius: 999px;
  font: 500 12px var(--sans); background: #1A2330; color: var(--text2); border: 1px solid var(--line3); white-space: nowrap; text-decoration: none; }
.chip.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-line); }
.chip.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-line); }
.chip.bad { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-line); }
.chip.info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-line); }
.chip.sm { min-height: 20px; padding: 0 7px; font-size: 11px; }
a.chip:hover { color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; border: 1px solid; font-size: 14px; line-height: 1.5; }
.alert.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #CCFBF1; }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); color: #FDE68A; }
.alert.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-fg); }
.alert.info { background: var(--info-bg); border-color: var(--info-line); color: #BFDBFE; }
.alert svg { flex: none; margin-top: 1px; }
.flashes { display: flex; flex-direction: column; gap: 8px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid var(--line3); background: var(--sel); color: var(--text);
  font: 600 14px var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #3B4B62; color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #5EEAD4; }
.btn.danger { color: var(--bad-fg); border-color: var(--bad-line); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }
.btn.icon { padding: 0; width: 40px; }
.inline-form { display: inline; }
button.link { background: none; border: 0; padding: 0; color: var(--accent-soft); font: inherit; cursor: pointer; text-decoration: underline; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .flabel { font: 600 13px var(--sans); color: var(--text2); }
.field .help { font-size: 12px; color: var(--muted); }
.input, .field input[type=text], .field input[type=password], .field input[type=number], .field input[type=date],
.field input[type=month], .field input[type=email], .field input[type=tel], .field input[type=search], .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line3);
  background: var(--input); color: var(--text); font: 500 14px var(--sans); }
.field textarea { padding: 10px 12px; min-height: 84px; line-height: 1.5; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(45,212,191,.18); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text2); cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.fieldset legend { font: 600 18px var(--display); margin-bottom: 14px; padding: 0; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; position: sticky; bottom: 0;
  padding: 14px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.seg { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line2); flex-wrap: wrap; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; align-items: center; justify-content: center; height: 36px; padding: 0 12px; border-radius: 8px;
  color: var(--nav); font: 500 13px var(--sans); cursor: pointer; text-align: center; }
.seg input:checked + span { background: #22303F; color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.search-box { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px; border-radius: 12px;
  background: var(--input); border: 1px solid var(--line3); }
.search-box input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font: 500 16px var(--sans); min-height: 48px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters select { min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line3); background: var(--card); color: var(--text); font: 500 13px var(--sans); }
details.more > summary { cursor: pointer; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; padding: 11px 14px; font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line); background: var(--card2); white-space: nowrap; }
table.t td { padding: 13px 14px; border-bottom: 1px solid var(--line2); font-size: 14px; vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .nm { font-weight: 600; color: var(--text); text-decoration: none; }
table.t .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------- medication pieces ---------- */
.med-head { display: flex; flex-wrap: wrap; gap: 22px; align-items: center; padding: 22px 24px; }
.thumb { width: 84px; height: 84px; border-radius: 16px; background: var(--card2); border: 1px dashed var(--line3); flex: none;
  display: flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.med-actions { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; border-top: 1px solid var(--line2); padding-top: 16px; }
.big-num { font: 700 26px var(--display); }
.head-facts { display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap; }
.head-facts .fact { min-width: 160px; }
.tile-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { padding: 16px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 8px; }
.tile:hover { border-color: #33445C; color: var(--text); }
.tile-name { font: 600 17px var(--display); }
.files { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.file { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.file a.prev { display: flex; align-items: center; justify-content: center; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden;
  background: var(--card2); border: 1px solid var(--line2); color: var(--muted); text-decoration: none; }
.file a.prev img { width: 100%; height: 100%; object-fit: cover; }
.file .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }
.pack-edit { padding: 14px 0 4px; }
.qr svg { width: 220px; height: 220px; border-radius: 12px; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font: 500 16px var(--mono); }
.codes span { background: var(--card2); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; text-align: center; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .side { display: none; }
  .main { padding: 16px 16px 96px; gap: 18px; }
  h1 { font-size: 26px; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
    background: var(--side); border-bottom: 1px solid #1C2532; position: sticky; top: 0; z-index: 5; }
  .topbar .ws-switch { margin: 0 0 0 auto; max-width: 55%; }
  .topbar .ws-switch select, .topbar .ws-static { height: 38px; }
  .shell { flex-direction: column; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--side);
    border-top: 1px solid #1C2532; padding: 4px 6px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px;
    color: var(--muted); text-decoration: none; font: 500 10px var(--sans); }
  .tab.on { color: var(--accent-soft); }
  .tab .plus { width: 46px; height: 46px; border-radius: 14px; background: var(--accent); color: var(--accent-ink);
    display: flex; align-items: center; justify-content: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-actions { bottom: 72px; }
  .med-head { padding: 18px; }
  .head-facts { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .head-facts .fact { min-width: 0; }
  .stat-num { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  .side, .topbar, .tabbar, .med-actions, .form-actions, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .fact { background: #fff; border-color: #ccc; }
}
