/* PLAA Tracker — design tokens, layout, components */
:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef2f5;
  --border: #e2e7ec;
  --border-strong: #cbd3db;
  --text: #0f1b24;
  --text-2: #4a5763;
  --text-3: #75828e;
  --brand: #0b3a53;
  --brand-2: #0f5f7a;
  --accent: #0e7fa3;
  --accent-soft: #e3f3f8;
  --focus: #2a78d6;
  --series-1: #2a78d6;
  --seq-1: #86b6ef;
  --good: #0a7d0a; --good-bg: #e6f5e6;
  --info: #1c5cab; --info-bg: #e7f0fb;
  --warn: #8a5a00; --warn-bg: #fdf3dc;
  --serious: #b0431a; --serious-bg: #fcebe3;
  --critical: #c02f2f; --critical-bg: #fbe7e7;
  --neutral: #52606d; --neutral-bg: #eef1f4;
  --violet: #4a3aa7; --violet-bg: #efedfb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  --sidebar: 236px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1418; --surface: #161d22; --surface-2: #1b242a; --surface-3: #222d34;
    --border: #2a353d; --border-strong: #3a4751;
    --text: #eef3f6; --text-2: #b6c2cb; --text-3: #8795a0;
    --brand: #0b3a53; --brand-2: #4fb3d4; --accent: #4fb3d4; --accent-soft: #15313d; --focus: #6aa8f0;
    --series-1: #3987e5; --seq-1: #1c5cab;
    --good: #5fcf5f; --good-bg: #16301a; --info: #7fb2f0; --info-bg: #172a40;
    --warn: #f3c460; --warn-bg: #34290f; --serious: #f0a07e; --serious-bg: #3a2118;
    --critical: #f08a8a; --critical-bg: #3b1a1a; --neutral: #aab6bf; --neutral-bg: #252f36;
    --violet: #a79cf0; --violet-bg: #251f45;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1418; --surface: #161d22; --surface-2: #1b242a; --surface-3: #222d34;
  --border: #2a353d; --border-strong: #3a4751;
  --text: #eef3f6; --text-2: #b6c2cb; --text-3: #8795a0;
  --brand: #0b3a53; --brand-2: #4fb3d4; --accent: #4fb3d4; --accent-soft: #15313d; --focus: #6aa8f0;
  --series-1: #3987e5; --seq-1: #1c5cab;
  --good: #5fcf5f; --good-bg: #16301a; --info: #7fb2f0; --info-bg: #172a40;
  --warn: #f3c460; --warn-bg: #34290f; --serious: #f0a07e; --serious-bg: #3a2118;
  --critical: #f08a8a; --critical-bg: #3b1a1a; --neutral: #aab6bf; --neutral-bg: #252f36;
  --violet: #a79cf0; --violet-bg: #251f45;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--brand); color: #dce9f0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; overflow-y: auto;
}
.logo { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; color: #fff; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #1aa3c9, #0e7fa3); display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .5px; }
.logo b { display: block; font-size: 15px; }
.logo span { font-size: 11px; opacity: .75; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: #cfe0ea; font-weight: 500; text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav a .count { margin-left: auto; background: #d03b3b; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.proj-switch { display: block; margin: 0 4px 6px; }
.proj-switch select { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); font-weight: 600; }
.proj-switch select option { color: #0f1b24; }
.welcome { max-width: 880px; margin: 4vh auto; }
.welcome .lib-hero { padding: 34px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; margin: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; font-size: 11px; opacity: .65; padding: 10px; }
.sidebar-foot a { color: inherit; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.search-trigger {
  flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text-3); cursor: text;
}
.search-trigger kbd { margin-left: auto; }
kbd { font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text-3); background: var(--surface-2); }
.topbar .spacer { flex: 1; }
.content { padding: 22px 24px 60px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--text-3); margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumbs a { color: var(--text-2); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #06212b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #06212b; } }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--critical); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.icon-only { padding: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=date], input[type=number], input[type=password], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); min-height: 34px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 50%, transparent); border-color: var(--focus); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
label.field .hint { font-weight: 400; color: var(--text-3); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 16px; }
.card-b.flush { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; cursor: pointer; transition: transform .12s, box-shadow .12s; text-align: left; border: 1px solid var(--border); }
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kpi .label { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12px; color: var(--text-3); }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill svg { width: 12px; height: 12px; stroke-width: 2.4; }
.st-good { color: var(--good); background: var(--good-bg); }
.st-info { color: var(--info); background: var(--info-bg); }
.st-warn { color: var(--warn); background: var(--warn-bg); }
.st-serious { color: var(--serious); background: var(--serious-bg); }
.st-critical { color: var(--critical); background: var(--critical-bg); }
.st-neutral { color: var(--neutral); background: var(--neutral-bg); }
.st-violet { color: var(--violet); background: var(--violet-bg); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
table.data th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: 12px; font-weight: 650; color: var(--text-2);
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td .t1 { font-weight: 600; }
table.data td .t2 { font-size: 12px; color: var(--text-3); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.progress { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; border-radius: 4px; background: var(--info); }
.progress.warn > span { background: #fab219; }
.progress.crit > span { background: #d03b3b; }
.days { font-weight: 650; font-variant-numeric: tabular-nums; }
.days.over { color: var(--critical); }
.days.soon { color: var(--warn); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; max-width: 240px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); padding: 4px 10px; border-radius: 999px; font-size: 12px; cursor: pointer; font-weight: 550; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .n { color: var(--text-3); margin-left: 4px; }

/* ---------- dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.sev { width: 4px; align-self: stretch; border-radius: 3px; flex: none; }
.sev.critical { background: #d03b3b; } .sev.serious { background: #ec835a; } .sev.warning { background: #fab219; } .sev.info { background: #2a78d6; }
.empty { padding: 28px; text-align: center; color: var(--text-3); }

/* bar chart */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 42px; gap: 10px; align-items: center; font-size: 13px; cursor: pointer; border-radius: 6px; padding: 2px 4px; }
.bar-row:hover { background: var(--surface-2); }
.bar-row .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-row .track { height: 14px; position: relative; }
.bar-row .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.bar-row .val { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.stack-bar { display: flex; height: 16px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 6px; font-size: 12px; box-shadow: var(--shadow-lg); max-width: 280px; }

/* ---------- detail ---------- */
.detail-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.detail-head .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button .n { font-size: 11px; background: var(--surface-3); border-radius: 8px; padding: 0 6px; margin-left: 4px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.fact { background: var(--surface); padding: 12px 14px; }
.fact .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; }
.fact .v { font-size: 15px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.fact .s { font-size: 12px; color: var(--text-3); }
.savebar {
  position: sticky; bottom: 12px; z-index: 15; display: flex; gap: 10px; align-items: center; margin-top: 16px;
  background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg);
}
.savebar .btn { border-color: transparent; }

/* timeline of cycles */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ''; position: absolute; left: -20px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--text-3); }
.tl-item.good::before { border-color: var(--good); background: var(--good); }
.tl-item.info::before { border-color: var(--info); }
.tl-item.serious::before { border-color: var(--serious); background: var(--serious); }
.tl-item.neutral::before { border-color: var(--neutral); }
.tl-item .when { font-size: 12px; color: var(--text-3); }

.cycle { border: 1px solid var(--border); border-radius: 9px; padding: 12px; background: var(--surface-2); }
.cycle-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cycle-h .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.cycles { display: grid; gap: 10px; }

/* ---------- modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 15, 20, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 720px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.wide { max-width: 960px; }
.modal-h { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 18px; max-height: 70vh; overflow-y: auto; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); }

.palette { max-width: 640px; }
.palette input { border: 0; font-size: 16px; padding: 16px 18px; border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; min-height: 52px; }
.palette input:focus { outline: none; }
.pal-list { max-height: 55vh; overflow-y: auto; padding: 6px; }
.pal-item { display: flex; gap: 10px; padding: 9px 12px; border-radius: 8px; cursor: pointer; align-items: center; }
.pal-item.sel, .pal-item:hover { background: var(--accent-soft); }
.pal-item .k { font-size: 11px; color: var(--text-3); margin-left: auto; white-space: nowrap; }
.pal-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 8px 12px 4px; }

.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .18s ease-out; }
.toast.err { background: var(--critical); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.cal .dow { padding: 8px; font-size: 12px; font-weight: 650; color: var(--text-2); background: var(--surface-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal .day { min-height: 112px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); overflow: hidden; }
.cal .day.other { background: var(--surface-2); color: var(--text-3); }
.cal .day.weekend { background: var(--surface-2); }
.cal .day.today .dnum { background: var(--accent); color: #fff; border-radius: 50%; }
.cal .dnum { font-size: 12px; font-weight: 650; width: 22px; height: 22px; display: inline-grid; place-items: center; }
.cal .hol { font-size: 10px; color: var(--serious); font-weight: 600; margin-left: 4px; }
.cal .ev { display: block; font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-left: 3px solid; }
.cal .more { font-size: 11px; color: var(--accent); cursor: pointer; margin-top: 2px; }

/* ---------- planner gantt ---------- */
.gantt { position: relative; margin-top: 10px; }
.g-row { display: grid; grid-template-columns: 210px 1fr; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.g-track { position: relative; height: 26px; background: var(--surface-2); border-radius: 6px; }
.g-seg { position: absolute; top: 3px; bottom: 3px; border-radius: 5px; color: #fff; font-size: 11px; font-weight: 650; display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; }
.g-mile { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--critical); }

/* ---------- library ---------- */
.lib-hero { background: linear-gradient(135deg, var(--brand), #0f5f7a); color: #fff; border-radius: 14px; padding: 26px; margin-bottom: 18px; }
.lib-hero h1 { font-size: 24px; }
.lib-hero p { opacity: .85; max-width: 760px; }
.lib-hero input { max-width: 560px; margin-top: 12px; border: 0; min-height: 42px; font-size: 15px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile { padding: 16px; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; display: flex; flex-direction: column; gap: 6px; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.tile .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.tile .ico .icon { width: 20px; height: 20px; }
.tile h3 { font-size: 15px; }
.tile p { margin: 0; color: var(--text-2); font-size: 13px; }
.tile .foot { margin-top: auto; font-size: 12px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.lib-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.tree { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; padding: 8px; }
.tree details { margin: 2px 0; }
.tree summary { cursor: pointer; padding: 6px 8px; border-radius: 6px; font-weight: 600; font-size: 13px; list-style: none; display: flex; gap: 6px; align-items: center; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: '▸'; font-size: 10px; color: var(--text-3); transition: transform .12s; }
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary:hover { background: var(--surface-2); }
.tree .lvl2 { padding-left: 12px; }
.tree .lvl3 { padding-left: 14px; }
.tree a.leaf { display: block; padding: 5px 8px 5px 22px; border-radius: 6px; font-size: 13px; color: var(--text-2); }
.tree a.leaf:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.tree a.leaf.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sec { margin-bottom: 18px; }
.sec h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.sec ul { margin: 0; padding-left: 20px; }
.sec li { margin: 4px 0; }
.checklist li { list-style: none; margin-left: -20px; display: flex; gap: 8px; align-items: flex-start; }
.checklist input { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.src { font-size: 11px; color: var(--text-3); }
.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 0 8px 8px 0; }
.callout.warn { border-color: #fab219; background: var(--warn-bg); }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step { padding: 14px; }
.step .num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.finder-q { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.finder-q .q { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 12px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--accent); color: #fff; }

.hol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1000px) {
  .dash-grid, .lib-layout { grid-template-columns: 1fr; }
  .tree { position: static; max-height: none; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.bottom-nav, .backdrop { display: none; }
.mobile-only { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 70; width: 270px; transform: translateX(-100%); transition: transform .2s; padding-top: calc(16px + env(safe-area-inset-top)); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .backdrop.show { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(8, 15, 20, .45); }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px 14px calc(96px + env(safe-area-inset-bottom)); }
  .topbar { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 8px; }
  .topbar .spacer { display: none; }
  .search-trigger { max-width: none; }
  .search-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .btn-label, #newPermitBtn { display: none; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .grid > *, .filters > *, .row > * { min-width: 0; }
  .search-trigger { min-width: 0; }
  .filters select { width: 100%; }
  .card-h { flex-wrap: wrap; }
  .card-h h2 { flex: 1 1 160px; min-width: 0; }
  .card-h .right { margin-left: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 24px; }
  .g-row { grid-template-columns: 1fr; }
  .search-trigger kbd { display: none; }
  .steps { grid-template-columns: 1fr; }
  h1 { font-size: 20px; }
  .page-head { align-items: flex-start; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; justify-content: center; }
  .detail-head .row { width: 100%; }
  .detail-head .row .btn.primary { flex: 1; justify-content: center; }
  .facts { grid-template-columns: 1fr 1fr !important; }
  .filters { padding: 10px 12px; }
  .filters input[type=search], .filters select { max-width: none; flex: 1 1 100%; }
  .chips { overflow-x: auto; flex-wrap: nowrap; width: 100%; padding-bottom: 2px; }
  .chip { white-space: nowrap; }
  /* bigger touch targets; 16px inputs stop iOS from zooming in */
  input[type=text], input[type=email], input[type=date], input[type=number], input[type=password], input[type=time], input[type=search], select, textarea { font-size: 16px; min-height: 42px; }
  .btn { min-height: 40px; }
  .btn.sm { min-height: 34px; }
  .tabs button { padding: 10px 12px; }
  /* tables become cards */
  table.stack-table thead { display: none; }
  table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table tr { border-bottom: 1px solid var(--border); padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  table.stack-table td { border: 0; padding: 2px 0; min-width: 0 !important; max-width: none !important; }
  table.stack-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
  table.stack-table td.cell-main { grid-column: 1 / -1; order: -1; }
  table.stack-table td.cell-hide-m { display: none; }
  .table-wrap { max-height: none !important; }
  /* modals become full-screen sheets */
  .overlay { padding: 0; align-items: stretch; }
  .modal, .modal.wide { max-width: none; border-radius: 0; min-height: 100%; display: flex; flex-direction: column; }
  .modal-h { padding-top: calc(14px + env(safe-area-inset-top)); position: sticky; top: 0; background: var(--surface); z-index: 1; }
  .modal-b { max-height: none; flex: 1; }
  .modal-f { position: sticky; bottom: 0; background: var(--surface); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1; justify-content: center; }
  .palette { border-radius: 0; }
  .savebar { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toasts { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  /* calendar: dots in the grid, agenda list below */
  .cal .day { min-height: 54px; padding: 4px; }
  .cal .ev { font-size: 0; height: 6px; padding: 0; margin-top: 2px; border-left-width: 0; }
  .cal .hol, .cal .more { display: none; }
  .mobile-only { display: block; }
  .lib-hero { padding: 18px; }
  .lib-hero h1 { font-size: 20px; }
  .tree { display: none; }
  .finder-q { flex-direction: column; align-items: stretch; }
  .seg button { flex: 1; padding: 8px 12px; font-size: 13px; }
  .seg { display: flex; }
  /* bottom tab bar */
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(16, 24, 40, .06);
  }
  .bottom-nav a, .bottom-nav button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--text-3); background: none; border: 0; text-decoration: none; padding: 4px 0; cursor: pointer; }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav .icon { width: 22px; height: 22px; }
  .bottom-nav .bn-new { align-self: center; justify-self: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff; justify-content: center; box-shadow: var(--shadow-lg); margin-top: -18px; }
  .bottom-nav .bn-new .icon { width: 24px; height: 24px; stroke-width: 2.4; }
  .bn-dot { position: absolute; top: 2px; left: 55%; width: 9px; height: 9px; border-radius: 50%; background: #d03b3b; }
}
@media print { .sidebar, .topbar, .savebar, .actions, .filters { display: none !important; } .app { display: block; } }

/* ---------- accounts ---------- */
.user-box { margin: auto 10px 0; padding: 8px; border-top: 1px solid rgba(255,255,255,.12); display: flex; flex-direction: column; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 6px; border-radius: 8px; min-width: 0; }
.user-chip:hover { background: rgba(255,255,255,.08); }
.user-chip .avatar { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; }
.user-chip .grow { min-width: 0; display: flex; flex-direction: column; }
.user-chip b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip span span, .user-chip .grow > span { font-size: 11.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .btn { justify-content: flex-start; color: inherit; opacity: .85; }

/* ---------- submission checklists ---------- */
.cl-sec { border-top: 1px solid var(--border); padding: 4px 0; }
.cl-sec:first-child { border-top: 0; }
.cl-sec > summary { cursor: pointer; font-weight: 650; padding: 8px 0; list-style-position: outside; }
.cl-list { list-style: none; margin: 0 0 8px; padding: 0; }
.cl-list > li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.cl-list ul, .cl-t ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.cl-n { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 13px; text-align: right; padding-top: 2px; }
.cl-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 6px; border-bottom: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.cl-row.info { grid-template-columns: 34px minmax(0, 1fr); }
.cl-row.done.yes { background: var(--good-bg); }
.cl-row.done.no { background: var(--critical-bg); }
.cl-row.done.na, .cl-row.done.ack { background: var(--surface-2); }
.cl-row.done .cl-t > div:first-child { color: var(--text-2); }
.cl-why { margin-top: 6px; width: 100%; box-sizing: border-box; }
.seg.sm button { padding: 5px 10px; font-size: 12.5px; }
.cl-prog { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cl-prog .bar { flex: 1 1 160px; max-width: 320px; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.cl-prog .bar i { display: block; height: 100%; background: var(--good); }
@media (max-width: 860px) {
  .cl-row { grid-template-columns: 26px minmax(0, 1fr); }
  .cl-row .seg { grid-column: 2; justify-self: start; }
}
.user-box + .sidebar-foot { margin-top: 0; }

.finder-g { padding: 14px 16px 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); border-top: 1px solid var(--border); background: var(--surface-2); }
.finder-g:first-of-type { border-top: 0; }

/* Home (landing page after sign-in) */
.home-page { max-width: 1240px; margin: 0 auto; }
.home-hero2 { padding: 28px 30px; }
.home-hero2 h1 { font-size: 28px; margin: 4px 0 6px; }
.home-hero2 p { font-size: 15.5px; margin: 0; }
.home-hero2 .home-cta { background: #fff; color: var(--brand); border-color: #fff; }
.home-hero2 .home-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.home-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.home-stat { padding: 14px 16px; text-decoration: none; color: inherit; border: 1px solid var(--border); transition: transform .12s, box-shadow .12s; }
.home-stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.home-stat .label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.home-stat .value { font-size: 28px; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.home-stat .foot { font-size: 12px; color: var(--text-3); }
.home-stat.tone-crit { border-left: 4px solid var(--critical); }
.home-stat.tone-crit .value { color: var(--critical); }
.home-stat.tone-warn { border-left: 4px solid #ec835a; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.home-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.home-act { flex-direction: row; align-items: flex-start; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; box-shadow: none; }
.home-act .ico { flex: none; }
.home-act h3 { font-size: 14px; margin: 0 0 2px; }
.home-proj { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; text-decoration: none; color: inherit; box-shadow: none; border: 1px solid var(--border); }
.home-proj:hover { border-color: var(--accent); }
.home-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.home-bar span { display: block; height: 100%; background: #0ca30c; }
@media (max-width: 1200px) { .home-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .home-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .home-hero2 { padding: 20px 18px; }
  .home-hero2 h1 { font-size: 22px; }
  .home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-stat .value { font-size: 24px; }
  .home-acts { grid-template-columns: minmax(0, 1fr); }
}

/* Permit Finder: one question at a time */
.finder-topics { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; margin-bottom: 4px; scrollbar-width: thin; }
.finder-topic { flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.finder-topic .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.finder-topic .icon { width: 14px; height: 14px; color: #0ca30c; }
.finder-topic.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.finder-topic.on .n, .finder-topic.on .icon { color: rgba(255,255,255,.85); }
.finder-card { overflow: hidden; }
.finder-meta { display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px 8px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.finder-prog { height: 4px; background: var(--surface-3); }
.finder-prog span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.finder-card .card-b { padding: 22px 20px 16px; }
.finder-qtext { font-size: 20px; line-height: 1.35; margin: 0 0 8px; font-weight: 650; }
.finder-hint { margin: 0 0 4px; font-size: 14px; }
.seg.finder-big { display: flex; margin: 18px 0 14px; border-radius: 10px; }
.seg.finder-big button { flex: 1; padding: 13px 10px; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--text); }
.seg.finder-big button.on { color: #fff; }
.seg.finder-big button:hover:not(.on) { background: var(--surface-2); }
.seg kbd, .finder-keys kbd { font: 600 11px/1 ui-monospace, monospace; border: 1px solid var(--border-strong); border-radius: 4px; padding: 2px 5px; opacity: .7; }
.finder-adds { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.finder-adds .tag { text-decoration: none; }
.finder-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 12px; }
.finder-nav .grow { flex: 1; }
.finder-keys { margin-top: 10px; }
.finder-done { text-align: center; padding: 34px 24px; }
.finder-done .ico { width: 48px; height: 48px; border-radius: 50%; background: #e3f5e3; color: #0ca30c; display: grid; place-items: center; margin: 0 auto 10px; }
.finder-done .ico .icon { width: 24px; height: 24px; }
.finder-res { position: sticky; top: 70px; }
.finder-res .list { max-height: calc(100vh - 170px); overflow: auto; }
.finder-g { display: flex; justify-content: space-between; }
.finder-g .n { font-variant-numeric: tabular-nums; }
.finder-mres { display: none; }
@media (max-width: 1000px) { .finder-res { position: static; } .finder-res .list { max-height: none; } }
@media (max-width: 860px) {
  .finder-qtext { font-size: 18px; }
  .finder-keys { display: none; }
  .seg.finder-big kbd { display: none; }
  .finder-card .card-b { padding: 18px 16px 14px; }
  .finder-mres { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
  .finder-mres span { margin-left: auto; color: var(--accent); }
  .finder-nav .grow { display: none; }
  #fNoRest { flex-basis: 100%; }
}

/* Permit Finder: search + collapsible categories */
.finder-search { position: relative; margin-bottom: 12px; }
.finder-search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 18px; height: 18px; pointer-events: none; }
.finder-search input { width: 100%; box-sizing: border-box; min-height: 44px; padding: 10px 14px 10px 40px; font-size: 15px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); }
.finder-search input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
#fMain mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }
.finder-sr-meta { margin-top: 6px; color: var(--text-2); }
.finder-sr-meta .tag { margin-right: 4px; }
.finder-cat { border-top: 1px solid var(--border); }
.finder-cat > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; background: var(--surface-2); user-select: none; }
.finder-cat > summary::-webkit-details-marker { display: none; }
.finder-cat > summary:hover { background: var(--surface-3); }
.finder-cat > summary .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.finder-cat > summary .chev { width: 16px; height: 16px; color: var(--text-3); transition: transform .15s; flex: none; }
.finder-cat[open] > summary .chev { transform: rotate(90deg); }
.finder-cat[open] > summary { border-bottom: 1px solid var(--border); }
.finder-cat-n { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
.finder-cat-n.done { color: #0ca30c; border-color: #b8e3b8; }
.finder-cat-n .icon { width: 13px; height: 13px; }
.finder-cat-f { padding: 10px 16px 14px; }
.card-h .right .btn + .btn { margin-left: 4px; }
[data-theme="dark"] #fMain mark { background: #7a5b00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #fMain mark { background: #7a5b00; } }

/* Documents: attachments, upload tray, Document Library */
.clamp1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; }
.doc-drop { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border: 2px dashed var(--border-strong); border-radius: 12px; padding: 16px 18px; background: var(--surface-2); transition: border-color .12s, background .12s; }
.doc-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.doc-drop .ico { width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.doc-drop .grow { flex: 1 1 260px; min-width: 0; }
.doc-drop .doc-cat { margin: 0; flex: 0 1 230px; }
.doc-list { border-top: 1px solid var(--border); }
.doc-group-h { padding: 10px 16px 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); display: flex; gap: 6px; align-items: center; }
.doc-group-h .n { background: var(--surface-3); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.doc-row .grow { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; color: var(--text); text-decoration: none; word-break: break-word; }
.doc-name:hover { color: var(--accent); text-decoration: underline; }
.doc-cat-sel { max-width: 190px; font-size: 13px; padding: 5px 8px; }
.doc-acts { display: flex; gap: 2px; flex: none; }
.doc-ico { flex: none; width: 40px; height: 44px; border-radius: 6px; display: grid; place-items: end center; padding-bottom: 6px; box-sizing: border-box; font: 700 9.5px/1 ui-monospace, monospace; color: #fff; background: #6b7785; clip-path: polygon(0 0, 72% 0, 100% 22%, 100% 100%, 0 100%); }
.doc-ico.k-pdf { background: #d03b3b; } .doc-ico.k-cad { background: #0e7fa3; } .doc-ico.k-img { background: #8a5cc2; } .doc-ico.k-xls { background: #1f8a4c; }
.doc-ico.k-doc { background: #2a62c9; } .doc-ico.k-mail { background: #c47a12; } .doc-ico.k-zip { background: #5b4636; } .doc-ico.k-ppt { background: #d0602e; }
.doc-toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.doc-crumbs { margin: 4px 0 12px; }
.doc-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.doc-tree { padding: 8px; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; font-size: 13.5px; }
.doc-tree details { margin-left: 10px; }
.doc-tree > details { margin-left: 0; }
.doc-tree summary { list-style: none; display: flex; align-items: center; gap: 4px; cursor: pointer; border-radius: 6px; }
.doc-tree summary::-webkit-details-marker { display: none; }
.doc-tree summary::before { content: '▸'; width: 12px; color: var(--text-3); font-size: 11px; flex: none; transition: transform .12s; }
.doc-tree details[open] > summary::before { transform: rotate(90deg); }
.doc-tree a { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; padding: 5px 6px; border-radius: 6px; color: var(--text); text-decoration: none; }
.doc-tree a .icon { width: 15px; height: 15px; color: var(--text-3); }
.doc-tree a:hover { background: var(--surface-2); }
.doc-tree a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.doc-tree .leaf { margin-left: 26px; }
.doc-tree .n { font-size: 11.5px; color: var(--text-3); padding: 0 6px; font-variant-numeric: tabular-nums; }
.doc-folders { display: flex; flex-direction: column; }
.doc-folder { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.doc-folder:last-child { border-bottom: 0; }
.doc-folder:hover { background: var(--surface-2); }
.doc-folder > .icon:first-child { width: 22px; height: 22px; color: var(--accent); }
.doc-folder .grow { flex: 1; min-width: 0; }
.upload-tray { position: fixed; right: 16px; bottom: 16px; width: 380px; max-width: calc(100vw - 32px); max-height: 50vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 60; overflow: hidden; }
.ut-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ut-h b { flex: 1; }
.ut-list { overflow: auto; }
.ut-row { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.ut-row:last-child { border-bottom: 0; }
.ut-name { display: flex; align-items: center; gap: 10px; }
.ut-name .grow { flex: 1; min-width: 0; font-size: 13px; }
.ut-name .doc-ico { width: 30px; height: 34px; font-size: 8px; }
.ut-bar { height: 4px; background: var(--surface-3); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.ut-bar span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.ut-ok { color: var(--good); }
.ut-row.error { background: var(--critical-bg); }
@media (max-width: 1000px) { .doc-layout { grid-template-columns: minmax(0, 1fr); } .doc-tree { display: none; } }
@media (max-width: 860px) {
  .doc-row { flex-wrap: wrap; }
  .doc-row .grow { flex-basis: calc(100% - 60px); }
  .doc-cat-sel { margin-left: 52px; flex: 1; max-width: none; }
  .upload-tray { bottom: 76px; right: 8px; left: 8px; width: auto; max-width: none; }
}

/* Multi-permit plan Gantt */
.pg { --pg-label: 250px; font-size: 13px; }
.pg-row { display: grid; grid-template-columns: var(--pg-label) minmax(0, 1fr); gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.pg-row:last-of-type { border-bottom: 0; }
.pg-row.late .pg-label b { color: var(--critical); }
.pg-label { min-width: 0; }
.pg-label .pg-del { margin-left: auto; padding: 2px 4px; opacity: .6; }
.pg-label .pg-del:hover { opacity: 1; }
.pg-track { position: relative; height: 30px; background: var(--surface-2); border-radius: 6px; }
.pg-seg { top: 4px; bottom: 4px; font-size: 10.5px; padding: 0 5px; border-radius: 4px; }
.pg-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); }
.pg-today { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--critical); z-index: 2; }
.pg-start { position: absolute; top: 50%; width: 12px; height: 12px; background: var(--text); transform: translate(-50%, -50%) rotate(45deg); border: 2px solid var(--surface); border-radius: 2px; z-index: 3; }
.pg-axis { border-bottom: 1px solid var(--border-strong); padding-bottom: 4px; }
.pg-ticks { background: none; height: 20px; }
.pg-tick { position: absolute; top: 2px; transform: translateX(-50%); font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pg-tick.today { color: var(--critical); font-weight: 700; top: 2px; background: var(--surface); padding: 0 3px; z-index: 2; }
.pg-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--text-2); }
.pg-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pg-legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.pg-legend .pg-start-key { width: 9px; height: 9px; background: var(--text); transform: rotate(45deg); border-radius: 1px; }
.pg-legend .pg-today-key { width: 2px; height: 14px; background: var(--critical); border-radius: 0; }
.pg-tick.near-today { visibility: hidden; }
@media (max-width: 860px) {
  .pg-tick.minor, .pg-tick.near-today-m { visibility: hidden; }
  .pg-row { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 8px 0; }
  .pg-axis .pg-label { display: none; }
}

.pg-row.flash { animation: pgFlash 2.2s ease-out; border-radius: 8px; }
@keyframes pgFlash { 0%, 40% { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); } 100% { background: transparent; box-shadow: none; } }

/* ---------------- Usability layer (ux.js) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gl { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 3px; padding: 0; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-3); font: 700 11px/1 inherit; cursor: help; vertical-align: 1px; }
.gl:hover, .gl[aria-expanded] { background: var(--accent); border-color: var(--accent); color: #fff; }
.gl-pop { position: absolute; z-index: 90; background: var(--text); color: var(--surface); border-radius: 10px; padding: 11px 13px; font-size: 13px; line-height: 1.45; box-shadow: var(--shadow-lg); }
.gl-pop b { display: block; margin-bottom: 3px; }
.gl-pop a { color: inherit; opacity: .8; font-size: 12px; display: inline-block; margin-top: 6px; }
.help-btn { gap: 6px; }
.help-q-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.8px solid currentColor; font-weight: 800; font-size: 12px; }
.help-wrap { position: fixed; inset: 0; z-index: 80; }
.help-back { position: absolute; inset: 0; background: rgba(15, 27, 36, .35); opacity: 0; transition: opacity .2s; }
.help-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s ease-out; }
.help-wrap.open .help-back { opacity: 1; }
.help-wrap.open .help-panel { transform: none; }
.help-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.help-h h2 { margin: 0; }
.help-b { overflow: auto; padding: 16px 18px 40px; }
.help-b h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 22px 0 10px; }
.help-tasks { display: flex; flex-direction: column; gap: 8px; }
.help-task { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; }
.help-task:hover { border-color: var(--accent); background: var(--surface-2); }
.help-task .icon { color: var(--accent); margin-top: 2px; }
.help-task b { display: block; font-size: 14px; }
.help-task span { font-size: 13px; color: var(--text-2); }
.help-q { width: 100%; box-sizing: border-box; margin-bottom: 8px; }
.help-gloss { margin: 0; }
.help-gloss div { padding: 8px 0; border-bottom: 1px solid var(--border); }
.help-gloss dt { font-weight: 700; font-size: 14px; }
.help-gloss dd { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.help-keys td { padding: 5px 10px 5px 0; font-size: 13px; }
.help-keys kbd { font: 600 12px ui-monospace, monospace; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; background: var(--surface-2); }
.tour { position: fixed; inset: 0; z-index: 95; }
.tour-hole { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10, 22, 32, .55); outline: 3px solid var(--accent); transition: all .25s ease; pointer-events: none; }
.tour-card { position: fixed; background: var(--surface); color: var(--text); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow-lg); transition: top .25s, left .25s; }
.tour-card h3 { margin: 4px 0 6px; font-size: 17px; }
.tour-card p { margin: 0 0 12px; font-size: 14px; color: var(--text-2); line-height: 1.5; }
.gs-bar { height: 5px; background: var(--surface-3); }
.gs-bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.gs-list { list-style: none; margin: 0; padding: 6px 0; }
.gs-list li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.gs-list li.done { opacity: .6; }
.gs-list li.done b { text-decoration: line-through; }
.gs-list li.next { background: var(--accent-soft); }
.gs-list .grow { flex: 1; min-width: 0; }
.gs-dot { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; border: 2px solid var(--border-strong); color: var(--text-2); }
.gs-list li.done .gs-dot { background: var(--good); border-color: var(--good); color: #fff; }
.gs-list li.done .gs-dot .icon { width: 14px; height: 14px; }
.gs-list li.next .gs-dot { border-color: var(--accent); color: var(--accent); }
.lc { display: flex; align-items: stretch; gap: 0; margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 10px; flex-wrap: wrap; row-gap: 10px; }
.lc-step { flex: 1 1 0; min-width: 110px; position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; background: none; border: 0; padding: 4px 6px; cursor: pointer; color: var(--text-2); border-radius: 8px; font: inherit; }
.lc-step:hover { background: var(--surface-2); }
.lc-step::before { content: ''; position: absolute; top: 17px; left: calc(-50% + 16px); right: calc(50% + 16px); height: 3px; background: var(--border); border-radius: 2px; }
.lc-step:first-of-type::before { display: none; }
.lc-step.done::before, .lc-step.current::before, .lc-step.problem::before { background: var(--accent); }
.lc-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; border: 2px solid var(--border-strong); background: var(--surface); position: relative; z-index: 1; }
.lc-dot .icon { width: 15px; height: 15px; }
.lc-step.done .lc-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.lc-step.current .lc-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.lc-step.problem .lc-dot { border-color: var(--critical); background: var(--critical); color: #fff; box-shadow: 0 0 0 4px var(--critical-bg); }
.lc-t { font-weight: 650; font-size: 13px; color: var(--text); }
.lc-step.current .lc-t { color: var(--accent); }
.lc-step.problem .lc-t, .lc-step.problem .lc-s { color: var(--critical); }
.lc-s { font-size: 11.5px; color: var(--text-3); min-height: 1em; }
.lc-next { align-self: center; margin-left: 8px; }
.lc.closed .lc-step { opacity: .55; }
.lc-closed { align-self: center; font-weight: 700; color: var(--text-2); padding: 0 12px; }
.row-acts { width: 44px; text-align: right; }
.ra-btn { font-size: 18px; line-height: 1; letter-spacing: 1px; padding: 4px 8px; }
.ra-menu { position: absolute; z-index: 70; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; display: flex; flex-direction: column; }
.ra-menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 7px; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; }
.ra-menu button:hover, .ra-menu button:focus { background: var(--surface-2); outline: none; }
.ra-menu button.danger { color: var(--critical); }
.ra-menu .icon { width: 16px; height: 16px; }
.toast-act { display: flex; align-items: center; gap: 12px; }
.toast-act .btn { background: rgba(255,255,255,.15); color: inherit; border-color: rgba(255,255,255,.3); }
.tp { position: relative; }
.tp input { width: 100%; }
.tp-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 75; max-height: 300px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.tp-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 14px; }
.tp-item:last-child { border-bottom: 0; }
.tp-item.on, .tp-item:hover { background: var(--accent-soft); }
.tp-item mark { background: #fde68a; color: inherit; border-radius: 2px; }
.tp-foot { padding: 8px 12px; }
.np-type { margin-bottom: 14px; }
.np-type input { font-size: 16px; min-height: 46px; }
.np-lib { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; }
.np-more { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.np-more summary { cursor: pointer; font-weight: 650; }
@media (max-width: 860px) {
  .help-btn .btn-label { display: none; }
  .lc-step { min-width: 0; flex-basis: 20%; padding: 4px 2px; }
  .lc-s { display: none; }
  .lc-t { font-size: 11px; }
  .lc-next { width: 100%; margin: 4px 0 0; justify-content: center; }
  .row-acts { position: absolute; top: 8px; right: 8px; width: auto; }
  .stack-table tr { position: relative; }
}

label.field .lbl { display: inline-flex; align-items: center; gap: 2px; }
@media (max-width: 860px) { #stepBtn { display: none; } }

/* Forms & Guides */
.fg-list { display: flex; flex-direction: column; }
.fg-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-top: 1px solid var(--border); }
.fg-row:first-child { border-top: 0; }
.fg-ico { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.fg-ico .icon { width: 17px; height: 17px; }
.fg-row .grow { flex: 1; min-width: 0; }
.fg-title { font-weight: 650; }
.fg-title a { color: var(--text); text-decoration: none; }
.fg-title a:hover { color: var(--accent); text-decoration: underline; }
.fg-sum { font-size: 13.5px; color: var(--text-2); margin-top: 4px; line-height: 1.45; }
.fg-key { margin-top: 6px; font-size: 13px; }
.fg-key summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.fg-key ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-2); }
.fg-snips { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.fg-snips mark, .fg-row mark { background: #fde68a; color: inherit; border-radius: 2px; }
.fg-lib { margin-top: 5px; color: var(--text-3); }
.fg-acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; flex: none; }
.fg-note { padding: 10px 16px 14px; }
.fg-card { margin-top: 16px; }
.fg-group { margin-bottom: 12px; }
.fg-group > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 13px 16px; cursor: pointer; }
.fg-group > summary::-webkit-details-marker { display: none; }
.fg-group[open] > summary { border-bottom: 1px solid var(--border); }
@media (max-width: 860px) {
  .fg-row { flex-wrap: wrap; }
  .fg-acts { flex-direction: row; flex-wrap: wrap; width: 100%; padding-left: 46px; }
}

.doc-toolbar select { width: auto; max-width: 240px; }
@media (max-width: 860px) { .doc-toolbar select { flex: 1 1 45%; max-width: none; } }

/* links to referenced documents */
a.doclink { color: inherit; text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a.doclink:hover { color: var(--accent); text-decoration-style: solid; }
a.doclink::after { content: '↗'; font-size: .75em; margin-left: 2px; color: var(--accent); }

/* ---------- plans, billing and shared workspaces ---------- */
#planBanner:empty { display: none; }
#planBanner { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.plan-banner { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
.plan-banner .icon { flex: 0 0 auto; margin-top: 2px; }
.seg { display: inline-flex; gap: 2px; background: var(--surface-3); padding: 3px; border-radius: 8px; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.meter .bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.meter .bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.warn .bar i { background: #e0a100; }
.meter.critical .bar i { background: var(--critical); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.plan-card.cur { border: 2px solid var(--accent); }
.plan-card .price { font-size: 22px; font-weight: 750; }
.plan-card .price small { font-size: 12px; font-weight: 500; color: var(--text-2); }
.plan-card .btn { margin-top: auto; justify-content: center; }
.org-switch { width: 100%; margin-top: 6px; }
body.ro #newPermitBtn, body.ro #bnNew { display: none; }
