/* Hazmat Portal — styles */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  /* surfaces */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f6;
  --border: #e6e8ec;
  --border-soft: #eef0f3;
  --border-strong: #d3d7de;

  /* text */
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;

  /* brand */
  --accent: #2f5bea;
  --accent-hover: #2449c4;
  --accent-soft: #eef2fe;
  --accent-ring: rgba(47, 91, 234, .22);

  /* dark ink (print toolbar, code, toasts) */
  --ink: #0f172a;
  --ink-text: #cbd5e1;
  --sidebar: var(--ink);           /* kept for pages that still reference these */
  --sidebar-text: var(--ink-text);

  /* status */
  --good: #16a34a; --good-soft: #e8f7ee;
  --warn: #b45309; --warn-soft: #fef5e1;
  --bad: #dc2626;  --bad-soft: #fdecec;
  --low: #16a34a; --medium: #ca8a04; --high: #ea580c; --extreme: #dc2626; --removed: #94a3b8;

  /* shape */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .28);

  /* layout */
  --sidebar-w: 260px;
  --rail-w: 72px;
  --topbar-h: 64px;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 8px; }
::selection { background: var(--accent-soft); }
.icon { width: 18px; height: 18px; flex: none; }
.mono { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-bad { color: var(--bad); font-weight: 500; }
.text-good { color: var(--good); font-weight: 500; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
kbd { font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; line-height: 18px; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 300; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s var(--ease); }
body.nav-collapsed .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

/* ---------- sidebar ---------- */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: hidden; z-index: 40; }
.sidebar-head { display: flex; align-items: center; gap: 8px; height: var(--topbar-h); padding: 0 14px 0 16px; flex: none; }
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; flex: 1; color: var(--text); text-decoration: none !important; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #3b6cff, #1e40af); display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 2px 6px rgba(47, 91, 234, .35); }
.brand-mark .icon { width: 19px; height: 19px; }
.brand-text { min-width: 0; }
.brand-name { display: block; font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand-org { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn.sidebar-close { display: none; }

.nav-search { display: flex; align-items: center; gap: 8px; margin: 4px 14px 6px; padding: 0 10px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-align: left; flex: none; transition: border-color .15s, background .15s; }
.nav-search:hover { border-color: var(--border-strong); background: var(--surface); }
.nav-search .icon { width: 16px; height: 16px; }
.nav-search span { flex: 1; white-space: nowrap; overflow: hidden; }

.nav { padding: 6px 10px 12px; flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 6px; }
.nav-title { display: flex; align-items: center; justify-content: space-between; width: 100%; font: inherit; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); padding: 0 10px 6px; font-weight: 600; background: none; border: 0; text-align: left; white-space: nowrap; }
button.nav-title { cursor: pointer; padding-top: 4px; border-radius: 6px; }
button.nav-title:hover { color: var(--text-2); }
.nav-title .icon { width: 14px; height: 14px; transition: transform .15s; transform: rotate(90deg); }
.nav-group.collapsed .nav-title .icon { transform: none; }
.nav-group.collapsed .nav-items { display: none; }
.nav-items { display: flex; flex-direction: column; gap: 2px; }
.nav-link { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 13.5px; font-weight: 500; text-decoration: none !important; white-space: nowrap; transition: background .12s, color .12s; }
.nav-link .icon { color: var(--faint); transition: color .12s; }
.nav-link > span:not(.soon) { overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link:hover .icon { color: var(--text-2); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link.active .icon { color: var(--accent); }
.nav-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-link .soon { margin-left: auto; font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-3); color: var(--muted); }

.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px 12px 16px; font-size: 11.5px; color: var(--faint); border-top: 1px solid var(--border-soft); flex: none; }
.sidebar-foot .foot-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapse-btn .icon { transition: transform .2s var(--ease); transform: rotate(180deg); }
body.nav-collapsed .collapse-btn .icon { transform: none; }
.nav-overlay { display: none; }

/* icon rail (desktop collapsed) */
@media (min-width: 961px) {
  body.nav-collapsed .sidebar-head { padding: 0; justify-content: center; }
  body.nav-collapsed .brand { flex: none; }
  body.nav-collapsed .brand-text,
  body.nav-collapsed .nav-search span,
  body.nav-collapsed .nav-search kbd,
  body.nav-collapsed .nav-link > span,
  body.nav-collapsed .foot-text,
  body.nav-collapsed .nav-title { display: none; }
  body.nav-collapsed .nav-search { width: 42px; margin: 4px auto 6px; justify-content: center; padding: 0; }
  body.nav-collapsed .nav { padding: 6px 14px 12px; }
  body.nav-collapsed .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
  body.nav-collapsed .nav-group:first-child { border-top: 0; padding-top: 0; }
  body.nav-collapsed .nav-group.collapsed .nav-items { display: flex; }
  body.nav-collapsed .nav-link { justify-content: center; padding: 10px 0; }
  body.nav-collapsed .nav-link.active::before { left: -14px; }
  body.nav-collapsed .sidebar-foot { justify-content: center; padding: 10px 0 12px; }
}

/* ---------- topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 28px; position: sticky; top: 0; z-index: 30; }
.topbar-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.topbar-crumbs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; line-height: 1.3; }
.topbar-crumbs a { color: var(--muted); }
.topbar-crumbs a:hover { color: var(--accent); text-decoration: none; }
.topbar-crumbs .icon { width: 12px; height: 12px; color: var(--faint); }
.topbar-title { font-size: 17px; font-weight: 650; letter-spacing: -.015em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-btn.topbar-search { display: none; }
.icon-btn.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 99px; border: 1px solid transparent; }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #6d8cff, var(--accent)); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; font-size: 13px; font-weight: 500; }
.user-meta small { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.content { padding: 28px 28px 56px; max-width: 1480px; width: 100%; }

.page-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-intro p { color: var(--muted); margin: 0; max-width: 760px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- grid & cards ---------- */
.grid { display: grid; gap: 18px; margin-bottom: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.cols-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
a.card { transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
a.card:hover { border-color: #c7d3fb; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.card-body { padding: 14px 18px 18px; }
.card-body.flush { padding: 12px 0 0; }
.chart-box { position: relative; height: 290px; }
.chart-box.tall { height: 360px; }
.chart-box.short { height: 220px; }

/* ---------- KPI ---------- */
.kpi { --kpi-c: var(--accent); position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; min-width: 0; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--kpi-c); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-bad { --kpi-c: var(--bad); }
.kpi-warn { --kpi-c: #f59e0b; }
.kpi-good { --kpi-c: var(--good); }
.kpi-neutral { --kpi-c: #94a3b8; }

/* ---------- controls ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.filters .spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0; }
.field.grow { flex: 1; min-width: 180px; }
select, input[type=text], input[type=email], input[type=number], input[type=date], input[type=search], textarea {
  font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 11px; min-height: 38px; min-width: 0; max-width: 100%; transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; -webkit-appearance: none; padding-right: 32px; 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='%236b7280' stroke-width='2.5' 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 11px center; }
select:hover, input:hover, textarea:hover { border-color: #b9bfc9; }
textarea { min-height: 80px; resize: vertical; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-size: 13.5px; font-weight: 500; padding: 7px 14px; min-height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; white-space: nowrap; text-decoration: none !important; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); border-color: #b9bfc9; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(47, 91, 234, .3); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); border-color: #f5b5b5; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 4px 11px; min-height: 32px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; flex: none; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: var(--radius-sm); }
.seg button { font: inherit; font-size: 12.5px; font-weight: 500; padding: 6px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; transition: background .12s, color .12s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button { font: inherit; font-size: 13.5px; font-weight: 500; padding: 10px 12px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; transition: color .12s, border-color .12s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; line-height: 1.5; }
.risk-Extreme { background: #fdecec; color: #b91c1c; }
.risk-High { background: #fff0e3; color: #c2410c; }
.risk-Medium { background: #fdf6d8; color: #a16207; }
.risk-Low { background: #e8f7ee; color: #15803d; }
.risk-Removed, .risk-None { background: var(--surface-3); color: var(--muted); }
.tone-good { background: var(--good-soft); color: #15803d; }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: #b91c1c; }
.tone-neutral { background: #e8ebf0; color: var(--text-2); }
.tone-muted { background: var(--surface-3); color: var(--muted); }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; color: var(--c); background: color-mix(in srgb, var(--c) 10%, white); border: 1px solid color-mix(in srgb, var(--c) 25%, white); white-space: nowrap; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 0 6px; border-radius: 5px; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; vertical-align: 1px; }
.pill { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 99px; white-space: nowrap; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }

.bandbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.bandbar span { display: block; height: 100%; }

/* ---------- banners ---------- */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius); border: 1px solid; margin-bottom: 18px; font-size: 13.5px; }
.banner .icon { margin-top: 1px; }
.banner strong { font-weight: 600; }
.banner-info { background: var(--accent-soft); border-color: #d3ddfc; color: #1e3a8a; }
.banner-warn { background: #fffaeb; border-color: #fbe3a6; color: #78350f; }
.banner-bad { background: #fef3f2; border-color: #fbcaca; color: #7f1d1d; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); border-top: 1px solid var(--border-soft); white-space: nowrap; user-select: none; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table th.sorted-asc, .table th.sorted-desc { color: var(--accent); }
.table th.sorted-asc::after { content: " ↑"; }
.table th.sorted-desc::after { content: " ↓"; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: #f7f9ff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.empty, .empty { color: var(--muted); text-align: center; padding: 32px 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; border-top: 1px solid var(--border-soft); }
.pager-ctrl { display: inline-flex; gap: 8px; align-items: center; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.list li:last-child { border-bottom: 0; }
.list li > .icon { color: var(--accent); }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; }
.rank-bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.rank-bar span { display: block; height: 100%; border-radius: 99px; }
.alert-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); align-items: flex-start; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .icon { margin-top: 1px; }
.alert-item.bad .icon { color: var(--bad); }
.alert-item.warn .icon { color: #d97706; }
.alert-item.info .icon { color: var(--accent); }

.type-tile { display: flex; flex-direction: column; gap: 6px; }
.type-tile .count { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }

/* ---------- portfolio explorer ---------- */
.explorer { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: start; }
.tree-panel { position: sticky; top: calc(var(--topbar-h) + 18px); max-height: calc(100vh - var(--topbar-h) - 36px); display: flex; flex-direction: column; overflow: hidden; }
.tree-search { padding: 12px; border-bottom: 1px solid var(--border-soft); }
.tree-search input { width: 100%; }
.tree { overflow-y: auto; padding: 6px; font-size: 13px; scrollbar-width: thin; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 0; cursor: pointer; border-radius: 6px; transition: background .1s; }
.tree-row:hover { background: var(--surface-3); }
.tree-row.selected { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-row.selected .tree-count { color: var(--accent); }
.tree-toggle { width: 20px; height: 20px; display: grid; place-items: center; border: 0; background: none; padding: 0; color: var(--faint); cursor: pointer; flex: none; border-radius: 4px; }
.tree-toggle:hover { color: var(--text); }
.tree-toggle .icon { width: 14px; height: 14px; transition: transform .15s; }
.tree-toggle.open .icon { transform: rotate(90deg); }
.tree-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.search-hit { padding: 8px 12px; cursor: pointer; border-radius: 6px; }
.search-hit:hover { background: var(--surface-3); }
.search-hit small { display: block; color: var(--muted); }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); padding: 1px 4px; margin: 0 -4px; border-radius: 4px; }
.crumbs a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.crumbs .sep { color: var(--border-strong); margin: 0 4px; }
.node-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); font-weight: 600; }
.node-head h2 { font-size: 24px; margin: 2px 0 6px; letter-spacing: -.02em; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); }
.meta b { color: var(--text-2); font-weight: 500; }
.child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.child-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: var(--surface); display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
.child-card:hover { border-color: #c7d3fb; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.child-card .name { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.child-card .name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.child-card .stats { font-size: 12px; color: var(--muted); }

/* ---------- detail list ---------- */
.dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.dl-row { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* ---------- modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; z-index: 100; animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .18s var(--ease); }
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border-soft); background: var(--surface-2); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--text); font-weight: 400; font-size: 13px; }
.check-grid label { display: inline-flex; gap: 6px; align-items: center; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; transition: opacity .4s, transform .4s; background: var(--ink); color: #fff; animation: pop .2s var(--ease); }
.toast.tone-bad { background: #b91c1c; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- quick search (command palette) ---------- */
.palette-backdrop { place-items: start center; padding-top: 12vh; }
.palette { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(620px, 100%); max-height: 70vh; display: flex; flex-direction: column; overflow: hidden; animation: pop .16s var(--ease); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border-soft); }
.palette-input .icon { color: var(--muted); }
.palette-input input::-webkit-search-cancel-button { display: none; }
.palette-input input { flex: 1; border: 0; box-shadow: none !important; padding: 16px 0; font-size: 15px; min-height: 56px; background: transparent; }
.palette-results { overflow-y: auto; padding: 6px 8px 8px; }
.palette-section { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); text-decoration: none !important; }
.palette-item .p-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--surface-3); color: var(--muted); display: grid; place-items: center; flex: none; }
.palette-item .p-icon .icon { width: 16px; height: 16px; }
.palette-item .p-text { flex: 1; min-width: 0; }
.palette-item .p-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .p-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .p-kind { font-size: 11px; color: var(--faint); white-space: nowrap; }
.palette-item.active { background: var(--accent-soft); }
.palette-item.active .p-icon { background: var(--accent); color: #fff; }
.palette-empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border-soft); background: var(--surface-2); font-size: 12px; color: var(--muted); }
.palette-foot span { display: inline-flex; gap: 5px; align-items: center; }

/* ---------- heat maps ---------- */
#map { height: 540px; border-radius: 0 0 var(--radius) var(--radius); }
.legend-scale { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend-scale .ramp { width: 160px; height: 10px; border-radius: 99px; background: linear-gradient(90deg, #16a34a, #eab308, #f97316, #dc2626); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.floorplan { width: 100%; height: auto; display: block; }
.floorplan .room { cursor: pointer; stroke: #fff; stroke-width: 2; transition: opacity .1s; }
.floorplan .room:hover { opacity: .8; }
.floorplan .room.sel { stroke: var(--ink); stroke-width: 3; }
.floorplan text { pointer-events: none; font-family: var(--font); }
.matrix { display: grid; grid-template-columns: 110px repeat(5, minmax(0, 1fr)); gap: 5px; }
.matrix .cell { aspect-ratio: 1.6; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 20px; cursor: pointer; border: 2px solid transparent; color: var(--ink); transition: transform .12s var(--ease), border-color .12s; }
.matrix .cell small { font-size: 10.5px; font-weight: 500; opacity: .75; }
.matrix .cell:hover { transform: scale(1.03); }
.matrix .cell:hover, .matrix .cell.sel { border-color: var(--ink); }
.matrix .lab { display: flex; align-items: center; justify-content: flex-end; text-align: right; font-size: 12px; color: var(--muted); padding-right: 8px; }
.matrix .lab.col { justify-content: center; text-align: center; padding: 4px 0 0; }
.heat-table td.heat { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.leaflet-popup-content { font-family: var(--font); font-size: 13px; }
.leaflet-container { font-family: var(--font); }

/* ---------- upload ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 36px 20px; text-align: center; background: var(--surface-2); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .icon { width: 36px; height: 36px; color: var(--accent); margin-bottom: 8px; }
.dropzone strong { display: block; font-size: 15px; margin-bottom: 4px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.step { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.step b { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; font-size: 12px; }
.step strong { display: block; color: var(--text); }
tr.row-error td { background: #fef3f2; }
tr.row-warn td { background: #fffaeb; }
pre.code { background: var(--ink); color: #e2e8f0; padding: 16px; border-radius: 10px; font-family: var(--mono); font-size: 12px; overflow-x: auto; margin: 0; line-height: 1.6; }

/* ---------- admin ---------- */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table tr.planned td { color: var(--muted); background: var(--surface-2); }
.role-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.role-pills button { font: inherit; font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; color: var(--text-2); transition: background .12s, border-color .12s; }
.role-pills button:hover { background: var(--surface-3); }
.role-pills button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.user-cell { display: flex; gap: 10px; align-items: center; }
.user-cell .avatar { width: 30px; height: 30px; font-size: 11px; }
.user-cell small { display: block; color: var(--muted); }

/* ---------- modules ---------- */
.module-card { display: flex; flex-direction: column; gap: 10px; }
.module-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.module-icon .icon { width: 22px; height: 22px; }
.module-card ul { margin: 0; padding-left: 18px; color: var(--text-2); }
.module-card li { margin-bottom: 3px; }

/* ---------- small layout helpers (formerly inline styles) ---------- */
.mb { margin-bottom: 18px; }
.grid.tight { margin-bottom: 10px; }
.note { margin: 10px 0 0; }
.subhead { font-size: 14px; }
.center, .table th.center { text-align: center; }
.card-head.spaced { padding-bottom: 12px; }
.card-body.pb-0 { padding-bottom: 0; }
.input-sm { width: 110px; }
.col-bar { min-width: 100px; }
.actions.end { justify-content: flex-end; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.filters.plain { box-shadow: none; margin-bottom: 0; padding: 0; border: 0; }
.filters .btn.sm { margin-bottom: 3px; }
.scope-row { margin-top: 8px; }
.type-tile .count .small { font-weight: 400; }
.modal-body .banner { margin-bottom: 12px; }
a.card { color: inherit; text-decoration: none !important; }
.module-card h2 { font-size: 20px; }
.module-card p { margin: 0; }
.pct-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.pct-cell .rank-bar { width: 60px; margin: 0; }
.tree-toggle.leaf { visibility: hidden; }
.floorplan .on-fill { fill: #fff; paint-order: stroke; stroke: rgba(15, 23, 42, .45); stroke-width: 2.5px; }
.floorplan .off-fill { fill: #64748b; }

/* ---------- contractor acknowledgement (printable A4) ---------- */
body.ack-page { background: #e5e9ef; }
.ack-toolbar { position: sticky; top: 0; z-index: 10; background: var(--ink); color: #fff; display: flex; gap: 10px; align-items: center; padding: 10px 20px; flex-wrap: wrap; }
.ack-toolbar .grow { flex: 1; font-size: 13px; color: var(--ink-text); min-width: 200px; }
.ack-doc { background: #fff; max-width: 860px; margin: 24px auto; padding: 40px 44px; box-shadow: var(--shadow-lg); border-radius: 4px; }
.ack-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--text); padding-bottom: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.ack-head h1 { font-size: 21px; margin-top: 4px; }
.ack-ref { text-align: right; font-size: 12px; color: var(--muted); }
.ack-ref b { color: var(--text); font-family: var(--mono); }
.ack-doc h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.ack-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.ack-fields .full { grid-column: 1 / -1; }
.ack-fields label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); font-weight: 600; gap: 2px; }
.ack-fields input, .ack-fields textarea { border: 0; border-bottom: 1px solid #94a3b8; border-radius: 0; padding: 4px 2px; min-height: 30px; font-size: 13.5px; background: #fbfdff; }
.ack-fields input:focus, .ack-fields textarea:focus { box-shadow: none; border-bottom-color: var(--accent); }
.ack-fields textarea { min-height: 54px; }
.ack-fixed { font-size: 13.5px; color: var(--text); font-weight: 500; padding: 4px 2px; border-bottom: 1px solid #e2e8f0; }
.ack-doc .table { font-size: 12px; }
.ack-doc .table th, .ack-doc .table td { padding: 6px 8px; }
.ack-doc .controls { display: grid; gap: 10px; }
.ack-doc .control { border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 6px; padding: 10px 14px; break-inside: avoid; }
.ack-doc .control h3 { font-size: 13.5px; margin-bottom: 4px; }
.ack-doc .control ul, .ack-doc ol { margin: 4px 0 0; padding-left: 20px; font-size: 12.8px; }
.ack-doc .control li, .ack-doc ol li { margin-bottom: 3px; }
.ack-doc .declaration { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; font-size: 13px; }
.ack-doc .sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 18px; }
.ack-doc .sig h4 { font-size: 12.5px; margin-bottom: 18px; }
.ack-doc .sig .line { border-bottom: 1px solid #334155; height: 34px; margin-bottom: 4px; }
.ack-doc .sig .lbl { font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.ack-foot { margin-top: 26px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
@media (max-width: 700px) {
  .ack-doc { padding: 22px 16px; margin: 0; border-radius: 0; }
  .ack-fields, .ack-doc .sig-grid { grid-template-columns: 1fr; }
  .ack-ref { text-align: left; }
}
@media print {
  @page { size: A4; margin: 14mm; }
  body.ack-page { background: #fff; }
  .ack-toolbar { display: none; }
  .ack-doc { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .ack-fields input, .ack-fields textarea { background: none; }
  .ack-doc .badge, .ack-doc .chip, .ack-doc .control { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ack-doc tr, .ack-doc .sig-grid, .ack-doc .declaration { break-inside: avoid; }
  .ack-doc a { color: inherit; text-decoration: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .explorer { grid-template-columns: 270px minmax(0, 1fr); }
}
@media (max-width: 960px) {
  :root { --topbar-h: 58px; }
  .app, body.nav-collapsed .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .22s var(--ease); box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 35; animation: fade .15s; }
  .icon-btn.sidebar-close { display: inline-grid; }
  .icon-btn.collapse-btn { display: none; }
  .icon-btn.menu-btn { display: inline-grid; margin-left: -6px; }
  .icon-btn.topbar-search { display: inline-grid; }
  .user-meta, .topbar .pill { display: none; }
  .user-chip { padding: 0; }
  .topbar { padding: 0 16px; }
  .topbar-title { font-size: 16px; }
  .content { padding: 18px 16px 44px; }
  .cols-2, .cols-3, .cols-3-1, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .explorer { grid-template-columns: minmax(0, 1fr); }
  .tree-panel { position: static; max-height: 360px; }
  .dl { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .palette-backdrop { padding-top: 8vh; }
}
@media (max-width: 560px) {
  .cols-6, .cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .dl-row { grid-template-columns: 1fr; gap: 2px; }
  .kpi-value { font-size: 21px; }
  .topbar-crumbs { display: none; }
  .matrix { grid-template-columns: 70px repeat(5, minmax(0, 1fr)); }
  .matrix .cell { font-size: 15px; }
  #map { height: 420px; }
  .palette-foot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
