/* ===== Policy Review Dashboard — MUI-inspired styles ===== */

:root {
  /* MUI-like palette */
  --primary: #1976d2;
  --primary-dark: #115293;
  --primary-light: #42a5f5;
  --primary-bg: #e3f2fd;

  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --success-light: #66bb6a;

  --warning: #ed6c02;
  --warning-bg: #fff4e5;

  --error: #d32f2f;
  --error-bg: #fdecea;

  --info: #0288d1;
  --info-bg: #e1f5fe;

  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.6);
  --text-disabled: rgba(0, 0, 0, 0.38);

  --divider: rgba(0, 0, 0, 0.12);
  --divider-light: rgba(0, 0, 0, 0.06);

  --bg-default: #f4f6f8;
  --bg-paper: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-selected: rgba(25, 118, 210, 0.08);

  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-2: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-4: 0 4px 6px rgba(0,0,0,0.07), 0 10px 30px rgba(0,0,0,0.10);
  --shadow-8: 0 8px 16px rgba(0,0,0,0.10), 0 20px 50px rgba(0,0,0,0.14);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-default);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ===== Top app bar ===== */
.appbar {
  height: 56px;
  background: var(--bg-paper);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 200;
}
.appbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.appbar .brand .logo {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 13px;
}
.appbar .crumbs {
  color: var(--text-secondary);
  font-size: 13px;
  display: flex; gap: 8px; align-items: center;
}
.appbar .crumbs .sep { color: var(--text-disabled); }
.appbar .right {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
}
.appbar .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

/* ===== Tab strip (page-level) ===== */
.tabstrip {
  background: var(--bg-paper);
  border-bottom: 1px solid var(--divider);
  display: flex;
  padding: 0 24px;
  gap: 4px;
  position: sticky;
  top: 56px;
  z-index: 199;
  overflow-x: auto;
}
.tabstrip .tab {
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tabstrip .tab:hover { color: var(--text-primary); }
.tabstrip .tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== Content shell ===== */
.page { padding: 24px; }
.page-narrative {
  max-width: 880px;
  margin: 0 auto 24px;
  color: var(--text-secondary);
  font-size: 14px;
}
.page-narrative h2 {
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

/* ===== Cards / Paper ===== */
.paper {
  background: var(--bg-paper);
  border-radius: var(--radius-md);
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-1);
}
.paper-flat { background: var(--bg-paper); border-radius: var(--radius-md); border: 1px solid var(--divider); }

/* ===== Summary cards ===== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.summary-card {
  background: var(--bg-paper);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.summary-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.summary-card .value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.summary-card .delta {
  font-size: 12px;
  color: var(--text-secondary);
}
.summary-card .delta.up { color: var(--error); }
.summary-card .delta.down { color: var(--success); }
.summary-card .accent {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
}
.summary-card.primary .accent { background: var(--primary); }
.summary-card.error .accent { background: var(--error); }
.summary-card.warning .accent { background: var(--warning); }
.summary-card.success .accent { background: var(--success); }

.summary-card .icon-bubble {
  position: absolute; right: 14px; top: 14px;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 18px;
}
.summary-card.primary .icon-bubble { background: var(--primary-bg); color: var(--primary); }
.summary-card.error .icon-bubble { background: var(--error-bg); color: var(--error); }
.summary-card.warning .icon-bubble { background: var(--warning-bg); color: var(--warning); }
.summary-card.success .icon-bubble { background: var(--success-bg); color: var(--success); }

/* ===== Filter panel ===== */
.filter-panel {
  background: var(--bg-paper);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.filter-panel .section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
}
.filter-panel .field { display: flex; flex-direction: column; gap: 6px; }
.filter-panel label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Form controls (MUI-ish) ===== */
.input,
.select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-paper);
  color: var(--text-primary);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }

.input-outlined {
  position: relative;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 6px 10px 4px;
  background: var(--bg-paper);
}
.input-outlined .legend {
  position: absolute;
  top: -7px;
  left: 8px;
  background: var(--bg-paper);
  padding: 0 5px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.input-outlined .value { font-size: 13px; padding: 4px 0; }
.input-outlined.focused {
  border-color: var(--primary);
  border-width: 2px;
  padding: 5px 9px 3px;
}
.input-outlined.focused .legend { color: var(--primary); }

.input-outlined.is-select { padding-right: 28px; cursor: pointer; }
.input-outlined .select-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 12px;
  pointer-events: none;
}

/* search input with icon */
.search {
  position: relative;
}
.search input {
  padding-left: 34px;
}
.search .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 14px;
}

/* range row */
.range-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.range-row .input { padding: 0 8px; font-size: 12px; }

/* slider */
.slider-track {
  height: 4px; background: rgba(25,118,210,0.2); border-radius: 999px;
  position: relative; margin: 18px 8px 8px;
}
.slider-track .fill {
  position: absolute; top: 0; bottom: 0;
  background: var(--primary); border-radius: 999px;
}
.slider-track .thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 8px rgba(25,118,210,0.06);
}
.slider-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms, box-shadow 120ms;
  background: transparent;
  color: var(--text-primary);
}
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-2); }
.btn-outlined {
  border-color: rgba(25, 118, 210, 0.5);
  color: var(--primary);
}
.btn-outlined:hover { background: rgba(25,118,210,0.04); border-color: var(--primary); }
.btn-text {
  color: var(--primary);
  padding: 0 8px;
}
.btn-text:hover { background: rgba(25,118,210,0.04); }
.btn-danger { color: var(--error); }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn:disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  border: none; background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ===== Chips ===== */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(0,0,0,0.06);
  color: var(--text-primary);
  white-space: nowrap;
}
.chip-sm { height: 20px; padding: 0 7px; font-size: 10px; }
.chip-md { height: 24px; padding: 0 10px; font-size: 12px; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }

.chip-success { background: var(--success-bg); color: var(--success); }
.chip-warning { background: var(--warning-bg); color: var(--warning); }
.chip-error   { background: var(--error-bg);   color: var(--error); }
.chip-info    { background: var(--info-bg);    color: var(--info); }
.chip-neutral { background: rgba(0,0,0,0.06); color: var(--text-secondary); }

.chip-outlined {
  background: transparent;
  border: 1px solid currentColor;
}

/* ===== Risk chip ===== */
.risk { display: inline-flex; align-items: center; gap: 6px; }
.risk-num {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Table ===== */
.table-paper { background: var(--bg-paper); border: 1px solid var(--divider); border-radius: var(--radius-md); overflow: hidden; }
.table-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}
.table-toolbar .title { font-size: 15px; font-weight: 600; }
.table-toolbar .spacer { flex: 1; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
  background: #fafbfc;
  user-select: none;
  white-space: nowrap;
}
.table thead th .sortable {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer;
}
.table thead th .sortable:hover { color: var(--text-primary); }
.table thead th .sortable .arrow { font-size: 10px; opacity: 0.7; }
.table tbody tr {
  border-bottom: 1px solid var(--divider-light);
  cursor: pointer;
  transition: background 80ms;
}
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr.selected { background: var(--bg-selected); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  white-space: nowrap;
}
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table .actions { width: 60px; text-align: right; }
.table.dense thead th { padding: 6px 12px; font-size: 11px; }
.table.dense tbody td { padding: 6px 12px; font-size: 12px; }

/* pagination */
.pagination {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; padding: 8px 16px;
  border-top: 1px solid var(--divider);
  font-size: 12px; color: var(--text-secondary);
}
.pagination .pages { display: flex; gap: 2px; }
.pagination .page-btn {
  width: 28px; height: 28px; border: none; background: transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px;
  color: var(--text-primary);
}
.pagination .page-btn:hover { background: var(--bg-hover); }
.pagination .page-btn.active { background: var(--primary); color: white; }

/* ===== Drawer ===== */
.drawer {
  background: var(--bg-paper);
  border-left: 1px solid var(--divider);
  box-shadow: var(--shadow-4);
  display: flex; flex-direction: column;
  height: 100%;
}
.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  display: flex; align-items: flex-start; gap: 12px;
}
.drawer-header .head-text { flex: 1; min-width: 0; }
.drawer-header .id {
  font-size: 11px; color: var(--text-secondary);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.drawer-header .name {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
  margin: 2px 0 6px;
}
.drawer-header .meta { display: flex; gap: 8px; flex-wrap: wrap; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.drawer-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--divider-light);
}
.drawer-section:last-child { border-bottom: none; }
.drawer-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 600;
  margin: 0 0 12px;
}
.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.kv {
  display: flex; flex-direction: column; gap: 2px;
}
.kv .k {
  font-size: 11px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.kv .v {
  font-size: 14px; color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.kv .v.big { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }

.drawer-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--divider);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bg-paper);
}

/* pending review row */
.review-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider-light);
}
.review-row:last-child { border-bottom: none; }
.review-row .type { font-size: 13px; font-weight: 500; }
.review-row .due { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* progress bars (risk visual) */
.progress-track {
  height: 6px; border-radius: 999px;
  background: rgba(0,0,0,0.06);
  overflow: hidden;
}
.progress-track .bar { height: 100%; border-radius: 999px; }
.progress-track .bar.success { background: var(--success); }
.progress-track .bar.warning { background: var(--warning); }
.progress-track .bar.error { background: var(--error); }

/* ===== Modal ===== */
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  display: grid; place-items: center;
  z-index: 100;
}
.modal {
  width: 720px;
  max-width: calc(100% - 32px);
  background: var(--bg-paper);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-8);
  display: flex; flex-direction: column;
  max-height: 85vh;
}
.modal-header {
  padding: 16px 20px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.modal-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.modal-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--divider);
  display: flex; gap: 8px; justify-content: flex-end;
}

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-section h5 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary); font-weight: 600;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--divider-light);
}

/* ===== Skeleton (loading) ===== */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skel {
  background: linear-gradient(90deg, rgba(0,0,0,0.06) 0%, rgba(0,0,0,0.10) 50%, rgba(0,0,0,0.06) 100%);
  background-size: 400px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* ===== Layout helpers ===== */
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.gap-s { gap: 8px; }
.gap-m { gap: 16px; }
.gap-l { gap: 24px; }
.muted { color: var(--text-secondary); }
.tiny { font-size: 11px; }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.right { margin-left: auto; }
.divider-h { height: 1px; background: var(--divider); }
.divider-v { width: 1px; background: var(--divider); align-self: stretch; }

/* ===== Approach narrative card (legacy, now superseded by .tab-meta-bar) ===== */
.approach-header { display: none; }

/* ===== Tab meta bar (between tabstrip and page content) ===== */
.tab-meta-bar {
  background: var(--bg-paper);
  border-bottom: 1px solid var(--divider);
  padding: 20px 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.tab-meta-bar .left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tab-meta-bar .eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 600; color: var(--primary);
}
.tab-meta-bar .title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.tab-meta-bar .desc {
  font-size: 13px; color: var(--text-secondary); max-width: 720px;
  text-wrap: pretty;
}
.tab-meta-bar .right-meta {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
  flex-shrink: 0;
}

.note-pin {
  position: relative;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  background: #fffbe6;
  border: 1px dashed #e0c850;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: inline-flex;
  gap: 6px;
  align-items: flex-start;
}
.note-pin::before { content: "✎"; color: #c19400; }

/* layout grids for variants */
.layout-grid-sidebar {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}
.layout-grid-with-drawer {
  display: grid;
  grid-template-columns: 280px 1fr 380px;
  gap: 16px;
}
.layout-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* sticky filter sidebar */
.filter-sidebar { align-self: start; position: sticky; top: 120px; }

/* horizontal filter bar */
.filter-bar {
  background: var(--bg-paper);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.filter-bar .more-btn { white-space: nowrap; }

.filter-bar.expanded {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

/* expandable row */
.expanded-row td {
  background: #fafbfc;
  padding: 16px 24px !important;
}

/* split pane layout (inspector inline) */
.split-pane {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 16px;
  align-items: start;
}

/* empty / error states */
.state-card {
  background: var(--bg-paper);
  border: 1px dashed var(--divider);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.state-card .icon-circle {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 24px;
  background: var(--bg-default);
  color: var(--text-secondary);
}
.state-card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.state-card p { margin: 0; font-size: 13px; color: var(--text-secondary); max-width: 360px; }

.state-error .icon-circle { background: var(--error-bg); color: var(--error); }

/* Tweak panel host */
.tweak-host { font-family: var(--font-sans); }

/* annotations */
.annot {
  position: relative;
}
.annot-callout {
  display: inline-block;
  background: #fff8c2;
  color: #594300;
  font-size: 11px;
  border: 1px solid #e6cf3d;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* tabs (within a section, not page) */
.subtabs {
  display: inline-flex;
  background: var(--bg-paper);
  border: 1px solid var(--divider);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.subtabs button {
  border: none; background: transparent;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  cursor: pointer;
}
.subtabs button.active {
  background: var(--primary);
  color: white;
}

/* density side-by-side */
.density-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.density-grid .density-col h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 600;
  margin: 0 0 8px;
}

/* checkbox / radio (mini) */
.checkbox {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-primary);
  cursor: pointer; user-select: none;
}
.checkbox .box {
  width: 16px; height: 16px;
  border: 2px solid var(--text-secondary);
  border-radius: 3px;
  display: grid; place-items: center;
  color: white; font-size: 11px; font-weight: 700;
}
.checkbox.checked .box { background: var(--primary); border-color: var(--primary); }

/* divider with label */
.divider-label {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-secondary); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
}
.divider-label::before, .divider-label::after {
  content: ""; flex: 1; height: 1px; background: var(--divider);
}

/* date range */
.date-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
}
.date-range .arrow { color: var(--text-disabled); font-size: 12px; }

/* facility count cell */
.cell-fac {
  display: inline-flex; gap: 4px; align-items: center;
}
.cell-fac .badge-num {
  background: var(--bg-default);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

/* alert banner */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.alert .icon { font-size: 16px; flex-shrink: 0; }
.alert-warning { background: var(--warning-bg); color: #663d00; }
.alert-error   { background: var(--error-bg);   color: #5f1717; }
.alert-info    { background: var(--info-bg);    color: #014361; }

/* simple bar chart */
.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 50px;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
}
.bar-row .lbl { color: var(--text-secondary); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }

/* hide scrollbars on filter sidebar but keep scroll */
.scroll-y { overflow-y: auto; }

/* ===== Markdown viewer (Instructions tab) ===== */
.md-viewer-shell {
  display: flex;
  justify-content: center;
}
.md-viewer {
  background: var(--bg-paper);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 880px;
  padding: 32px 40px;
  box-shadow: var(--shadow-1);
}
.md-body {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.65;
}
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  letter-spacing: -0.01em;
  font-weight: 600;
  margin: 1.4em 0 0.5em;
  color: var(--text-primary);
}
.md-body h1:first-child, .md-body h2:first-child, .md-body h3:first-child {
  margin-top: 0;
}
.md-body h1 { font-size: 28px; line-height: 1.25; }
.md-body h2 {
  font-size: 20px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--divider-light);
}
.md-body h3 { font-size: 16px; }
.md-body h4 { font-size: 14px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.08em; }
.md-body p { margin: 0.6em 0; }
.md-body ul, .md-body ol { padding-left: 22px; margin: 0.6em 0; }
.md-body li { margin: 0.25em 0; }
.md-body li > p { margin: 0.2em 0; }
.md-body a { color: var(--primary); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.md-body a:hover { border-bottom-color: var(--primary); }
.md-body code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
}
.md-body pre {
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--divider-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
}
.md-body pre code { background: transparent; padding: 0; }
.md-body blockquote {
  border-left: 3px solid var(--primary);
  padding: 4px 14px;
  margin: 0.8em 0;
  color: var(--text-secondary);
  background: rgba(25, 118, 210, 0.04);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md-body table {
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 13px;
}
.md-body th, .md-body td {
  border: 1px solid var(--divider);
  padding: 8px 12px;
  text-align: left;
}
.md-body th { background: var(--bg-hover); font-weight: 600; }
.md-body hr {
  border: none;
  border-top: 1px solid var(--divider);
  margin: 1.5em 0;
}
.md-body img { max-width: 100%; border-radius: var(--radius-sm); }

