/* NebulaHIS — teal workspace, glass controls and light report cards. */
@import url('/css/fonts.css');

:root {
  color-scheme: light;
  --navy-950: #103139;
  --navy-900: #143c44;
  --navy-850: #164751;
  --navy-800: #17525b;
  --navy-700: #17626b;
  --navy-600: #146a70;
  --navy-500: #25878a;
  --navy-300: #82b2b2;
  --navy-200: #b4d2d1;
  --navy-100: #dcebea;
  --navy-50: #eff6f5;
  --yellow-400: #e0ffef;
  --yellow-500: #b5eed5;
  --yellow-600: #8bd3b2;
  --yellow-100: #d8f3e9;
  --yellow-50: #eef9f4;
  /* Surfaces + ink */
  --white: #ffffff;
  --canvas: #ebefee;
  --ink: #173238;
  --ink-2: #3e575b;
  --ink-3: #526c70;
  --line: #dce8e6;
  --line-strong: #c5d9d7;
  --grid: #e5efed;
  /* On navy */
  --on-navy-muted: #d6eceb;
  --glass: rgba(232, 254, 251, .1);
  --glass-strong: rgba(232, 254, 251, .2);
  --glass-line: rgba(232, 254, 251, .27);
  --s1: #16858c;
  --s2: #d39746;
  --s3: #277e60;
  --s4: #6a6eb0;
  --s5: #8d6db5;
  --s1-soft: #80bdbb;
  /* Status (always with icon + label) */
  --good: #0f7a3a;
  --good-bg: #e7f6ec;
  --serious: #b4501f;
  --serious-bg: #fdeee6;
  --critical: #c22f2f;
  --critical-bg: #fdecec;
  --info-bg: var(--navy-50);

  --radius-xl: 30px;
  --radius: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(16, 49, 57, .045), 0 10px 32px -20px rgba(16, 49, 57, .24);
  --shadow-2: 0 1px 2px rgba(16, 49, 57, .05), 0 17px 40px -18px rgba(16, 49, 57, .3);
  --shadow-pop: 0 18px 50px -12px rgba(16, 49, 57, .35);
  --shadow-yellow: 0 6px 18px -10px rgba(33, 138, 111, .45);
  --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Leelawadee UI', Tahoma, system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--navy-600); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--yellow-100); color: var(--navy-950); }

.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 15px; height: 15px; }
.ico.lg { width: 22px; height: 22px; }

/* ---------- Workspace shell ---------- */
.shell {
  --workspace-gutter: clamp(18px, 3.2vw, 46px);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 44px);
  width: calc(100% - 44px);
  max-width: 1540px;
  margin: 22px auto;
  border: 4px solid rgba(255, 255, 255, .85);
  border-radius: 34px;
  background:
    radial-gradient(65% 390px at 75% 250px, #a9ceba4d, transparent 78%),
    radial-gradient(46% 300px at 100% 0, #617dad7a, transparent 78%),
    linear-gradient(180deg, #184451 0, #27606a 145px, #659494 315px, #c4dbd7 510px, #e9f3f0 790px, #edf5f3 100%);
  background-repeat: no-repeat;
  box-shadow: 0 24px 80px -43px #214c50a6, 0 4px 12px -5px #214c5026;
}
.masthead {
  position: relative; z-index: 30;
  padding: 22px var(--workspace-gutter) 19px;
  border-radius: 30px 30px 0 0;
  color: #fff;
}
.masthead-inner { width: 100%; }
.masthead :focus-visible { outline-color: var(--yellow-500); }
.masthead .ws-menu :focus-visible, .masthead .user-menu :focus-visible, .masthead .dropdown-menu :focus-visible { outline-color: var(--navy-600); }

.topbar { display: flex; align-items: center; gap: 11px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: none; text-decoration: none; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%; background: #fff; overflow: hidden; }
.brand-mark img { width: 34px; height: 34px; object-fit: contain; }
.brand-word { display: flex; flex-direction: column; min-width: 0; }
.brand-word b { font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.brand-word b span { color: var(--yellow-500); }
.brand-word small { font-size: 10px; font-weight: 500; letter-spacing: .065em; color: var(--on-navy-muted); white-space: nowrap; }
.btn.nav-toggle { display: none; }

/* Workspace switcher */
.ws-switch { position: relative; margin-left: auto; min-width: 0; }
.ws-button {
  display: flex; align-items: center; gap: 8px; text-align: left; max-width: 228px; width: 100%; min-height: 42px;
  border: 1px solid var(--glass-line); background: var(--glass); color: #fff;
  border-radius: var(--radius-pill); padding: 4px 14px 4px 5px; transition: background .16s var(--ease);
}
.ws-button:hover { background: var(--glass-strong); }
.ws-code { flex: none; display: grid; place-items: center; min-width: 40px; height: 31px; padding: 0 8px; border-radius: var(--radius-pill); background: var(--yellow-500); color: var(--navy-950); font-weight: 700; font-size: 11px; letter-spacing: .02em; }
.ws-button .ws-code { display: block; max-width: 72px; overflow: hidden; text-overflow: ellipsis; line-height: 31px; text-align: center; white-space: nowrap; }
.ws-name { min-width: 0; flex: 1; font-size: 13px; line-height: 1.35; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-label { display: block; font-size: 11px; color: var(--ink-3); padding: 6px 10px 4px; }
.ws-menu {
  position: absolute; z-index: 40; right: 0; width: min(320px, 86vw); top: calc(100% + 8px);
  background: #fff; color: var(--ink); border-radius: 18px; box-shadow: var(--shadow-pop); padding: 6px; display: none;
}
.ws-switch.open .ws-menu { display: block; animation: pop .16s var(--ease); }
.ws-option { width: 100%; display: flex; gap: 10px; align-items: center; border: 0; background: none; padding: 8px; border-radius: 12px; text-align: left; font-size: 13px; }
.ws-option:hover { background: var(--navy-50); }
.ws-option[aria-current="true"] { background: var(--yellow-50); }
.ws-option .ws-code { background: var(--navy-100); color: var(--navy-800); height: 28px; min-width: 38px; }
.ws-option[aria-current="true"] .ws-code { background: var(--yellow-500); color: var(--navy-950); }
.ws-add { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.ws-add button { color: var(--navy-600); font-weight: 500; }

/* Account menu */
.sb-user { position: relative; flex: none; }
.sb-user-btn { display: grid; place-items: center; width: 42px; height: 42px; padding: 3px; border-radius: 50%; border: 1px solid var(--glass-line); background: var(--glass); color: #fff; transition: background .16s var(--ease); }
.sb-user-btn:hover { background: var(--glass-strong); }
.sb-user-btn .avatar { width: 34px; height: 34px; background: #e2f5ef; color: var(--navy-900); }
.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-100); color: var(--navy-800); font-weight: 600; font-size: 13px; border: 2px solid rgba(255,255,255,.3); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.person-avatar { width: 36px; height: 36px; font-size: 12px; border-color: var(--navy-100); overflow: hidden; }
.user-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 240px; background: #fff; color: var(--ink); border-radius: 18px; box-shadow: var(--shadow-pop); padding: 6px; display: none; z-index: 40; }
.sb-user.open .user-menu { display: block; animation: pop .16s var(--ease); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 12px; text-align: left; text-decoration: none; color: var(--ink); font-size: 13px; }
.menu-item:hover { background: var(--navy-50); }
.menu-item.danger { color: var(--critical); }

/* Main menu: a glass pill, the current page is the white segment */
.topnav { display: flex; min-width: 0; flex: 1; justify-content: center; }
.topnav-list { position: relative; display: inline-flex; gap: 2px; max-width: 100%; padding: 4px; border-radius: var(--radius-pill); background: var(--glass); border: 1px solid var(--glass-line); overflow-x: auto; scrollbar-width: none; }
.topnav-list::-webkit-scrollbar { display: none; }
.sb-item {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 36px; padding: 0 12px;
  border-radius: var(--radius-pill); color: var(--on-navy-muted); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.sb-item:hover { background: var(--glass); color: #fff; }
.sb-item[aria-current] { background: #fff; color: var(--navy-900); font-weight: 600; }
.sb-item[aria-current] .ico { color: var(--navy-600); }
.sb-item .ico { width: 15px; height: 15px; }
.masthead .sb-item:focus-visible { outline-offset: -2px; border-radius: var(--radius-pill); }
.sb-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); display: grid; place-items: center; background: var(--yellow-500); color: var(--navy-950); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

.view { width: 100%; margin: 0 auto; padding: 0 var(--workspace-gutter) 40px; transition: opacity .2s var(--ease); }
.view[aria-busy="true"] .page-body { opacity: .5; pointer-events: none; }

/* Photo picker */
.photo-picker { display: flex; align-items: center; gap: 16px; padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); background: var(--navy-50); transition: border-color .15s, background .15s; }
.photo-picker.drag { border-color: var(--navy-600); background: var(--navy-100); }
.photo-picker.busy { opacity: .6; pointer-events: none; }
.photo-preview { flex: none; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: #fff; color: var(--navy-300); box-shadow: 0 0 0 1px var(--line), 0 0 0 4px #fff; }
.photo-preview .ico { width: 34px; height: 34px; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-picker-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.photo-picker-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-optional { font-weight: 400; color: var(--ink-3); }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-2); }

/* ---------- Page header (inside the masthead) ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-top: 26px; }
.page-head > div:first-child { min-width: 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; min-height: 26px; max-width: 100%; padding: 2px 12px 2px 3px; border-radius: var(--radius-pill); background: var(--glass); border: 1px solid var(--glass-line); font-size: 12px; font-weight: 500; color: #fff; margin-bottom: 10px; }
.eyebrow:empty { display: none; }
.eyebrow span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eyebrow .chip-code { font-weight: 700; font-size: 11px; color: var(--navy-900); background: #fff; border-radius: var(--radius-pill); padding: 0 8px; letter-spacing: .03em; }
.page-title { font-size: clamp(30px, 3.15vw, 46px); font-weight: 400; line-height: 1.25; letter-spacing: -.025em; color: #fff; }
.page-sub { color: var(--on-navy-muted); margin-top: 4px; font-size: 14px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.page-actions:empty { display: none; }
.page-actions .btn { min-height: 44px; padding: 8px 20px; }
.page-actions > .btn:not(.btn-primary) { background: var(--glass); border-color: var(--glass-line); color: #fff; }
.page-actions > .btn:not(.btn-primary):hover { background: var(--glass-strong); }

/* ---------- Period rail (signature control) ---------- */
.period {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 7px 12px;
  background: rgba(248, 255, 253, .93);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border: 1px solid #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-1);
  transition: background .2s, box-shadow .2s;
}
.period.stuck { background: #f8fffd; box-shadow: var(--shadow-2); }
.period-controls { display: flex; align-items: center; gap: 8px; }
.fy-select { position: relative; }
.fy-select select {
  appearance: none; border: 1px solid var(--line-strong); background: #fff; border-radius: var(--radius-pill);
  padding: 7px 36px 7px 16px; font-weight: 600; color: var(--navy-900); min-height: 40px; cursor: pointer;
}
.fy-select .ico { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-3); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--grid); border-radius: var(--radius-pill); max-width: 100%; }
.seg button { border: 0; background: none; padding: 5px 15px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; color: var(--ink-2); min-height: 34px; white-space: nowrap; transition: background .16s var(--ease), color .16s var(--ease); }
.seg button:hover { color: var(--navy-900); }
.seg button[aria-pressed="true"] { background: var(--navy-900); color: #fff; }
.months { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(12, minmax(42px, 1fr)); gap: 4px; position: relative; }
.month {
  position: relative; border: 0; background: transparent; border-radius: var(--radius-pill); padding: 14px 0 9px;
  font-size: 13px; font-weight: 500; color: var(--ink-2); text-align: center; min-height: 48px;
  transition: background .15s var(--ease), color .15s;
}
.month:hover { background: var(--navy-50); color: var(--navy-900); }
.month .yr { position: absolute; top: 2px; left: 0; right: 0; font-size: 10px; color: var(--ink-3); font-weight: 500; }
.month .cov { position: absolute; left: 50%; bottom: 6px; width: 16px; height: 3px; margin-left: -8px; border-radius: 3px; background: var(--line-strong); }
.month.has-data .cov { background: var(--navy-500); }
.month[aria-pressed="true"] { background: var(--yellow-100); color: var(--navy-950); font-weight: 700; }
.month[aria-pressed="true"] .yr { color: var(--navy-800); }
.month[aria-pressed="true"] .cov { background: var(--navy-900); }
.months.annual .month { background: var(--yellow-50); border-radius: 0; color: var(--navy-900); }
.months.annual .month:first-child { border-radius: var(--radius-pill) 0 0 var(--radius-pill); }
.months.annual .month:last-child { border-radius: 0 var(--radius-pill) var(--radius-pill) 0; }
.months.annual { gap: 0; }
.months.annual .month:hover { background: var(--yellow-100); }
.period-hint { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.period-hint i { display: inline-block; width: 14px; height: 3px; border-radius: 3px; background: var(--navy-500); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 18px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong);
  background: #fff; color: var(--navy-900); font-weight: 500; font-size: 14px; line-height: 1.4; text-decoration: none; white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease);
}
.btn:hover { border-color: var(--navy-500); background: var(--navy-50); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--yellow-500); border-color: var(--yellow-500); color: var(--navy-950); font-weight: 600; box-shadow: var(--shadow-yellow); }
.btn-primary:hover { background: var(--yellow-400); border-color: var(--yellow-400); }
.btn-navy { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.btn-navy:hover { background: var(--navy-600); border-color: var(--navy-600); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--navy-50); border-color: transparent; }
.btn-danger { color: var(--critical); }
.btn-sm { min-height: 32px; padding: 3px 13px; font-size: 13px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; flex: none; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 290px; background: #fff; color: var(--ink); border-radius: 18px; box-shadow: var(--shadow-pop); padding: 6px; display: none; z-index: 40; }
.dropdown.open .dropdown-menu { display: block; animation: pop .16s var(--ease); }
.dropdown-menu .menu-item { align-items: flex-start; }
.dropdown-menu .menu-item small { display: block; color: var(--ink-3); font-size: 12px; }
.dropdown-menu .menu-item .ico { margin-top: 2px; color: var(--navy-500); }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 20px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.section-gap { margin-top: 20px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-heading { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.card-heading-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 11px; background: #e3f2ee; color: var(--navy-700); }
.card-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.card-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.card-tools { display: flex; gap: 6px; align-items: center; flex: none; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.link-arrow { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13px; color: var(--navy-600); text-decoration: none; white-space: nowrap; }
.link-arrow:hover { color: var(--navy-900); }

/* Source chip — every number says where it came from */
.source { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); min-width: 0; max-width: 100%; }
.source .ico { color: var(--good); }
.source span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* KPI tiles — the icon sits in its own square, the number is large and light */
.kpi { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.kpi-label { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; color: var(--ink-2); min-width: 0; }
.kpi-label .ico { width: 36px; height: 36px; padding: 9px; border-radius: var(--radius-sm); background: var(--navy-50); border: 1px solid var(--line); color: var(--navy-600); }
.kpi-value { font-size: 34px; font-weight: 300; color: var(--ink); letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 6px; letter-spacing: 0; }
.kpi-foot { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; padding: 1px 9px; border-radius: var(--radius-pill); }
.delta.up { color: var(--good); background: var(--good-bg); }
.delta.down { color: var(--critical); background: var(--critical-bg); }
.delta.flat { color: var(--ink-2); background: var(--navy-50); }
.kpi .spark { margin-top: 8px; }

/* Hero card — the single number a view leads with (the one dark card) */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: linear-gradient(160deg, var(--navy-800), var(--navy-900)); color: #fff; border: 0; border-radius: var(--radius); padding: 24px 26px;
  display: flex; flex-direction: column; justify-content: space-between; min-height: 220px; box-shadow: var(--shadow-pop);
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(43, 92, 196, .55) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26'%3E%3Cpath d='M13 9v8M9 13h8' stroke='%23ffffff' stroke-opacity='.08' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
.hero-label { font-size: 14px; color: var(--on-navy-muted); display: flex; align-items: center; gap: 10px; }
.hero-label .ico { width: 36px; height: 36px; padding: 8px; border-radius: var(--radius-sm); background: var(--glass); border: 1px solid var(--glass-line); color: #fff; }
.hero-value { font-size: 64px; font-weight: 300; letter-spacing: -.03em; line-height: 1.1; margin-top: 14px; font-variant-numeric: tabular-nums; }
.hero-value small { font-size: 16px; font-weight: 400; color: var(--on-navy-muted); margin-left: 8px; letter-spacing: 0; }
.hero-mark { display: inline-block; height: 6px; width: 64px; border-radius: 3px; background: var(--yellow-500); margin-top: 12px; }
.hero-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--on-navy-muted); }
.hero-foot > span { padding: 4px 12px; border-radius: var(--radius-pill); background: var(--glass); border: 1px solid var(--glass-line); }
.hero-foot b { color: #fff; font-weight: 600; }
.hero .delta.up { background: rgba(110, 231, 160, .16); color: #8ff0b7; }
.hero .delta.down { background: rgba(255, 140, 140, .16); color: #ffb3b3; }
.hero .delta.flat { background: var(--glass); color: #dbe4f7; }

/* Report tile details */
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tile-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--navy-50); border: 1px solid var(--line); color: var(--navy-600); }

/* ---------- Overview ---------- */
.page-actions > .overview-head-link:not(.btn-primary) { background: #f8fffd; border-color: #fff; color: var(--navy-950); }
.page-actions > .overview-head-link:not(.btn-primary):hover { background: #dff5ee; }
.overview-head-link .ico { color: var(--navy-600); }
.overview-board { display: grid; gap: 15px; }
.overview-metrics, .overview-row { display: grid; gap: 14px; }
.overview-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.overview-primary { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr) minmax(0, 1.12fr); }
.overview-secondary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.overview-details { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.overview-metric {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 5px 10px; align-content: start; align-items: center;
  min-width: 0; min-height: 100px; padding: 13px; border: 1px solid #f2fffa55; border-radius: 18px;
  background: linear-gradient(145deg, #163f48a6, #2a5c63b5);
  box-shadow: inset 0 1px #ffffff1c, 0 8px 22px -18px #143c44;
  color: #fff; text-decoration: none; transition: background .16s, border-color .16s;
}
.overview-metric:hover { background: #23545ee8; border-color: #f2fffa9e; }
.overview-metric:focus-visible { outline-color: #e7fff5; }
.overview-metric-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 11px; background: #e3fff426; color: #ddfff3; }
.overview-metric-label { display: block; color: #e1f6f2; font-size: 13px; font-weight: 500; line-height: 1.35; }
.overview-metric-value { display: block; margin-top: 3px; font-size: clamp(21px, 2.15vw, 33px); font-weight: 400; letter-spacing: -.035em; line-height: 1.16; font-variant-numeric: tabular-nums; }
.overview-metric-value small { font-size: 12px; color: #e1f6f2; letter-spacing: 0; }
.overview-metric-value.is-empty { font-size: 16px; line-height: 1.55; letter-spacing: 0; }
.overview-metric-foot { grid-column: 2 / -1; font-size: 12px; color: #e1f6f2; }
.overview-metric-trend { align-self: end; width: clamp(34px, 4.8vw, 72px); margin-bottom: 2px; }
.overview-metric-trend .spark { width: 100%; height: auto; --s1: #bcf7e4; --s1-soft: #8fc3c0; --line-strong: #94babc85; }

.overview-panel {
  display: flex; flex-direction: column; background: linear-gradient(145deg, #fcfefdfa, #f5faf9f2);
  border-color: #fff; padding: clamp(14px, 1.45vw, 20px);
}
.overview-panel .card-head { margin-bottom: 12px; }
.overview-panel .card-title { font-size: 16px; }
.overview-panel .card-sub { line-height: 1.45; }
.overview-panel .card-foot { margin-top: auto; padding-top: 10px; }
.overview-panel .card-tools .btn { padding-inline: 9px; background: #edf6f3; }
.overview-panel .card-tools .btn:hover { background: #dceee9; }
.overview-panel .chart-empty { min-height: 112px; margin-bottom: 11px; background: #eaf3f17d; }
.overview-panel .barlist, .overview-panel .seg-legend, .overview-panel .table-wrap, .overview-panel .chart { margin-bottom: 11px; }
.overview-panel-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 7px; margin-bottom: 8px; }
.overview-panel-total strong { font-size: 31px; font-weight: 400; line-height: 1.22; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.overview-panel-total span { color: var(--ink-3); font-size: 13px; }
.overview-visits .chart text { font-size: 14px; }
.overview-visits .chart .val-label { font-size: 14px; }
.chart-pin { pointer-events: none; }
.chart-pin line { stroke-width: 2; stroke-linecap: round; }
.chart-pin circle { stroke: #f8fdfa; stroke-width: 1.4; }
.overview-disease .card-heading-icon { background: #ede7f5; color: #73529b; }
.overview-finance .card-heading-icon { background: #f5eadc; color: #835b31; }
.overview-cost-chart .card-heading-icon { background: #e8ebf7; color: #57598e; }
.overview-coverage-scroll { position: relative; overflow-x: auto; margin-bottom: 9px; }

.overview-gauge { display: grid; place-content: center; justify-items: center; flex: 1; min-height: 111px; margin: 0 0 10px; }
.overview-gauge svg { grid-area: 1 / 1; width: min(100%, 202px); height: auto; overflow: visible; }
.overview-gauge line { stroke: #d9e9e6; stroke-width: 3.9; stroke-linecap: round; }
.overview-gauge .is-covered { stroke: var(--s1); }
.overview-gauge .is-covered:nth-child(n+15) { stroke: #226e79; }
.overview-gauge-value { grid-area: 1 / 1; align-self: end; padding-bottom: 5px; text-align: center; white-space: nowrap; }
.overview-gauge-value strong { display: block; font-size: clamp(25px, 3vw, 37px); font-weight: 400; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.overview-gauge-value span { display: block; margin-top: 3px; color: var(--ink-3); font-size: 12px; }
.overview-gauge-details, .overview-stock-metrics { display: grid; margin: 0; border-radius: 13px; }
.overview-gauge-details { grid-template-columns: repeat(3, minmax(0, 1fr)); background: #e9f3f19e; padding: 9px 4px; text-align: center; }
.overview-gauge-details div + div { border-inline-start: 1px solid #d5e5e2; }
.overview-gauge-details dt { color: var(--ink-3); font-size: 12px; }
.overview-gauge-details dd, .overview-stock-metrics dd { margin: 2px 0 0; font-size: 20px; font-weight: 500; line-height: 1.2; font-variant-numeric: tabular-nums; }

.overview-stock {
  background: radial-gradient(110% 130% at 100% 0, #686197, transparent 77%), linear-gradient(155deg, #184952, #235e60);
  border-color: #ffffff36; color: #fff;
}
.overview-stock .card-title { color: #fff; }
.overview-stock .card-sub, .overview-stock dt { color: #e0efef; }
.overview-stock .card-heading-icon { background: #e9fffc26; color: #e7fffa; }
.overview-stock-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.overview-stock-metrics > div { padding: 10px; border: 1px solid #ffffff2b; border-radius: 13px; background: #effff21a; }
.overview-stock-metrics > div + div { background: #ead5ff24; }
.overview-stock dt { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; }
.overview-stock-level, .overview-stock-cost { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 6px; margin-top: 10px; font-size: 12px; color: #e0efef; }
.overview-stock-level b, .overview-stock-cost b { color: #fff; }
.overview-stock-level progress { width: 100%; height: 5px; overflow: hidden; border: 0; border-radius: 999px; appearance: none; background: #ffffff36; color: #c7aff6; accent-color: #c7aff6; }
.overview-stock-level progress::-webkit-progress-bar { background: #ffffff36; }
.overview-stock-level progress::-webkit-progress-value { background: #c7aff6; border-radius: 999px; }
.overview-stock-level progress::-moz-progress-bar { background: #c7aff6; border-radius: 999px; }
.overview-stock .card-foot { justify-content: flex-end; padding-top: 9px; border-color: transparent; }
.overview-stock .btn { color: #174c53; border-color: #f1faf7; background: #f1faf7; }
.overview-stock .btn:hover { background: #d7f4e9; }
.overview-stock .btn:focus-visible { outline-color: #e7fff5; }
.overview-stock-empty { display: grid; flex: 1; place-items: center; margin-bottom: 6px; padding: 14px; border: 1px solid #ffffff29; border-radius: 13px; background: #effff21a; color: #e0efef; text-align: center; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--ink-3); font-size: 11px; }
.chart .axis-label { font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar { transition: opacity .15s; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .hit:focus + .bar { opacity: .82; }
.chart .x-label.sel { fill: var(--navy-950); font-weight: 700; }
.chart .x-sel-bg { fill: var(--yellow-500); }
.chart .val-label { fill: var(--ink); font-size: 11px; font-weight: 600; }
.chart .crosshair { stroke: var(--navy-300); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0; pointer-events: none; }
.chart .col-hit { fill: transparent; }
.chart .col-hit:hover ~ .crosshair { opacity: 1; }
.chart .line { fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { opacity: .08; }
.chart .dot { stroke: #fff; stroke-width: 2; }
.chart .empty-bar { fill: var(--navy-100); }
.chart-empty { display: grid; place-items: center; text-align: center; min-height: 200px; color: var(--ink-3); font-size: 13px; background: var(--navy-50); border-radius: var(--radius-md); padding: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend i.line-key { height: 3px; width: 14px; border-radius: 2px; }

.tip {
  position: fixed; z-index: 100; pointer-events: none; min-width: 140px; max-width: 280px;
  background: var(--navy-950); color: #fff; border-radius: var(--radius-md); padding: 9px 13px; font-size: 12px; line-height: 1.45;
  box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: none; }
.tip-title { color: #a9b8db; font-size: 11px; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--on-navy-muted); }
.tip-row i { width: 12px; height: 3px; border-radius: 2px; flex: none; }

/* Ranked bar list */
.barlist { display: flex; flex-direction: column; gap: 12px; }
.barlist-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.barlist-rank { font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.barlist-row:first-child .barlist-rank { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--yellow-500); color: var(--navy-950); font-size: 11px; }
.barlist-name { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barlist-val { font-size: 13px; font-weight: 600; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.barlist-val small { color: var(--ink-3); font-weight: 400; margin-left: 4px; }
.barlist-track { grid-column: 2 / 4; height: 6px; border-radius: var(--radius-pill); background: var(--grid); overflow: hidden; }
.barlist-fill { height: 100%; border-radius: var(--radius-pill); background: var(--s1); min-width: 6px; }
.barlist-sub { grid-column: 2 / 4; font-size: 12px; color: var(--ink-3); margin-top: -2px; }

/* Segmented bar: separate pills, one per part */
.segbar { display: flex; gap: 4px; height: 26px; }
.segbar > div { display: flex; align-items: center; justify-content: center; padding: 0 8px; color: #fff; font-size: 12px; font-weight: 600; min-width: 8px; white-space: nowrap; overflow: hidden; border-radius: var(--radius-pill); }
.segbar > div.ink-dark { color: var(--navy-950); }
.seg-legend { display: grid; gap: 8px; margin-top: 14px; }
.seg-legend div { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.seg-legend i { width: 8px; height: 8px; border-radius: 50%; }
.seg-legend b { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

/* Coverage matrix */
.coverage { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: 12px; }
.coverage th { font-weight: 500; color: var(--ink-3); text-align: center; padding: 0 0 4px; }
.coverage th:first-child { text-align: left; }
.coverage th.sel { color: var(--navy-900); font-weight: 700; }
.coverage td.src { padding-right: 10px; white-space: nowrap; }
.coverage td.src a { color: var(--ink); text-decoration: none; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.coverage td.src a:hover { color: var(--navy-600); }
.coverage td.src .ico { color: var(--navy-500); }
.cell { height: 26px; min-width: 14px; border-radius: 8px; background: var(--grid); }
.cell.on { background: var(--navy-500); }
.cell.sel { box-shadow: 0 0 0 2px var(--yellow-500); }
.coverage td.count { text-align: right; font-weight: 600; color: var(--ink); padding-left: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Stock flow equation (pharmacy) */
.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1.15fr; align-items: stretch; gap: 10px; }
.flow-box { border-radius: var(--radius-md); padding: 14px 16px; background: var(--navy-50); border: 1px solid var(--line); }
.flow-box span { display: block; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.flow-box b { display: block; font-size: 24px; font-weight: 300; color: var(--ink); letter-spacing: -.01em; margin-top: 4px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.flow-box small { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.flow-box.result { background: linear-gradient(160deg, var(--navy-800), var(--navy-900)); border-color: var(--navy-900); }
.flow-box.result span, .flow-box.result small { color: var(--on-navy-muted); }
.flow-box.result b { color: #fff; }
.flow-op { display: grid; place-items: center; font-size: 22px; font-weight: 300; color: var(--ink-3); }
.flow-op.eq { color: var(--yellow-600); }
.flow.pharmacy-finance-flow { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.12fr); }
.pharmacy-finance-flow .flow-op { display: grid; min-width: 13px; }
.pharmacy-finance-flow .flow-op.eq { color: var(--navy-600); }
.pharmacy-finance-flow .flow-box > span, .pharmacy-profit-label > span { font-size: 14px; }
.pharmacy-finance-flow .flow-box b { font-size: clamp(24px, 2.55vw, 36px); overflow-wrap: anywhere; }
.pharmacy-profit.good { background: linear-gradient(148deg, #147442, #0b5033); border-color: #146240; }
.pharmacy-profit.critical { background: linear-gradient(148deg, #b3353a, #7f202e); border-color: #9b2d38; }
.pharmacy-profit:is(.good, .critical) :is(span, b, small, .ico) { color: #fff; }
.pharmacy-profit-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 22px; }
.pharmacy-profit-label .ico { color: var(--navy-700); }

/* ---------- Tables ---------- */
.table-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search { position: relative; flex: 1 1 240px; max-width: 380px; }
.search .ico { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search input { width: 100%; }
.input, .search input, .select, textarea.input {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 12px; min-height: 40px; padding: 8px 13px; font-size: 14px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.search input { padding-left: 40px; border-radius: var(--radius-pill); }
.btn.disabled { opacity: .5; pointer-events: none; }
.input:hover, .search input:hover, .select:hover { border-color: var(--navy-300); }
.input:focus, .search input:focus, .select:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(43, 92, 196, .15); }
.select { appearance: none; padding-right: 34px; border-radius: var(--radius-pill); cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2366718a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.field .select { border-radius: 12px; }
.table-count { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { position: sticky; top: 0; background: var(--navy-50); color: var(--ink-2); font-weight: 600; font-size: 12px; text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th.num, table.data td.num { text-align: right; }
table.data td { padding: 11px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--yellow-50); }
table.data td.nowrap, .nowrap { white-space: nowrap; }
table.data td small { display: block; color: var(--ink-3); font-size: 12px; }
table.data td b { font-weight: 600; }
.th-sort { border: 0; background: none; padding: 0; font-weight: 600; color: inherit; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.th-sort .ico { width: 13px; height: 13px; opacity: .45; }
.th-sort[aria-sort] .ico { opacity: 1; color: var(--navy-600); }
.empty-row td { text-align: center; color: var(--ink-3); padding: 28px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.pager-btns { display: flex; gap: 6px; align-items: center; }

/* Badges / status */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--navy-50); color: var(--navy-800); }
.badge .ico { width: 13px; height: 13px; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.serious { background: var(--serious-bg); color: var(--serious); }
.badge.critical { background: var(--critical-bg); color: var(--critical); }
.badge.yellow { background: var(--yellow-100); color: #6b4b00; }
.badge.muted { background: var(--grid); color: var(--ink-2); }
.pct-up { color: var(--good); font-weight: 600; }
.pct-down { color: var(--critical); font-weight: 600; }

/* Tabs (sub-pages): a pill rail, the current tab is navy */
.tabs { display: inline-flex; gap: 2px; max-width: 100%; padding: 3px; margin: 0 0 14px; background: var(--grid); border-radius: var(--radius-pill); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; vertical-align: top; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 34px; padding: 4px 16px; border-radius: var(--radius-pill); text-decoration: none; font-size: 13px; color: var(--ink-2); font-weight: 500; white-space: nowrap; transition: background .16s var(--ease), color .16s var(--ease); }
.tabs a:hover { color: var(--navy-900); }
.tabs a:focus-visible { outline-offset: -2px; border-radius: var(--radius-pill); }
.tabs a[aria-current="page"] { background: var(--navy-900); color: #fff; }
.tabs .count { font-size: 11px; background: #fff; color: var(--navy-800); border-radius: var(--radius-pill); padding: 0 7px; font-weight: 700; }
.tabs a[aria-current="page"] .count { background: var(--yellow-500); color: var(--navy-950); }
.page-body > .tabs { display: flex; width: max-content; }

/* Notices & empty states */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-md); background: var(--yellow-50); border: 1px solid #f7e2a6; color: #5a4300; font-size: 13px; }
.notice .ico { color: var(--yellow-600); margin-top: 2px; }
.notice.info { background: var(--navy-50); border-color: var(--navy-100); color: var(--ink-2); }
.notice.info .ico { color: var(--navy-500); }
.notice b { color: var(--ink); }
.empty { text-align: center; padding: 40px 20px; }
.empty-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--yellow-100); color: var(--navy-900); }
.empty h3 { font-size: 18px; font-weight: 500; color: var(--ink); }
.empty p { color: var(--ink-3); margin: 6px auto 16px; max-width: 460px; font-size: 13px; }

/* Source cards (receivable funds etc.) */
.src-card { display: flex; flex-direction: column; gap: 10px; }
.src-card .tile-top b { font-size: 15px; font-weight: 600; color: var(--ink); }
.src-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.src-card dt { color: var(--ink-3); }
.src-card dd { margin: 0; text-align: right; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field.full { grid-column: 1 / -1; }
.field small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--navy-900); }
.form-error { color: var(--critical); font-size: 13px; min-height: 1em; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Modal */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius); width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-pop); color: var(--ink); }
dialog.modal.wide { width: min(980px, calc(100vw - 32px)); }
dialog.modal.narrow { width: min(460px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(6, 18, 43, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: pop .2s var(--ease); display: flex; flex-direction: column; }
.modal-form { display: flex; flex-direction: column; min-height: 0; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 0; }
.modal-head h2 { font-size: 20px; font-weight: 500; color: var(--ink); }
.modal-head p { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 22px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.modal-foot .form-error { margin-right: auto; }

/* Import */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius-md); padding: 28px; text-align: center; background: var(--navy-50); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--navy-500); background: #eef3fd; }
.dropzone .empty-icon { background: #fff; }
.dropzone b { color: var(--navy-900); }
.dropzone p { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.file-row .ico { color: var(--good); }
.file-row b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.file-row small { color: var(--ink-3); font-size: 12px; }
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-strip div { background: var(--navy-50); border-radius: var(--radius-md); padding: 10px 14px; }
.summary-strip span { display: block; font-size: 12px; color: var(--ink-3); }
.summary-strip b { font-size: 20px; color: var(--ink); font-weight: 400; font-variant-numeric: tabular-nums; }

/* Toasts */
.toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--navy-950); color: #fff; padding: 12px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-pop); font-size: 13px; max-width: 380px; animation: pop .2s var(--ease); }
.toast .ico { color: var(--yellow-500); margin-top: 1px; }
.toast.error .ico { color: #ff9b9b; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 260px; color: var(--ink-3); font-size: 13px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--navy-100); border-top-color: var(--navy-600); animation: spin .7s linear infinite; }
.error-card { border-color: #f3c7c7; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: 1fr 1fr; }
  .flow-op { display: none; }
  .overview-metric { grid-template-columns: auto minmax(0, 1fr); }
  .overview-metric-trend { grid-column: 1; grid-row: 2; width: 38px; }
}
@media (min-width: 961px) and (max-width: 1560px) {
  .sb-item:not([aria-current]) > .ico { display: none; }
}
@media (min-width: 961px) and (max-width: 1440px) {
  .sb-item { font-size: 13px; padding-inline: 9px; }
}
@media (min-width: 961px) and (max-width: 1320px) {
  .topbar { flex-wrap: wrap; }
  .topnav { flex-basis: 100%; order: 1; justify-content: flex-start; }
}
@media (max-width: 1100px) {
  .months { grid-template-columns: repeat(12, minmax(40px, 1fr)); overflow-x: auto; flex-basis: 100%; }
  .g-main, .g-3 { grid-template-columns: 1fr; }
  .overview-primary, .overview-secondary, .overview-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-visits { grid-column: 1 / -1; }
  .overview-visits .chart svg { max-width: 700px; }
  .overview-finance { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .shell { width: calc(100% - 18px); margin: 9px auto; min-height: calc(100vh - 18px); border-width: 3px; border-radius: 25px; }
  .masthead { padding-block: 13px 15px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .btn.nav-toggle { display: inline-flex; background: var(--glass); border-color: var(--glass-line); color: #fff; }
  .nav-toggle:hover { background: var(--glass-strong); border-color: var(--glass-line); }
  .brand { flex: 1; }
  .brand-word small { display: none; }
  .topnav { display: none; order: 1; flex-basis: 100%; }
  .shell.nav-open .topnav { display: flex; animation: pop .16s var(--ease); }
  .topnav-list { flex: 1; flex-direction: column; border-radius: var(--radius); margin: 0; }
  .sb-item { height: 42px; padding: 0 16px; }
  .sb-count { margin-left: auto; }
}
@media (max-width: 720px) {
  .g-4, .g-2, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .shell { --workspace-gutter: 12px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-top: 17px; }
  .page-actions { justify-content: flex-start; }
  .page-actions .dropdown-menu { left: 0; right: auto; min-width: min(290px, 80vw); }
  .page-title { font-size: 30px; }
  .kpi-value { font-size: 30px; }
  .hero-value { font-size: 48px; }
  .flow { grid-template-columns: 1fr; }
  .flow.pharmacy-finance-flow { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .period-hint { display: none; }
  .overview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .overview-metric { padding: 10px; min-height: 93px; }
  .overview-row { grid-template-columns: 1fr; }
  .overview-board, .overview-row { gap: 11px; }
  .overview-panel { border-radius: 18px; }
}
@media (max-width: 520px) {
  .ws-switch { order: 1; flex-basis: 100%; margin-left: 0; }
  .ws-button { max-width: none; }
  .ws-menu { left: 0; right: auto; }
  .topnav { order: 2; }
  .overview-metric { grid-template-columns: minmax(0, 1fr); }
  .overview-metric-icon { width: 28px; height: 28px; }
  .overview-metric-icon .ico { width: 15px; height: 15px; }
  .overview-metric-trend { display: none; }
  .overview-metric-foot { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  body, .shell { background: #fff; }
  .shell { width: 100%; min-height: 0; margin: 0; border: 0; box-shadow: none; }
  .topbar, .topnav, .period, .page-actions, .card-tools, .table-tools, .pager { display: none !important; }
  .masthead { margin: 0; padding: 0 0 12px; background: none; color: var(--ink); }
  .page-title { color: var(--navy-900); }
  .page-sub { color: var(--ink-2); }
  .eyebrow { color: var(--ink); border-color: var(--line); }
  .view { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
  .overview-metric, .overview-stock, .overview-stock .card-title, .overview-stock .card-sub, .overview-stock dt, .overview-stock b, .overview-metric-label, .overview-metric-value small, .overview-metric-foot { color: var(--ink); }
  .overview-metric, .overview-stock, .overview-stock-metrics > div { background: #fff; border-color: var(--line); box-shadow: none; }
}

.settlement-upload,
.settlement-upload form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.settlement-upload { justify-content: space-between; }
.settlement-upload .field { max-width: 100%; }
.settlement-upload select { max-width: min(100%, 340px); }
.settlement-filters { align-items: end; }
.settlement-filters > label:last-child { display: flex; align-items: center; gap: 6px; min-height: 38px; }
.settlement-alert .notice,
[data-settlement-error] { background: #fff5df; border-color: #edce97; color: #713b0b; }
table.data.settlement-table { min-width: 850px; }
table.data .settlement-difference td,
table.data .settlement-difference:hover td { background: #fff8e8; }
table.data .settlement-difference td:nth-child(-n+2) { background: #ffedbc; color: #713b0b; font-weight: 600; }
