/* The Functional MDs brand (functional-mds-brand-board.pdf, DECISIONS D-40): Evergreen leads; Soft White and Oat
   surfaces; Forest Ink text; Bricolage Grotesque for headlines, Figtree for UI. No red, orange or pure black:
   "expired / needs action" uses Amethyst, "due soon" Amber, "due later" Champagne, "held" Sky. */

@font-face {
  font-family: 'Figtree';
  src: url('/dashboard/figtree.woff2?v=4ba7d3d09669') format('woff2');
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/dashboard/bricolage.woff2?v=a79fdb52d4a5') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

:root {
  /* brand */
  --evergreen: #0e6b4f;
  --deep: #0e4a38;
  --mint: #57c18a;
  --teal: #178c7e;
  --sky: #6fa3e2;
  --aqua: #97dbcb;
  --champagne: #c4a368;
  --amber: #e8b24c;
  --amethyst: #6e5b8e;
  --orchid: #a48fc4;
  --soft-white: #fcfbf7;
  --oat: #eae3d4;
  --ink: #14241d;

  /* roles */
  --bg: #f1ece2;
  --panel: var(--soft-white);
  --panel-2: #f5f1e8;
  --text: var(--ink);
  --muted: #5f6b64;
  --line: #e6dfd0;
  --brand: var(--evergreen);
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ea;

  /* status (kept as red/amber/yellow/blue class names in the script) */
  --red: var(--amethyst);
  --red-soft: #ece8f3;
  --amber-ink: #9a6d12;
  --amber-soft: #fbf0d8;
  --yellow: #8a6a2c;
  --yellow-soft: #f3ecdd;
  --blue: #3c6fae;
  --blue-soft: #e5eefa;
  --grey: #b9b2a3;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 36, 29, 0.04), 0 8px 24px rgba(20, 36, 29, 0.05);
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 34px; }
h2 { font-size: 17px; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---- layout: floating sidebar + top bar + content */
.shell { display: grid; grid-template-columns: 248px 1fr; gap: 16px; min-height: 100vh; padding: 16px; }
.side {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 14px 14px;
  position: sticky; top: 16px; height: calc(100vh - 32px);
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--ink); }
.logo img { width: 34px; height: 34px; border-radius: 10px; }
.nav-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.nav { display: grid; gap: 2px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { color: var(--ink); font-weight: 650; }
.nav a.on::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); }
.nav a.on svg { color: var(--brand); }
.nav a .label { flex: 1; }
.nav .count { font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--deep); color: #fff; font-weight: 650; }
.promo {
  margin-top: auto; border-radius: 16px; padding: 16px; color: #fff;
  background: radial-gradient(120% 90% at 100% 0%, #1d8a66 0%, transparent 60%), linear-gradient(160deg, var(--evergreen), var(--deep));
}
.promo h3 { font-size: 17px; margin-bottom: 4px; }
.promo p { margin: 0 0 12px; font-size: 12px; opacity: 0.85; }
.promo .btn { width: 100%; justify-content: center; background: rgba(255, 255, 255, 0.14); border-color: transparent; color: #fff; }
.promo .btn:hover { background: rgba(255, 255, 255, 0.24); }
.side .foot { display: grid; gap: 2px; margin-top: 12px; }
.side .foot button { all: unset; display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; color: var(--muted); cursor: pointer; font-weight: 500; }
.side .foot button:hover { background: var(--panel-2); color: var(--text); }

.content { display: grid; grid-template-rows: auto 1fr; gap: 16px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px 10px 16px; }
.search { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 99px; padding: 0 14px; height: 42px; width: min(380px, 100%); color: var(--muted); }
.search input { border: 0 !important; background: transparent !important; height: 40px; padding: 0 !important; flex: 1; outline: none; }
.search kbd { font: 11px 'Figtree', sans-serif; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.iconbtn { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--panel-2); color: var(--ink); border: 0; cursor: pointer; text-decoration: none; }
.iconbtn:hover { background: var(--oat); }
.iconbtn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); border: 2px solid var(--panel-2); }
.userchip { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--teal); font-size: 15px; flex: none; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.userchip .who { line-height: 1.25; }
.userchip .who b { display: block; font-weight: 650; }
.main { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 26px 40px; min-width: 0; }
.pagehead { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.pagehead .grow { flex: 1; min-width: 220px; }
.pagehead p { margin: 6px 0 0; color: var(--muted); }
.top { display: none; } /* old header, replaced by .pagehead */

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .side, .topbar, .main { min-width: 0; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .search { width: auto; flex: 1; min-width: 0; }
  .topbar > .grow { display: none; }
  .pagehead { gap: 10px; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; }
  .logo { padding: 0 8px 0 0; }
  .logo span, .nav-label, .promo, .side .foot span { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .nav a.on::before { display: none; }
  .nav a.on { background: var(--brand-soft); }
  .side .foot { display: flex; margin: 0 0 0 auto; }
  .main { padding: 18px 16px 32px; }
  .userchip .who, .search kbd { display: none; }
  h1 { font-size: 26px; }
}

/* ---- cards and grids */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.dash { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1200px) { .dash > * { grid-column: span 6; } .dash > .span-12, .dash > .span-8, .dash > .span-7 { grid-column: span 12; } }
@media (max-width: 720px) { .dash > * { grid-column: span 12 !important; } .two { grid-template-columns: 1fr; } }
.page { display: grid; gap: 16px; }
.page > * { min-width: 0; }
.page > p { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.card > header { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; flex-wrap: wrap; }
.card > header .grow { flex: 1; }
.card > header h2 { font-family: var(--display); white-space: nowrap; }
.card > .body { padding: 12px 20px 20px; }
.card > .body.flush { padding: 8px 0 4px; }
.card > .body.flush > .body { padding: 10px 16px 8px; }
.card.oat { background: var(--panel-2); }

/* KPI tiles: big number, round arrow, first one filled Evergreen */
.kpi { position: relative; padding: 18px 20px 18px; display: block; color: inherit; text-decoration: none; }
.kpi .label { font-size: 15px; font-weight: 600; padding-right: 44px; }
.kpi .value { font-family: var(--display); font-size: 44px; font-weight: 600; letter-spacing: -0.02em; margin-top: 10px; line-height: 1.05; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.kpi .sub::before { content: ''; width: 8px; height: 8px; border-radius: 3px; background: var(--line); flex: none; }
.kpi .arrow { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; }
.kpi .arrow svg { width: 15px; height: 15px; }
a.kpi:hover { border-color: var(--brand); }
.kpi.hero { background: radial-gradient(110% 120% at 100% 0%, #1e8a68 0%, transparent 55%), linear-gradient(150deg, var(--evergreen), var(--deep)); border-color: transparent; color: #fff; }
.kpi.hero .sub { color: rgba(255, 255, 255, 0.8); }
.kpi.hero .sub::before { background: var(--mint); }
.kpi.hero .arrow { background: #fff; border-color: #fff; color: var(--ink); }
.kpi.red .value { color: var(--amethyst); } .kpi.red .sub::before { background: var(--amethyst); }
.kpi.amber .sub::before { background: var(--amber); }
.kpi.yellow .sub::before { background: var(--champagne); }
.kpi.brand .sub::before { background: var(--mint); }
.kpi.blue .sub::before { background: var(--sky); }

/* dark highlight card (the "time tracker" slot) */
.feature {
  border-radius: var(--radius); padding: 20px; color: #fff; display: flex; flex-direction: column; gap: 10px; min-height: 100%;
  background:
    repeating-radial-gradient(circle at 120% 120%, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 14px),
    linear-gradient(155deg, var(--deep), #0a3328);
}
.feature h2 { color: #fff; }
.feature .big { font-family: var(--display); font-size: 46px; font-weight: 600; letter-spacing: -0.01em; }
.feature p { margin: 0; opacity: 0.8; font-size: 13px; }
.feature .btn { align-self: flex-start; background: #fff; color: var(--ink); border-color: #fff; }

.today-big { font-family: var(--display); font-size: 26px; font-weight: 600; color: var(--evergreen); line-height: 1.15; }
.card.span-4 > .body.grid, .card.span-3 > .body.grid { gap: 10px; align-content: start; }
.card.span-4 > .body .btn.primary { justify-self: start; margin-top: 6px; }

/* lists inside cards */
.list { display: grid; gap: 4px; padding: 4px 12px 8px; }
.lrow { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; text-decoration: none; color: inherit; cursor: pointer; }
.lrow:hover { background: var(--panel-2); }
.lrow .main-t { flex: 1; min-width: 0; }
.lrow .main-t div:first-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .sub { font-size: 12px; color: var(--muted); }
.dotico { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex: none; color: #fff; }

/* ---- tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: transparent; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
td .sub { font-size: 12px; color: var(--muted); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.more { padding: 10px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---- status pills */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.expired, .badge.red { background: var(--red-soft); color: var(--amethyst); border-color: transparent; }
.badge.due30, .badge.amber { background: var(--amber-soft); color: var(--amber-ink); border-color: transparent; }
.badge.due90, .badge.yellow { background: var(--yellow-soft); color: var(--yellow); border-color: transparent; }
.badge.ok, .badge.active, .badge.green { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.badge.quarantined, .badge.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }

/* ---- buttons and forms (pill shaped) */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 20px;
  border-radius: 99px; border: 1.5px solid var(--evergreen); background: transparent; color: var(--evergreen);
  cursor: pointer; white-space: nowrap; font-weight: 600; text-decoration: none;
}
.btn:hover { background: var(--brand-soft); }
.btn.primary { background: var(--evergreen); border-color: var(--evergreen); color: #fff; }
.btn.primary:hover { background: var(--deep); border-color: var(--deep); }
.btn.danger { color: var(--amethyst); border-color: var(--amethyst); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { height: 32px; padding: 0 14px; font-size: 12px; border-width: 1px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"], input[type="email"], select, textarea {
  height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; min-width: 0;
}
textarea { height: auto; min-height: 90px; padding: 10px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .iconbtn:focus-visible { outline: 2px solid var(--evergreen); outline-offset: 1px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--evergreen); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type="search"] { width: 280px; max-width: 100%; }
.toolbar input[type="number"] { width: 110px; }
.form { display: grid; gap: 14px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .form .row { grid-template-columns: 1fr; } }

/* ---- messages */
.msg { padding: 12px 16px; border-radius: 14px; }
.msg a { color: inherit; font-weight: 650; }
.msg.error { background: var(--red-soft); color: var(--amethyst); }
.msg.warn { background: var(--amber-soft); color: var(--amber-ink); }
.msg.info { background: var(--brand-soft); color: var(--deep); }
.msg.ok { background: var(--brand-soft); color: var(--evergreen); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; box-shadow: 0 10px 30px rgba(20, 36, 29, 0.18); max-width: calc(100vw - 32px); }
.loading { padding: 48px; text-align: center; color: var(--muted); }

/* ---- sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(80% 60% at 0% 0%, #dfe9de 0%, transparent 60%), var(--bg); }
.login .card { width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login .card > .body { padding: 28px; display: grid; gap: 14px; }
.login .logo { padding: 0 0 4px; font-size: 20px; }
.login .btn.primary { justify-content: center; }

/* ---- drawer and dialogs */
.overlay { position: fixed; inset: 0; background: rgba(20, 36, 29, 0.38); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(540px, 100vw); height: 100%; background: var(--bg); overflow-y: auto; display: flex; flex-direction: column; }
.drawer > header { display: flex; align-items: flex-start; gap: 8px; padding: 20px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
.drawer > header .grow { flex: 1; }
.drawer > .body { padding: 0 20px 20px; display: grid; gap: 16px; align-content: start; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
.dialog { width: min(440px, 100%); background: var(--panel); border-radius: var(--radius); max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog.wide { width: min(580px, 100%); }
.dialog > header { padding: 20px 22px 6px; }
.dialog > .body { padding: 14px 22px; }
.dialog > footer { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.photo { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.picker { display: grid; gap: 6px; margin-top: 6px; max-height: 230px; overflow-y: auto; }
.pick { text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.pick:hover { border-color: var(--evergreen); }

/* ---- charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 12px; font-family: 'Figtree', sans-serif; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 5; }
.chart .tip rect { fill: #fff; stroke: var(--line); }
.chart .tip text { fill: var(--ink); font-size: 11px; font-weight: 600; }
.chart rect.bar:hover, .chart path:hover { opacity: 0.85; }
.s-brand { fill: var(--evergreen); }
.s-deep { fill: var(--deep); }
.s-mint { fill: var(--mint); }
.s-red { fill: var(--amethyst); }
.s-amber { fill: var(--amber); }
.s-yellow { fill: var(--champagne); }
.s-blue { fill: var(--sky); }
.s-grey { fill: var(--grey); }
.s-hatch { fill: url(#hatch); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend i.s-brand { background: var(--evergreen); }
.legend i.s-deep { background: var(--deep); }
.legend i.s-mint { background: var(--mint); }
.legend i.s-red { background: var(--amethyst); }
.legend i.s-amber { background: var(--amber); }
.legend i.s-yellow { background: var(--champagne); }
.legend i.s-blue { background: var(--sky); }
.legend i.s-grey { background: var(--grey); }
.legend i.s-hatch { background: repeating-linear-gradient(135deg, var(--grey) 0 2px, transparent 2px 5px); border: 1px solid var(--grey); }
.gauge { display: grid; justify-items: center; }
.gauge .pct { font-family: var(--display); font-size: 44px; font-weight: 600; margin-top: -78px; letter-spacing: -0.02em; }
.gauge .cap { font-size: 12px; color: var(--evergreen); font-weight: 600; margin-bottom: 18px; }
.meter { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; min-width: 60px; }
.meter > i { display: block; height: 100%; background: var(--evergreen); border-radius: 99px; }
