/* FNG Doctor & Department Performance — no build step required */
:root {
  --plane: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: #e8f1fc;

  /* categorical series (fixed order) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;

  /* status */
  --good: #0ca30c; --good-ink: #006300; --good-wash: #e2f3e2;
  --warn: #fab219; --warn-ink: #7a5200; --warn-wash: #fdf1d4;
  --bad: #d03b3b;  --bad-ink: #a32121;  --bad-wash: #fbe4e3;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--plane); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
small, .muted { color: var(--muted); }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 236px; flex: 0 0 236px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 100px; border-radius: 9px;
 color: #fff; font-weight: 800; font-size: 13px; letter-spacing: 0.04em;
}
.brand-text { font-size: 12px; line-height: 1.25; font-weight: 600; color: var(--ink-2); }
.nav { padding: 6px 10px; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.ico { width: 18px; text-align: center; font-size: 14px; opacity: 0.85; }
.side-foot { border-top: 1px solid var(--border); padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; }
.who { font-weight: 600; font-size: 13px; display: flex; flex-direction: column; }
.who small { font-weight: 400; text-transform: capitalize; }
.link-btn { background: none; border: 0; color: var(--accent-ink); cursor: pointer; font: inherit; padding: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: flex-end; gap: 16px; padding: 20px 28px 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--plane) 92%, transparent);
  backdrop-filter: blur(6px); border-bottom: 1px solid transparent;
}
.top > div:first-of-type { flex: 1; min-width: 200px; }
.crumb { font-size: 12px; color: var(--muted); min-height: 16px; }
.menu-btn { display: none; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
#app { padding: 8px 28px 48px; }
.loading { color: var(--muted); padding: 40px 0; }

/* ---------- filter controls ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
select, input[type=text], input[type=number], input[type=email], input[type=password], input[type=month], textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis);
  border-radius: 8px; padding: 6px 10px; min-height: 34px;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; font: inherit; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--axis); }
.seg button.on { background: var(--ink); color: #fff; }

.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; min-height: 34px; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--bad-ink); }
.btn.small { padding: 4px 10px; min-height: 28px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- layout ---------- */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.section-title { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; justify-content: space-between; flex-wrap: wrap; }

/* ---------- KPI tiles ---------- */
.kpi .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 6px; }
.kpi .rows { display: grid; gap: 4px; font-size: 12.5px; }
.kpi .rows div { display: flex; justify-content: space-between; gap: 8px; }
.kpi .rows span:first-child { color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: 8px 0 2px; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }

/* deltas & status chips (never color alone: arrow/icon + text) */
.delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--bad-ink); }
.delta.flat { color: var(--ink-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.good { background: var(--good-wash); color: var(--good-ink); }
.chip.warn { background: var(--warn-wash); color: var(--warn-ink); }
.chip.bad { background: var(--bad-wash); color: var(--bad-ink); }
.chip.none { background: var(--surface-2); color: var(--ink-2); }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); margin-left: 6px; vertical-align: 1px; }
.tag.resigned { background: var(--bad-wash); color: var(--bad-ink); }
.tag.manual { background: var(--accent-wash); color: var(--accent-ink); }

/* ---------- charts ---------- */
.chart-box { position: relative; height: 290px; }
.chart-box.short { height: 220px; }
.chart-box.tall { height: 360px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--ink-2) 0 4px, transparent 4px 7px) !important; height: 2px; }
.legend i.sq { width: 10px; height: 10px; border-radius: 2px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); max-height: 72vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: middle; }
thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-size: 11.5px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--axis); }
tbody tr:hover td { background: #f7f7f4; }
tbody tr:hover td.heat { filter: brightness(0.98); }
th.sticky, td.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 220px; }
thead th.sticky { z-index: 3; }
tr.group td { background: var(--surface-2); font-weight: 650; position: sticky; }
tr.total td { font-weight: 700; border-top: 1px solid var(--axis); }
td .sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.sortable th[data-sort] { cursor: pointer; }
.sortable th[data-sort]:hover { color: var(--ink); }
th .arrow { font-size: 9px; margin-left: 3px; }

td.heat { text-align: right; font-variant-numeric: tabular-nums; min-width: 66px; line-height: 1.15; }
td.heat b { font-weight: 600; display: block; }
td.heat small { font-size: 10.5px; display: block; }
td.heat.good { background: var(--good-wash); }
td.heat.good small { color: var(--good-ink); }
td.heat.warn { background: var(--warn-wash); }
td.heat.warn small { color: var(--warn-ink); }
td.heat.bad { background: var(--bad-wash); }
td.heat.bad small { color: var(--bad-ink); }
td.heat.empty { color: var(--axis); }

.key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); align-items: center; }
.key .sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: -3px; margin-right: 5px; border: 1px solid var(--border); }

/* bar list (horizontal) */
.bars { display: grid; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 46%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; position: relative; }
.bar-fill { display: block; height: 10px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }
.bar-target { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--ink); border-radius: 1px; }

/* ---------- forms / admin ---------- */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
td input[type=number], td input[type=text] { width: 92px; min-height: 30px; padding: 4px 8px; text-align: right; }
td input.wide { width: 100%; text-align: left; }
td input.changed { border-color: var(--accent); background: var(--accent-wash); }
td input.jump { border-color: var(--warn); background: var(--warn-wash); }
.savebar {
  position: sticky; bottom: 0; z-index: 4; margin-top: 12px; padding: 12px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(0,0,0,0.05);
}
.drop {
  border: 2px dashed var(--axis); border-radius: var(--radius); padding: 36px 20px; text-align: center; background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-wash); }
.drop strong { display: block; font-size: 15px; margin-bottom: 4px; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 10px 0; }
.alert.good { background: var(--good-wash); color: var(--good-ink); }
.alert.warn { background: var(--warn-wash); color: var(--warn-ink); }
.alert.bad { background: var(--bad-wash); color: var(--bad-ink); }
.alert.info { background: var(--accent-wash); color: var(--accent-ink); }
ul.tight { margin: 6px 0; padding-left: 18px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12.5px; }
.pill button { border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 14px; line-height: 1; padding: 0 4px; }
.pill i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-width: 520px; width: calc(100% - 32px); box-shadow: 0 12px 40px rgba(0,0,0,.18); }
dialog::backdrop { background: rgba(11,11,11,.35); }
dialog h2 { margin-bottom: 12px; }
dialog .form-row > label { flex: 1 1 200px; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* tooltip + toast */
.tip {
  position: fixed; pointer-events: none; z-index: 50; background: var(--ink); color: #fff; font-size: 12px; padding: 7px 10px;
  border-radius: 6px; opacity: 0; transition: opacity .1s; max-width: 280px; line-height: 1.4;
}
.tip.show { opacity: 1; }
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  transform: translateY(20px); opacity: 0; transition: all .2s; font-weight: 500; max-width: 420px;
}
.toast.show { transform: none; opacity: 1; }
.toast.bad { background: var(--bad); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty-state h2 { margin-bottom: 6px; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 26px; display: grid; gap: 14px; }
.login-card .brand { padding: 0 0 6px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g21 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .side { position: fixed; left: -260px; z-index: 30; transition: left .2s; box-shadow: 0 0 30px rgba(0,0,0,.15); }
  .side.open { left: 0; }
  .menu-btn { display: inline-block; align-self: center; }
  .top { padding: 14px 16px 10px; }
  #app { padding: 8px 16px 40px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  th.sticky, td.sticky { min-width: 160px; }
}
@media print {
  .side, .filters, .menu-btn, .savebar { display: none !important; }
  .top { position: static; }
  .card, .table-wrap { break-inside: avoid; }
  .table-wrap { max-height: none; overflow: visible; }
}
.bars.wide .bar-row { grid-template-columns: minmax(140px, 230px) 1fr auto; }
