/* MedTrack console: dashboard + tracking page styles */
:root {
  --bg: #F3F6F5;
  --panel: #FFFFFF;
  --panel-2: #F8FAF9;
  --ink: #0E1B1A;
  --muted: #4A5A58;
  --faint: #6B7B79;
  --line: #DDE5E3;
  --line-soft: #ECF1F0;
  --primary: #0E6B5C;
  --primary-ink: #FFFFFF;
  --primary-soft: #E2F1EE;
  --side: #0F2523;
  --side-ink: #CFE0DD;
  --ok: #18794E;
  --ok-soft: #E3F5EA;
  --warn: #9A4A06;
  --warn-dot: #D97706;
  --warn-soft: #FDF1E1;
  --bad: #B42318;
  --bad-soft: #FDECEA;
  --cold: #1F5FA8;
  --cold-soft: #E6EFFA;
  --info: #3E4C9E;
  --info-soft: #ECEEFA;
  --shadow: 0 1px 2px rgba(14, 27, 26, 0.06);
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0D1514;
  --panel: #142020;
  --panel-2: #182625;
  --ink: #E6EEEC;
  --muted: #A7B7B4;
  --faint: #8A9B98;
  --line: #24342F;
  --line-soft: #1C2B29;
  --primary: #3FB39C;
  --primary-ink: #06201B;
  --primary-soft: #16332E;
  --side: #0A1110;
  --side-ink: #A9BDB9;
  --ok: #4CC38A;
  --ok-soft: #12301F;
  --warn: #F0A54A;
  --warn-dot: #F0A54A;
  --warn-soft: #33240F;
  --bad: #F2867A;
  --bad-soft: #3A1714;
  --cold: #7FB2F0;
  --cold-soft: #13253D;
  --info: #A9B2F0;
  --info-soft: #1D2240;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; }
body { font-variant-numeric: tabular-nums; }
a { color: var(--primary); text-underline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.15; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.num { text-align: right; }
svg.ic { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

button, .btn, input, select, textarea { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  font-size: 15px; color: var(--ink); font-weight: 400;
}
textarea { padding: 10px 12px; min-height: 80px; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--primary); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; }

/* ---------- shell ---------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
  flex: 1 1 220px; max-width: 236px; background: var(--side); color: var(--side-ink); padding: 20px 12px;
  display: flex; flex-direction: column; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; font-size: 18px; color: #fff; letter-spacing: -0.2px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: #3FB39C; display: grid; place-items: center; color: #06201B; }
.brand-mark svg { stroke: #06201B; stroke-width: 2.6; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--side-ink); text-decoration: none; padding: 10px 10px; border-radius: 9px; font-size: 15px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav a.active { color: #fff; background: rgba(63,179,156,0.18); font-weight: 600; }
.nav a.active svg { stroke: #6FD3BE; }
.nav .badge { margin-left: auto; background: #D97706; color: #1F1300; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 8px; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; font-size: 14px; }
.side-foot .row { display: flex; gap: 8px; }
.side-foot button { flex: 1; white-space: nowrap; padding: 0 6px; background: transparent; border: 1px solid rgba(255,255,255,0.18); color: var(--side-ink); border-radius: 8px; min-height: 36px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; }
.side-foot button:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

.main { flex: 999 1 560px; min-width: 0; padding: 26px 30px 40px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.row > .grow { flex: 999 1 520px; }
.row > .side-col { flex: 1 1 320px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- action stream (the page opener) ---------- */
.actions { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.actions-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.actions-head h2 { display: flex; align-items: center; gap: 10px; }
.count { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--warn-soft); color: var(--warn); }
.count.zero { background: var(--ok-soft); color: var(--ok); }
.action { display: grid; grid-template-columns: 4px 1fr auto; gap: 14px; align-items: center; padding: 12px 18px 12px 0; border-bottom: 1px solid var(--line-soft); }
.action:last-child { border-bottom: 0; }
.action .bar { align-self: stretch; border-radius: 0 3px 3px 0; }
.action.bad .bar { background: var(--bad); }
.action.warn .bar { background: var(--warn-dot); }
.action.cold .bar { background: var(--cold); }
.action .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.action .what b { font-weight: 650; }
.action .what span { color: var(--muted); font-size: 14px; }
.action .tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.action.bad .tag { background: var(--bad-soft); color: var(--bad); }
.action.warn .tag { background: var(--warn-soft); color: var(--warn); }
.action.cold .tag { background: var(--cold-soft); color: var(--cold); }
.actions .clear { padding: 18px; color: var(--ok); display: flex; gap: 10px; align-items: center; }

/* ---------- figures strip ---------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.figure { padding: 14px 18px; border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; }
.figure:last-child { border-right: 0; }
.figure .label { font-size: 13px; color: var(--muted); }
.figure .value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.figure .sub { font-size: 12.5px; color: var(--faint); }
.figure .delta.up { color: var(--ok); }
.figure .delta.down { color: var(--bad); }
.figure.cold .value { color: var(--cold); }
.figure.warn .value { color: var(--warn); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12.5px; color: var(--faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
td.code { white-space: nowrap; color: var(--muted); font-size: 13px; }
.bar-track { height: 8px; border-radius: 4px; background: var(--line-soft); min-width: 80px; }
.bar-track > span { display: block; height: 8px; border-radius: 4px; background: var(--primary); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip svg.ic { width: 13px; height: 13px; }
.chip.packing { background: var(--line-soft); color: var(--muted); }
.chip.loaded { background: var(--info-soft); color: var(--info); }
.chip.en_route { background: var(--primary-soft); color: var(--primary); }
.chip.delivered, .chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.cancelled, .chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.cold { background: var(--cold-soft); color: var(--cold); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.note { display: flex; gap: 10px; padding: 11px 12px; border-radius: 10px; font-size: 14px; }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.cold { background: var(--cold-soft); color: var(--cold); }
.note b { display: block; }

.map { height: 300px; border-radius: 10px; overflow: hidden; background: var(--line-soft); }
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
.daychart { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.daychart span { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; opacity: 0.85; }
.daychart span.zero { background: var(--line); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.photo-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; text-align: left; padding: 0; }
.photo-card:hover { border-color: var(--faint); }
.photo-card img { width: 100%; height: 150px; object-fit: cover; background: var(--line-soft); display: block; }
.photo-card .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.photo-card .body b { font-size: 14.5px; }

.weekdays { display: flex; gap: 4px; flex-wrap: wrap; }
.weekdays label { display: inline-flex; }
.weekdays input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.weekdays span { display: inline-grid; place-items: center; min-width: 44px; height: 36px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.weekdays input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.weekdays input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); }
.day-dots { display: flex; gap: 3px; }
.day-dots i { display: inline-grid; place-items: center; width: 26px; height: 22px; border-radius: 6px; font-size: 11px; font-style: normal; font-weight: 600; background: var(--line-soft); color: var(--faint); }
.day-dots i.on { background: var(--primary-soft); color: var(--primary); }

.item-rows { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: minmax(140px, 2fr) minmax(90px, 1fr) minmax(90px, 1fr) minmax(110px, 1fr) 36px; gap: 8px; align-items: center; }
.item-row input { min-height: 38px; font-size: 14px; }
@media (max-width: 640px) { .item-row { grid-template-columns: 1fr 1fr; } }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; max-width: min(720px, 94vw); width: 100%; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(6, 14, 13, 0.55); }
dialog form, .dialog-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px 16px; font-size: 14px; }
.kv span { color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.sig { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; max-width: 320px; }
.sig img { width: 100%; display: block; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 10px; z-index: 9999; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.empty { padding: 28px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-size: 14px; font-weight: 600; border: 1px solid transparent; }
.tabs a.active { background: var(--panel); border-color: var(--line); color: var(--ink); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.login { width: 100%; max-width: 380px; }
.login .brand { color: var(--ink); padding: 0; }

@media print {
  .side, .toolbar, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .panel, .actions, .figures { break-inside: avoid; box-shadow: none; }
}
@media (max-width: 720px) {
  .main { padding: 16px; }
  .side { max-width: none; flex-basis: 100%; padding: 12px; gap: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { padding: 8px 10px; }
  .side-foot { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 0; }
  .figure { border-right: 0; border-bottom: 1px solid var(--line-soft); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
