/* ============================================================
   Overturn Health — clinic dashboard
   ============================================================ */

body.dash {
  background: #f2efe7;
}
body.dash::before { opacity: 0.22; }

.dash-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ---------- sidebar ---------- */
.side {
  background: var(--pine-deep);
  color: #d6e2da;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .wordmark { color: #fff; margin-bottom: 22px; font-size: 17px; }
.side .wordmark .mark { border-color: #8fb8a4; color: #8fb8a4; }
.side a.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #b9c9bf;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 8px;
}
.side a.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.side a.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; font-weight: 600; }
.side .nav-sect {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6d8a7b;
  margin: 18px 12px 6px;
}
.side .side-foot {
  margin-top: auto;
  font-size: 12px;
  color: #6d8a7b;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.side .side-foot strong { color: #b9c9bf; display: block; font-size: 12.5px; }

/* ---------- main ---------- */
.main { padding: 26px 34px 60px; min-width: 0; }
.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.dash-head h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.dash-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.dash-head .actions { display: flex; gap: 10px; }

/* ---------- KPI tiles ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 18px 20px;
}
.kpi .k-lbl {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi .k-val {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 36px;
  line-height: 1.1;
  margin-top: 8px;
  color: var(--ink);
}
.kpi .k-delta { font-size: 12.5px; margin-top: 6px; color: var(--ink-2); }
.kpi .k-delta .up { color: var(--delta-good-text); font-weight: 700; }

/* ---------- panels ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
  align-items: stretch;
}
.panel {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 20px 22px;
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2 { font-size: 15.5px; font-weight: 700; }
.panel-head .ph-note { font-size: 12px; color: var(--muted); }

/* chart */
.chart-legend { display: flex; gap: 18px; margin-bottom: 10px; }
.chart-legend .lg { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); }
.chart-legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.viz-tip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 7px;
  padding: 8px 11px;
  opacity: 0;
  transition: opacity 0.12s ease;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
  z-index: 20;
}
.viz-tip .t-h { font-weight: 700; }
.viz-tip .t-row { display: flex; align-items: center; gap: 6px; }
.viz-tip .sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* deadlines */
.dl-list { list-style: none; display: flex; flex-direction: column; }
.dl {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 11px 2px;
  border-bottom: 1px dashed var(--hairline-soft);
}
.dl:last-child { border-bottom: none; }
.dl .d-days {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  flex-direction: column;
}
.dl .d-days small { font-size: 9px; font-weight: 700; letter-spacing: 0.05em; }
.d-critical { background: #fbe4e4; color: var(--status-critical); }
.d-warning  { background: #fdf2d7; color: #8a6210; }
.d-ok       { background: var(--pine-wash); color: var(--pine-deep); }
.dl .d-what { font-size: 13.5px; font-weight: 600; }
.dl .d-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.dl .d-kind {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--hairline-soft);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- appeals table ---------- */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.chip {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.chip:hover { background: var(--paper-2); }
.chip.on { background: var(--pine); border-color: var(--pine); color: #fff; }
.chip .ct { opacity: 0.65; font-weight: 500; margin-left: 4px; }

.tbl-wrap { overflow-x: auto; }
table.appeals {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.appeals th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.appeals td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: middle;
  white-space: nowrap;
}
.appeals tbody tr { cursor: pointer; }
.appeals tbody tr:hover { background: var(--paper-2); }
.appeals .pt { font-weight: 600; }
.appeals .cpt { color: var(--ink-2); }
.appeals .cpt b { color: var(--ink); font-weight: 700; }
.appeals .amt { font-variant-numeric: tabular-nums; text-align: right; }
.appeals th.amt { text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-intake     { background: #ecebe6; color: #5c5a52; }
.b-drafting   { background: #e2ecf8; color: #1c5cab; }
.b-signature  { background: #fdf2d7; color: #8a6210; }
.b-submitted  { background: #e8e4f5; color: #4a3aa7; }
.b-p2p        { background: var(--clay-wash); color: var(--clay); }
.b-overturned { background: var(--pine-wash); color: var(--pine-deep); }
.b-upheld     { background: #fbe4e4; color: var(--status-critical); }

/* ---------- detail drawer ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 25, 20, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 90;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 94vw);
  background: var(--card);
  border-left: 1px solid var(--hairline);
  box-shadow: -24px 0 60px -30px rgba(16, 25, 20, 0.5);
  transform: translateX(102%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 100;
  overflow-y: auto;
  padding: 28px 30px 40px;
}
.drawer.open { transform: translateX(0); }
.drawer .dr-close {
  position: absolute;
  top: 18px; right: 18px;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
}
.drawer .dr-close:hover { color: var(--ink); }
.drawer h2 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  margin: 6px 0 2px;
}
.drawer .dr-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.dr-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  background: var(--paper);
  border: 1px solid var(--hairline-soft);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 22px;
  font-size: 13.5px;
}
.dr-meta .m-lbl { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.dr-meta .m-val { font-weight: 600; margin-top: 2px; }
.drawer h3 {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 22px 0 10px;
}
.dr-matrix { border: 1px solid var(--hairline); border-radius: 10px; overflow: hidden; font-size: 13px; }
.dr-matrix .mc-row { grid-template-columns: 1.1fr 1.3fr auto; }
.dr-timeline { list-style: none; border-left: 2px solid var(--pine-wash); margin-left: 6px; padding-left: 18px; display: flex; flex-direction: column; gap: 12px; }
.dr-timeline li { position: relative; font-size: 13.5px; color: var(--ink-2); }
.dr-timeline li::before {
  content: "";
  position: absolute;
  left: -24.5px; top: 5px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--pine);
}
.dr-timeline li.pending::before { background: var(--baseline); }
.dr-timeline .tl-d { font-weight: 700; color: var(--ink); margin-right: 6px; }
.dr-actions { display: flex; gap: 10px; margin-top: 26px; }

/* demo toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: var(--pine-deep);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 12px 32px -12px rgba(16, 25, 20, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
  max-width: min(92vw, 480px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* responsive */
@media (max-width: 1060px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .dash-shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .nav-sect, .side .side-foot { display: none; }
}
