/* BEM GRC Prototype v2.0 - clean, minimal, Google-like. Primary: blue. */
:root {
  --primary: #1e293b;
  --primary-hover: #0f172a;
  --primary-container: #e2e8f0;
  --on-primary-container: #0f172a;
  --bg: #f8fafd;
  --surface: #ffffff;
  --surface-2: #f0f4f9;
  --surface-3: #e9eef6;
  --outline: #c4c7c5;
  --outline-variant: #e1e3e1;
  --text: #1f1f1f;
  --text-2: #444746;
  --text-3: #747775;
  --low-bg: #e6f4ea; --low-fg: #137333; --low-dot: #1e8e3e;
  --med-bg: #fef7e0; --med-fg: #8a6100; --med-dot: #f9ab00;
  --high-bg: #feefe3; --high-fg: #b3540a; --high-dot: #fa7b17;
  --vh-bg: #fce8e6; --vh-fg: #c5221f; --vh-dot: #d93025;
  --g: #1e293b; --r: #f9ab00; --c: #1e8e3e;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --font: "Google Sans Text", "Google Sans", Roboto, "Noto Sans Thai", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; color: var(--text); }
h1 { font-size: 24px; line-height: 32px; }
h2 { font-size: 18px; line-height: 24px; }
h3 { font-size: 15px; line-height: 22px; }
p { margin: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13px; }
.icon { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 20px; line-height: 1;
  display: inline-block; vertical-align: middle; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; user-select: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- App shell ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: 64px; background: var(--bg); display: flex; align-items: center; gap: 12px; padding: 0 16px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 232px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.brand-name { font-size: 20px; font-weight: 500; }
.brand-name span { color: var(--text-3); font-weight: 400; }
.search { flex: 1; max-width: 720px; position: relative; }
.search input { width: 100%; height: 48px; border: 0; border-radius: 24px; background: var(--surface-3); padding: 0 20px 0 52px; font: inherit; font-size: 16px; color: var(--text); }
.search input:focus { background: var(--surface); box-shadow: var(--shadow); outline: none; }
.search .icon { position: absolute; left: 16px; top: 14px; color: var(--text-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.role-chip { height: 32px; padding: 0 12px; border-radius: 8px; background: var(--primary-container); color: var(--on-primary-container); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #1e293b; color: #fff; display: grid; place-items: center; font-weight: 500; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(68,71,70,.08); }
.menu-btn { display: none; }

.nav { position: fixed; top: 64px; bottom: 0; left: 0; width: 256px; padding: 8px 12px; overflow-y: auto; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.nav a { height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-radius: 24px; color: var(--text-2); font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(68,71,70,.08); text-decoration: none; }
.nav a.active { background: var(--primary-container); color: var(--on-primary-container); }
.nav a.active .icon { font-variation-settings: "FILL" 1; }
.nav .nav-label { font-size: 12px; color: var(--text-3); padding: 16px 16px 6px; font-weight: 500; }
.nav-foot { margin-top: auto; padding: 12px 16px; font-size: 12px; color: var(--text-3); }
.main { margin-left: 256px; padding: 80px 32px 48px 24px; min-height: 100vh; }
.container { max-width: 1280px; margin: 0 auto; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 24px; flex-wrap: wrap; }
.page-head p { color: var(--text-3); margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Cards and grid ---------- */
.card { background: var(--surface); border: 1px solid var(--outline-variant); border-radius: var(--radius); padding: 20px 24px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head p { color: var(--text-3); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-5-7 { grid-template-columns: 5fr 7fr; }
.g-intake { grid-template-columns: minmax(360px, 420px) minmax(0, 1fr); }
.mt { margin-top: 16px; }
.mt-l { margin-top: 24px; }

.kpi { padding: 20px 24px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi-value { font-size: 40px; line-height: 48px; font-weight: 400; }
.kpi-sub { font-size: 13px; color: var(--text-3); }
.kpi-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); }
.kpi.alert .kpi-icon { background: var(--vh-bg); color: var(--vh-fg); }
.kpi.warn .kpi-icon { background: var(--high-bg); color: var(--high-fg); }
.trend-up { color: var(--vh-fg); } .trend-down { color: var(--low-fg); }
.gauge { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.gauge::after { content: attr(data-v); width: 56px; height: 56px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 500; font-size: 15px; }

/* ---------- Buttons, chips, inputs ---------- */
.btn { height: 40px; padding: 0 24px; border-radius: 20px; border: 0; font: inherit; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none !important; }
.btn .icon { font-size: 18px; }
.btn-filled { background: var(--primary); color: #fff; }
.btn-filled:hover { background: var(--primary-hover); box-shadow: var(--shadow); }
.btn-tonal { background: var(--primary-container); color: var(--on-primary-container); }
.btn-tonal:hover { box-shadow: var(--shadow); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--outline); }
.btn-outline:hover { background: rgba(11,87,208,.08); }
.btn-text { background: transparent; color: var(--primary); padding: 0 12px; }
.btn-text:hover { background: rgba(11,87,208,.08); }
.btn-danger { background: transparent; color: var(--vh-fg); border: 1px solid var(--outline); }
.btn-danger:hover { background: var(--vh-bg); }
.btn-sm { height: 32px; padding: 0 16px; font-size: 13px; }
.btn[disabled] { opacity: .4; cursor: default; }

.chip { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--outline); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--primary-container); border-color: transparent; color: var(--on-primary-container); }
.chip select { border: 0; background: transparent; font: inherit; color: inherit; cursor: pointer; padding-right: 2px; }
.chip select:focus { outline: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tag.blue { background: var(--primary-container); color: var(--on-primary-container); }
.tag.warn { background: var(--high-bg); color: var(--high-fg); }
.tag.red { background: var(--vh-bg); color: var(--vh-fg); }
.tag.green { background: var(--low-bg); color: var(--low-fg); }
.tag.yellow { background: var(--med-bg); color: var(--med-fg); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.input, .select, .textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius-sm); padding: 10px 14px; min-height: 44px; }
.textarea { resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.hint { font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Level badges ---------- */
.lvl { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.lvl::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.lvl.low { background: var(--low-bg); color: var(--low-fg); } .lvl.low::before { background: var(--low-dot); }
.lvl.medium { background: var(--med-bg); color: var(--med-fg); } .lvl.medium::before { background: var(--med-dot); }
.lvl.high { background: var(--high-bg); color: var(--high-fg); } .lvl.high::before { background: var(--high-dot); }
.lvl.veryhigh { background: var(--vh-bg); color: var(--vh-fg); } .lvl.veryhigh::before { background: var(--vh-dot); }
.lvl.none { background: var(--surface-2); color: var(--text-3); } .lvl.none::before { background: var(--outline); }
.lvl.lg { height: 32px; font-size: 14px; padding: 0 14px 0 12px; border-radius: 16px; }
.rag { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13px; white-space: nowrap; }
.rag::before { content: ""; width: 10px; height: 10px; border-radius: 50%; }
.rag.red { color: var(--vh-fg); } .rag.red::before { background: var(--vh-dot); }
.rag.amber { color: var(--med-fg); } .rag.amber::before { background: var(--med-dot); }
.rag.green { color: var(--low-fg); } .rag.green::before { background: var(--low-dot); }
.rag.nodata, .rag.nothreshold { color: var(--text-3); } .rag.nodata::before, .rag.nothreshold::before { background: transparent; border: 2px dashed var(--outline); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -24px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--outline-variant); white-space: nowrap; }
.t td { padding: 12px; border-bottom: 1px solid var(--outline-variant); vertical-align: top; }
.t th:first-child, .t td:first-child { padding-left: 24px; }
.t th:last-child, .t td:last-child { padding-right: 24px; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--surface-2); }
.t .clamp { min-width: 220px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 460px; }
.t td.mono { white-space: nowrap; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px 16px; color: var(--text-3); }
.empty .icon { font-size: 40px; display: block; margin: 0 auto 8px; color: var(--outline); }

/* ---------- Heatmap ---------- */
.heat { display: grid; grid-template-columns: 72px repeat(5, minmax(0, 1fr)); gap: 4px; }
.heat .ylab, .heat .xlab { font-size: 11px; color: var(--text-3); display: flex; align-items: center; }
.heat .ylab { justify-content: flex-end; padding-right: 8px; text-align: right; }
.heat .xlab { justify-content: center; text-align: center; padding-top: 4px; }
.cell { aspect-ratio: 1.6; border-radius: 8px; border: 0; font: inherit; font-size: 18px; font-weight: 500; cursor: pointer; display: grid; place-items: center; transition: transform .12s, box-shadow .12s; }
.cell:hover { transform: scale(1.04); box-shadow: var(--shadow); }
.cell.low { background: var(--low-bg); color: var(--low-fg); }
.cell.medium { background: var(--med-bg); color: var(--med-fg); }
.cell.high { background: var(--high-bg); color: var(--high-fg); }
.cell.veryhigh { background: var(--vh-bg); color: var(--vh-fg); }
.cell.zero { color: transparent; }
.cell.static { cursor: default; font-size: 12px; }
.cell.static:hover { transform: none; box-shadow: none; }
.axis-title { font-size: 12px; color: var(--text-2); font-weight: 500; text-align: center; margin-top: 6px; }
.seg { display: inline-flex; border: 1px solid var(--outline); border-radius: 20px; overflow: hidden; }
.seg button { height: 32px; padding: 0 14px; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--outline); }
.seg button.on { background: var(--primary-container); color: var(--on-primary-container); }

/* ---------- Bars ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 210px 1fr 36px; gap: 12px; align-items: center; cursor: pointer; border-radius: 8px; padding: 2px 4px; }
.bar-row:hover { background: var(--surface-2); }
.bar-label { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; display: flex; }
.bar-seg.G { background: var(--g); } .bar-seg.R { background: var(--r); } .bar-seg.C { background: var(--c); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Early warning ---------- */
.warn-list { display: flex; flex-direction: column; }
.warn-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--outline-variant); align-items: flex-start; cursor: pointer; }
.warn-item:last-child { border-bottom: 0; }
.warn-item .icon { color: var(--vh-fg); margin-top: 2px; }
.warn-item:hover .warn-text { color: var(--primary); }
.warn-text { font-weight: 500; }

/* ---------- Side sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.sheet .scrim { position: absolute; inset: 0; background: rgba(0,0,0,.32); opacity: 0; transition: opacity .2s; }
.sheet-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(600px, 100%); background: var(--surface); box-shadow: -4px 0 24px rgba(0,0,0,.12); transform: translateX(100%); transition: transform .25s cubic-bezier(.2,0,0,1); display: flex; flex-direction: column; border-radius: 16px 0 0 16px; }
.sheet.open { pointer-events: auto; }
.sheet.open .scrim { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-top { display: flex; align-items: center; justify-content: flex-end; padding: 8px 12px 0; }
.sheet-body { padding: 0 28px 32px; overflow-y: auto; flex: 1; }
.sec { padding: 20px 0; border-bottom: 1px solid var(--outline-variant); }
.sec:last-child { border-bottom: 0; }
.sec-title { font-size: 12px; font-weight: 500; color: var(--text-3); margin-bottom: 10px; letter-spacing: .2px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; }
.quote { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; white-space: pre-wrap; line-height: 1.7; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); }
.steps li { margin-bottom: 4px; }
.conf { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; width: 120px; display: inline-block; vertical-align: middle; }
.conf > span { display: block; height: 100%; background: var(--primary); }
.conf.lowc > span { background: var(--high-dot); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.notice .icon { color: var(--primary); }
.notice.warn { background: var(--med-bg); color: #5f4400; }
.notice.warn .icon { color: var(--med-fg); }
.notice.red { background: var(--vh-bg); color: #8c1d18; }
.notice.red .icon { color: var(--vh-fg); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--outline-variant); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.list-plain li:last-child { border-bottom: 0; }

/* ---------- Result card ---------- */
.result { margin-top: 16px; border: 1px solid var(--primary-container); background: #f8fafc; border-radius: var(--radius); padding: 18px 20px; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tc-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tc-chips .chip { height: 28px; font-size: 12px; }

/* ---------- Snackbar ---------- */
#snackbar { position: fixed; left: 24px; bottom: 24px; background: #303030; color: #f2f2f2; padding: 14px 20px; border-radius: 8px; box-shadow: var(--shadow); font-size: 14px; max-width: 520px; transform: translateY(120px); opacity: 0; transition: all .25s; z-index: 70; }
#snackbar.show { transform: none; opacity: 1; }
#snackbar.err { background: #8c1d18; }

/* ---------- Report ---------- */
.doc { max-width: 860px; }
.doc h1 { font-size: 22px; margin-bottom: 8px; }
.doc h2 { font-size: 17px; margin: 24px 0 8px; color: var(--primary); }
.doc p, .doc li { line-height: 1.7; }
.doc table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 8px 0; }
.doc th, .doc td { border: 1px solid var(--outline-variant); padding: 6px 8px; text-align: left; vertical-align: top; }
.doc th { background: var(--surface-2); font-weight: 500; }
.doc blockquote { margin: 8px 0; padding: 8px 14px; border-left: 3px solid var(--med-dot); background: var(--med-bg); border-radius: 0 8px 8px 0; }
.editor { font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13px; min-height: 60vh; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(448px, 100%); background: var(--surface); border: 1px solid var(--outline-variant); border-radius: 28px; padding: 40px; }
.login-card h1 { font-size: 28px; font-weight: 400; margin: 20px 0 8px; }
.demo-users { margin-top: 24px; font-size: 13px; }
.demo-users button { all: unset; cursor: pointer; display: flex; justify-content: space-between; width: 100%; padding: 8px 12px; border-radius: 8px; box-sizing: border-box; }
.demo-users button:hover { background: var(--surface-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-5-7, .g-2, .split, .g-intake { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn { display: grid; }
  .brand { min-width: 0; }
  .brand-name span, .role-chip { display: none; }
  .search input { height: 40px; font-size: 14px; }
  .search .icon { top: 10px; }
  .nav { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); background: var(--surface); }
  .nav.open { transform: none; }
  .main { margin-left: 0; padding: 76px 16px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 120px 1fr 28px; }
  .kpi-value { font-size: 32px; }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; }
  .sheet-body { padding: 0 18px 24px; }
}
@media print {
  .topbar, .nav, .no-print, #snackbar, .sheet { display: none !important; }
  .main { margin: 0; padding: 0; }
  .card { border: 0; padding: 0; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Risk register v2 */
.lvl-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.lvl-tile { all: unset; box-sizing: border-box; cursor: pointer; border-radius: 16px; padding: 14px 18px; display: flex; align-items: baseline; gap: 10px; border: 1px solid transparent; transition: box-shadow .15s; }
.lvl-tile:hover { box-shadow: var(--shadow); }
.lvl-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.lvl-tile.sel { border-color: currentColor; }
.lvl-tile.low { background: var(--low-bg); color: var(--low-fg); } .lvl-tile.medium { background: var(--med-bg); color: var(--med-fg); }
.lvl-tile.high { background: var(--high-bg); color: var(--high-fg); } .lvl-tile.veryhigh { background: var(--vh-bg); color: var(--vh-fg); }
.lt-n { font-size: 32px; line-height: 1; font-weight: 400; } .lt-l { font-weight: 500; }
.risk-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.risk-side { position: sticky; top: 80px; }
.heat-sm { grid-template-columns: 52px repeat(5, minmax(0, 1fr)); }
.heat-sm .xlab { font-size: 10px; }
.heat-sm .cell { aspect-ratio: 1; font-size: 15px; }
.cell.sel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.rlist { display: flex; flex-direction: column; margin: 0 -24px; }
.rrow { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 4px minmax(0, 1fr) 220px 140px 20px; gap: 16px; align-items: center; padding: 14px 24px 14px 20px; border-top: 1px solid var(--outline-variant); }
.rrow:hover { background: var(--surface-2); }
.rrow:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.rbar { width: 4px; align-self: stretch; border-radius: 2px; }
.rbar.low { background: var(--low-dot); } .rbar.medium { background: var(--med-dot); } .rbar.high { background: var(--high-dot); } .rbar.veryhigh { background: var(--vh-dot); }
.rmain { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rtitle { font-weight: 500; line-height: 1.45; }
.rmeta { font-size: 12px; color: var(--text-3); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.rlevel { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.rapp { white-space: nowrap; }
.rcount { display: flex; gap: 12px; color: var(--text-2); font-size: 13px; }
.rcount > span { display: inline-flex; align-items: center; gap: 3px; position: relative; }
.rcount .icon { font-size: 17px; color: var(--text-3); }
.rcount .dot { position: absolute; top: -2px; right: -7px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
@media (max-width: 1100px) { .risk-layout { grid-template-columns: 1fr; } .risk-side { position: static; } }
@media (max-width: 760px) {
  .lvl-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rrow { grid-template-columns: 4px minmax(0, 1fr) 20px; row-gap: 8px; }
  .rlevel, .rcount { grid-column: 2; }
}

[hidden] { display: none !important; }
.brand-name { white-space: nowrap; }
@media (max-width: 860px) { .search { display: none; } .topbar-right { margin-left: auto; } }

/* Policy library */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.doc-card { all: unset; box-sizing: border-box; cursor: pointer; background: var(--surface); border: 1px solid var(--outline-variant); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s, border-color .15s; }
.doc-card:hover { box-shadow: var(--shadow); border-color: transparent; }
.doc-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.doc-title { font-size: 15px; font-weight: 500; line-height: 1.5; }
.doc-sum { color: var(--text-2); font-size: 13px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.doc-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--outline-variant); display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.doc-foot .icon { color: var(--primary); }
.doc-sec { border: 1px solid var(--outline-variant); border-radius: 12px; padding: 0 16px; margin-bottom: 8px; }
.doc-sec summary { cursor: pointer; padding: 12px 0; font-weight: 500; }
.doc-sec p { margin: 0 0 14px; color: var(--text-2); line-height: 1.7; }
@media (max-width: 520px) { .doc-grid { grid-template-columns: 1fr; } }

/* Factsheet (formal knowledge-base view) */
.fs-crumb { margin: 4px 0 16px; font-size: 13px; }
.fs-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: start; }
.fs { background: var(--surface); border: 1px solid var(--outline-variant); border-radius: 16px; padding: 0 48px 40px; max-width: 900px; }
.fs-head { padding-bottom: 24px; border-bottom: 1px solid var(--outline-variant); }
.fs-band { display: flex; justify-content: space-between; margin: 0 -48px 28px; padding: 12px 48px; background: #1e293b; color: #fff; border-radius: 16px 16px 0 0; font-size: 13px; font-weight: 500; letter-spacing: .3px; }
.fs-type { color: var(--primary); font-weight: 500; font-size: 13px; }
.fs-title { font-size: 26px; line-height: 1.45; font-weight: 500; margin-top: 6px; }
.fs section { padding-top: 28px; scroll-margin-top: 80px; }
.fs h2 { font-size: 17px; font-weight: 600; color: var(--text); padding-bottom: 8px; border-bottom: 2px solid var(--primary-container); margin-bottom: 12px; }
.fs h3 { font-size: 15px; font-weight: 600; margin: 16px 0 4px; }
.fs p, .fs li { line-height: 1.85; color: #303134; font-size: 15px; }
.fs-ol, .fs-ul { margin: 0; padding-left: 22px; } .fs-ol li, .fs-ul li { margin-bottom: 6px; }
.fs-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fs-table th { width: 200px; text-align: left; font-weight: 500; color: var(--text-2); background: var(--surface-2); }
.fs-table th, .fs-table td { border: 1px solid var(--outline-variant); padding: 10px 14px; vertical-align: top; }
.fs-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--outline-variant); font-size: 12px; color: var(--text-3); line-height: 1.7; }
.fs-side { position: sticky; top: 80px; }
.fs-toc { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; }
.fs-toc:hover { background: var(--surface-2); text-decoration: none; }
@media (max-width: 1100px) { .fs-layout { grid-template-columns: 1fr; } .fs-side { display: none; } }
@media (max-width: 600px) { .fs { padding: 0 20px 28px; } .fs-band { margin: 0 -20px 20px; padding: 10px 20px; } .fs-title { font-size: 21px; } .fs-table th { width: 120px; } }

/* Library: full-width list cards */
.doc-grid { grid-template-columns: 1fr !important; gap: 12px; }
.doc-card { display: grid !important; grid-template-columns: minmax(0, 1fr) 220px 24px; gap: 24px; align-items: center; padding: 20px 24px; }
.doc-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.doc-card .doc-sum { -webkit-line-clamp: 2; }
.doc-side { display: flex; flex-direction: column; align-items: flex-start; padding-left: 24px; border-left: 1px solid var(--outline-variant); }
.doc-side-n { font-size: 24px; font-weight: 500; color: var(--text); line-height: 1.2; }
.doc-chev { font-size: 22px; }
@media (max-width: 760px) { .doc-card { grid-template-columns: minmax(0, 1fr) 20px; } .doc-side { grid-column: 1; grid-row: 2; border-left: 0; padding: 12px 0 0; border-top: 1px solid var(--outline-variant); width: 100%; } .doc-chev { grid-column: 2; grid-row: 1; } }

/* KRI v2 */
.kri-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--outline-variant); overflow-x: auto; }
.kri-tab { all: unset; cursor: pointer; padding: 12px 18px; display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.kri-tab b { font-weight: 500; background: var(--surface-2); border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.kri-tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.kri-tab.on b { background: var(--primary-container); color: var(--on-primary-container); }
.kri-tab:hover { background: var(--surface-2); }
.kri-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.kri-tab .rag::before { margin: 0; }
.kri-group + .kri-group { margin-top: 16px; }
.kri-row { grid-template-columns: 4px minmax(0, 1fr) 170px 220px 20px !important; }
.kri-val { display: flex; flex-direction: column; } .kri-val b { font-size: 18px; font-weight: 500; }
.kri-hero { display: grid; grid-template-columns: 1.2fr 1fr 1.4fr; gap: 16px; background: var(--surface-2); border-radius: 16px; padding: 16px 20px; }
.kri-big { font-size: 34px; line-height: 1.2; } .kri-big span { font-size: 15px; color: var(--text-3); }
@media (max-width: 760px) { .kri-row { grid-template-columns: 4px minmax(0, 1fr) 20px !important; } .kri-row > span:nth-child(3), .kri-row > span:nth-child(4) { grid-column: 2; } .kri-hero { grid-template-columns: 1fr; } }

/* Heatmap: deeper cell colors */
.cell.low { background: #a8dab5; color: #0d5323; }
.cell.medium { background: #fdd663; color: #5c4300; }
.cell.high { background: #fbb07a; color: #7a3100; }
.cell.veryhigh { background: #f28b82; color: #6e0f0a; }
.cell.zero { color: transparent; }

/* equal-height paired cards */
.grid.eq { align-items: stretch; }
.card-col { display: flex; flex-direction: column; min-height: 100%; }
.card-col > .card-head { min-height: 56px; align-items: flex-start; }
.push-bottom { margin-top: auto !important; }
.card-col form { margin-bottom: 24px; }
.t-rep { table-layout: fixed; width: 100%; }
.t-rep td { vertical-align: middle; }
.t-rep td:first-child { overflow: hidden; }
.t-rep td:first-child .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nowrap { white-space: nowrap; }

/* select: custom chevron with breathing room */
select, .select, .role-select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 16px center !important; background-size: 12px 8px !important;
  padding-right: 44px !important; cursor: pointer;
}
select::-ms-expand { display: none; }
.chip select { padding-right: 26px !important; background-position: right 2px center !important; }

/* ---------- Compact spacing (v2.3) ---------- */
.nav { width: 224px; padding: 8px 10px; }
.nav a { height: 42px; padding: 0 14px; border-radius: 21px; gap: 10px; font-size: 14px; }
.main { margin-left: 224px; padding: 76px 24px 32px 16px; }
#main-inner { max-width: 1360px; margin: 0 auto; }
.page-head { margin: 4px 0 16px; }
.page-head h1 { font-size: 24px; }
.card { padding: 16px 20px; }
.card-head { margin-bottom: 12px; }
.grid, .grid.eq { gap: 12px; }
.card + .card { margin-top: 12px; }
.mt { margin-top: 12px; }
.mt-l { margin-top: 16px; }
.table-wrap { margin: 0 -20px; }
.t th { padding: 8px 10px; }
.t td { padding: 10px; }
.t th:first-child, .t td:first-child { padding-left: 20px; }
.t th:last-child, .t td:last-child { padding-right: 20px; }
.input, .select, .textarea { min-height: 40px; padding: 8px 12px; }
.field label { margin-bottom: 4px; }
.g-intake { grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); }
@media (max-width: 1280px) { .g-intake { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .main { margin-left: 0; padding: 72px 12px 32px; } }
@media (max-width: 520px) { .card { padding: 14px; } .table-wrap { margin: 0 -14px; } .t th:first-child, .t td:first-child { padding-left: 14px; } .t th:last-child, .t td:last-child { padding-right: 14px; } }
@media (max-width: 1280px) { .g-intake { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) { .g-5-7, .g-2, .split { grid-template-columns: minmax(0, 1fr); } }
.grid > * { min-width: 0; }
@media (max-width: 520px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .brand-name { font-size: 16px; white-space: nowrap; }
  .role-select { max-width: 132px; font-size: 12px; }
}

/* report editor: equal panes */
.split-eq { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: stretch; }
.split-eq .pane { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 520px; margin: 0; }
.split-eq .pane > .card-head { min-height: 36px; margin-bottom: 12px; flex-wrap: nowrap; }
.split-eq .editor, .split-eq .pane-body { flex: 1; min-height: 0; overflow-y: auto; }
.split-eq .editor { resize: none; }
.split-eq .pane-body { max-width: none; border: 1px solid var(--outline); border-radius: var(--radius-sm); padding: 12px 16px; }
@media (max-width: 1100px) { .split-eq { grid-template-columns: minmax(0, 1fr); } .split-eq .pane { height: 70vh; } }

/* zones */
.ztag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.ztag.ex { background: #fef3e2; color: #7a4100; }
.ztag.rl { background: #e6eefc; color: #1e3a8a; }
.zone-sum { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 16px; margin-bottom: 12px; border-radius: 12px; background: var(--surface-2); }
.zone-sum .zs-n { text-align: right; display: flex; flex-direction: column; }
.zone-sum .zs-n b { font-size: 22px; line-height: 1.1; }
.mt-s { margin-top: 6px; }
.kg-head { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 12px; border-radius: 12px; padding: 4px 8px 4px 4px; margin: -4px 0 -4px -4px; }
.kg-head:hover { background: var(--surface-2); }
.kg-head:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.kg-head h2 { display: flex; align-items: center; gap: 6px; }
.kg-info { font-size: 18px; color: var(--text-3); }
.kg-ic { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--primary-container); color: var(--primary); font-size: 20px; flex: none; }
.kg-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.kg-stats > div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.kg-stats b { font-size: 22px; line-height: 1.1; }
@media (max-width: 600px) { .kg-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* heatmap cell popup list */
.cl-list { border: 1px solid var(--outline-variant); border-radius: 12px; overflow: hidden; }
.cl-item { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; grid-template-columns: 4px minmax(0, 1fr) 20px; gap: 14px; align-items: center; padding: 12px 16px 12px 12px; border-top: 1px solid var(--outline-variant); }
.cl-item:first-child { border-top: 0; }
.cl-item:hover { background: var(--surface-2); }
.cl-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cl-item .rbar { align-self: stretch; border-radius: 2px; }
.cl-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cl-title { font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sheet-back { margin: -4px 0 8px -12px; }
details.adv > summary { cursor: pointer; font-size: 13px; color: var(--text-2); padding: 6px 0; list-style: none; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: "▸ "; color: var(--text-3); }
details.adv[open] > summary::before { content: "▾ "; }
/* white topbar + sidebar */
.topbar { background: #fff; border-bottom: 1px solid var(--outline-variant); }
.nav { background: #fff; border-right: 1px solid var(--outline-variant); }
/* ---------- Report review workflow ---------- */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--vh-dot, #c5221f); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mb { margin-bottom: 16px; }
.steps-mini { margin: 4px 0 0; padding-left: 20px; font-size: 13px; color: var(--text-2); line-height: 1.8; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; padding: 0 0 14px; position: relative; font-size: 13px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--outline-variant); }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); margin-top: 4px; }
.tl-note { margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; color: var(--text-1, inherit); }
.split-read { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.side-sticky { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.side-sticky .kv { grid-template-columns: 96px 1fr; font-size: 13px; }
@media (max-width: 1100px) { .split-read { grid-template-columns: 1fr; } .side-sticky { position: static; max-height: none; } }
/* ---------- AI analysis record ---------- */
.lnk { color: var(--primary); cursor: pointer; } .lnk:hover { text-decoration: underline; }
.ai-rec { border: 1px solid var(--outline-variant); border-radius: 12px; background: var(--surface); overflow: hidden; }
.ai-rec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px; background: var(--surface-2); border-bottom: 1px solid var(--outline-variant); flex-wrap: wrap; }
.ai-rec-kicker { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--primary); }
.ai-rec-kicker .icon { font-size: 18px; }
.ai-sec { padding: 12px 16px; border-bottom: 1px solid var(--outline-variant); }
.ai-sec h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--text-1, #1f1f1f); letter-spacing: .01em; }
.ai-sec p { margin: 0; font-size: 14px; line-height: 1.65; }
.ai-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.ai-tbl th { width: 34%; min-width: 110px; text-align: left; font-weight: 500; color: var(--text-3); padding: 5px 10px 5px 0; vertical-align: top; }
.ai-tbl td { padding: 5px 0; vertical-align: top; }
.ai-ul, .ai-ol { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.ai-ul.warn li::marker { color: var(--high-dot); }
.ai-rec-foot { padding: 10px 16px; font-size: 12px; color: var(--text-3); background: var(--surface-2); }
.kpi-click { cursor: pointer; transition: border-color .15s, box-shadow .15s; position: relative; }
.kpi-click:hover { border-color: var(--primary); box-shadow: 0 1px 6px rgba(30,41,59,.12); }
.kpi-click:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.kpi-click::after { content: "ดูรายการ ›"; position: absolute; right: 16px; bottom: 12px; font-size: 12px; color: var(--primary); opacity: 0; transition: opacity .15s; }
.kpi-click:hover::after, .kpi-click:focus-visible::after { opacity: 1; }

/* Cases: keep page head and intake in place, scroll only the case table */
.case-list-card { display: flex; flex-direction: column; }
.case-list-card #case-list { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.case-scroll { overflow: auto; max-height: 70vh; overscroll-behavior: contain; }
.case-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); box-shadow: inset 0 -1px 0 var(--outline-variant); }
@media (min-width: 1281px) {
  .g-intake > .case-list-card { position: sticky; top: 76px; max-height: calc(100vh - 186px); min-height: 420px; }
  .g-intake > .case-list-card .case-scroll { max-height: none; flex: 1; min-height: 0; }
}

/* ===== shell ===== */
/* Detail popup: centered modal dialog */
.sheet .sheet-panel { top: 50%; left: 50%; right: auto; bottom: auto; width: min(760px, 94vw); max-height: 88vh; border-radius: 28px;
  transform: translate(-50%, -48%) scale(.97); opacity: 0; visibility: hidden; box-shadow: 0 24px 48px rgba(0,0,0,.18);
  transition: transform .2s cubic-bezier(.2,0,0,1), opacity .2s, visibility 0s .2s; }
.sheet.open .sheet-panel { transform: translate(-50%, -50%); opacity: 1; visibility: visible; transition: transform .2s cubic-bezier(.2,0,0,1), opacity .2s; }
.sheet .sheet-top { position: sticky; top: 0; }
.sheet .sheet-body { padding: 0 32px 32px; }
@media (max-width: 520px) { .sheet .sheet-panel { width: 96vw; max-height: 92vh; border-radius: 20px; } .sheet .sheet-body { padding: 0 18px 24px; } }
body:not(.logged) .topbar, body:not(.logged) .nav, body:not(.logged) .main { display: none; }
#back-office.on { background: var(--primary-container); color: var(--on-primary-container); }
#back-office:hover { text-decoration: none; }
.role-select { height: 32px; border: 0; border-radius: 8px; background: var(--primary-container); color: var(--on-primary-container); font: inherit; font-size: 13px; font-weight: 500; padding: 0 8px; cursor: pointer; max-width: 260px; }
@media (max-width: 860px) { #back-office.on { background: var(--primary-container); color: var(--on-primary-container); }
#back-office:hover { text-decoration: none; }
.role-select { max-width: 120px; } }

/* ===== server build ===== */
body.busy { cursor: progress; }
body.busy .btn[type=submit], body.busy [data-act] { pointer-events: none; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--text-3); }

.sheet-body .result { margin-top: 0; border: 0; background: transparent; padding: 0; animation: none; }

/* =====================================================================
   Design tokens v2: type scale from Google Drive (Material 3, Google Sans)
   and one 4/8 px spacing scale for the whole system. Loaded last on purpose.
   ===================================================================== */
:root {
  --fs-display: 32px; --lh-display: 40px;   /* KPI numbers */
  --fs-headline: 24px; --lh-headline: 32px; /* login, factsheet title */
  --fs-title-l: 22px; --lh-title-l: 28px;   /* page title (Drive: "My Drive") */
  --fs-title-m: 16px; --lh-title-m: 24px;   /* card / section title */
  --fs-title-s: 14px; --lh-title-s: 20px;   /* sub-section, table header */
  --fs-body-l: 16px; --lh-body-l: 24px;     /* long reading text, search */
  --fs-body: 14px; --lh-body: 20px;         /* default text, buttons, chips, table rows */
  --fs-small: 12px; --lh-small: 16px;       /* meta, hints, labels */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
}
body { font-size: var(--fs-body); line-height: var(--lh-body); }
h1, .page-head h1 { font-size: var(--fs-title-l); line-height: var(--lh-title-l); font-weight: 400; }
h2 { font-size: var(--fs-title-m); line-height: var(--lh-title-m); font-weight: 500; }
h3, h4 { font-size: var(--fs-title-s); line-height: var(--lh-title-s); font-weight: 500; }
.small, .hint, .kpi-sub, .doc-foot, .fs-crumb, .rcount, .demo-users, .fs-foot, .ai-rec-foot, .sec-title, .field label, .t th { font-size: var(--fs-small); line-height: var(--lh-small); }
.mono { font-size: 13px; }

/* Shell: equal gutters around the content */
.brand-name { font-size: var(--fs-title-l); line-height: var(--lh-title-l); font-weight: 400; }
.main { padding: calc(64px + var(--sp-4)) var(--sp-6) var(--sp-10); }
.nav { padding: var(--sp-2) var(--sp-3); }
.nav a { height: 40px; padding: 0 var(--sp-4); margin-bottom: var(--sp-1); font-size: var(--fs-body); border-radius: 20px; }
.nav-badge { font-size: 11px; }

/* Page header and cards */
.page-head { margin: 0 0 var(--sp-6); gap: var(--sp-4); align-items: center; }
.page-head p { margin-top: var(--sp-1); font-size: var(--fs-body); line-height: var(--lh-body); }
.card { padding: var(--sp-6); }
.card + .card, .card + section, section + .card { margin-top: var(--sp-4); }
.card-head { margin-bottom: var(--sp-4); gap: var(--sp-3); }
.card-head p { font-size: var(--fs-body); line-height: var(--lh-body); margin-top: 2px; }
.grid { gap: var(--sp-4); }
.mt { margin-top: var(--sp-4); } .mt-l { margin-top: var(--sp-6); }
.row { gap: var(--sp-2); }

/* KPI */
.kpi { padding: var(--sp-5) var(--sp-6); gap: var(--sp-2); }
.kpi-label { font-size: var(--fs-body); }
.kpi-value, .lt-n { font-size: var(--fs-display); line-height: var(--lh-display); }
.kpi-icon { width: 32px; height: 32px; }

/* Controls: Drive sizes (buttons 40/32 high, 14px label) */
.btn { height: 40px; padding: 0 var(--sp-6); font-size: var(--fs-body); }
.btn-sm { height: 32px; padding: 0 var(--sp-4); font-size: var(--fs-body); }
.btn-text { padding: 0 var(--sp-3); }
.chip, .seg button, .role-chip { font-size: var(--fs-body); }
.field { gap: var(--sp-1); }
.field label { margin-bottom: 0; }
.input, .select, .textarea { min-height: 40px; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-body); line-height: var(--lh-body); }
.form-grid { gap: var(--sp-4); }
.notice { padding: var(--sp-3) var(--sp-4); gap: var(--sp-3); font-size: var(--fs-body); line-height: var(--lh-body); }
.tag, .ztag, .rag { font-size: var(--fs-small); }

/* Tables and lists: 48px rows like Drive */
.table-wrap { margin: 0 calc(-1 * var(--sp-6)); }
.t td { padding: 14px var(--sp-3); font-size: var(--fs-body); line-height: var(--lh-body); }
.t th { padding: var(--sp-3); }
.t th:first-child, .t td:first-child { padding-left: var(--sp-6); }
.t th:last-child, .t td:last-child { padding-right: var(--sp-6); }
.cl-item { padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-3); gap: var(--sp-3); }
.empty { padding: var(--sp-10) var(--sp-4); }

/* Popup (sheet) */
.sheet-top { padding: var(--sp-2) var(--sp-3) 0; }
.sheet-body { padding: 0 var(--sp-6) var(--sp-6); }
.sheet-body h2 { font-size: var(--fs-title-l); line-height: var(--lh-title-l); font-weight: 400; }
.sec { padding: var(--sp-5) 0; }
.sec-title { margin-bottom: var(--sp-2); }
.kv { gap: var(--sp-2) var(--sp-3); font-size: var(--fs-body); line-height: var(--lh-body); }
.timeline li, .tl-note, .steps-mini, .side-sticky .kv { font-size: var(--fs-body); line-height: var(--lh-body); }

/* AI analysis record */
.ai-rec-head { padding: var(--sp-3) var(--sp-4); }
.ai-sec { padding: var(--sp-3) var(--sp-4); }
.ai-sec h4 { font-size: var(--fs-title-s); font-weight: 500; margin-bottom: var(--sp-2); }
.ai-sec p, .ai-tbl, .ai-ul, .ai-ol { font-size: var(--fs-body); line-height: var(--lh-body); }
.ai-rec-kicker { font-weight: 500; }

/* Login */
.login-card { padding: var(--sp-10); }
.login-card h1 { font-size: var(--fs-headline); line-height: var(--lh-headline); margin: var(--sp-5) 0 var(--sp-2); }

/* Library and factsheet */
.doc-card { padding: var(--sp-5) var(--sp-6); }
.doc-title { font-size: var(--fs-title-s); line-height: var(--lh-title-s); font-weight: 500; }
.doc-sum { font-size: var(--fs-body); line-height: var(--lh-body); }
.fs-type, .fs-band, .fs-toc { font-size: var(--fs-small); }
.fs-title { font-size: var(--fs-headline); line-height: var(--lh-headline); font-weight: 400; }
.fs h2 { font-size: var(--fs-title-m); line-height: var(--lh-title-m); font-weight: 500; }
.fs h3 { font-size: var(--fs-title-s); line-height: var(--lh-title-s); font-weight: 500; }
.fs p, .fs li { font-size: var(--fs-body); line-height: 24px; }
.fs section { padding-top: var(--sp-6); }
.fs-table { font-size: var(--fs-body); }

/* Reports, editor, charts */
.doc h1 { font-size: var(--fs-title-l); line-height: var(--lh-title-l); }
.doc h2 { font-size: var(--fs-title-m); line-height: var(--lh-title-m); }
.doc table, .editor, .bar-label, details.adv > summary { font-size: var(--fs-body); }
.heat .ylab, .heat .xlab, .heat-sm .xlab { font-size: var(--fs-small); }
.kri-val { font-size: var(--fs-title-m); }
.kri-big, .gauge::after, .doc-side-n { font-size: var(--fs-title-m); }
.zone-sum .zs-n b, .kg-stats b { font-size: var(--fs-title-l); }

@media (max-width: 1100px) { .main { padding-left: var(--sp-4); padding-right: var(--sp-4); } .card { padding: var(--sp-5); } .table-wrap { margin: 0 calc(-1 * var(--sp-5)); }
  .t th:first-child, .t td:first-child { padding-left: var(--sp-5); } .t th:last-child, .t td:last-child { padding-right: var(--sp-5); } }
@media (max-width: 600px) { .kpi-value { font-size: 28px; line-height: 36px; } .card { padding: var(--sp-4); } .table-wrap { margin: 0 calc(-1 * var(--sp-4)); }
  .t th:first-child, .t td:first-child { padding-left: var(--sp-4); } .t th:last-child, .t td:last-child { padding-right: var(--sp-4); } .sheet-body { padding: 0 var(--sp-4) var(--sp-4); } }
.btn:has(> .icon:first-child) { padding-left: var(--sp-4); }
.btn-sm:has(> .icon:first-child) { padding-left: var(--sp-3); }
#intake .row { flex-wrap: nowrap; }
/* Factsheet: tighter page (comment: area too wide) */
.fs-layout { grid-template-columns: minmax(0, 820px) 220px; gap: var(--sp-4); justify-content: center; }
.fs { max-width: 820px; padding: 0 var(--sp-8) var(--sp-8); }
.fs-band { margin: 0 calc(-1 * var(--sp-8)) var(--sp-5); padding: var(--sp-3) var(--sp-8); }
.fs-head { padding-bottom: var(--sp-4); }
.fs section { padding-top: var(--sp-5); }
.fs h2 { margin-bottom: var(--sp-3); }
.fs-table th { width: 160px; }
.fs-table th, .fs-table td { padding: var(--sp-2) var(--sp-3); }
.fs-foot { margin-top: var(--sp-6); }
.fs-crumb { max-width: 1056px; margin: 0 auto var(--sp-3); }
@media (max-width: 1100px) { .fs-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) { .fs { padding: 0 var(--sp-4) var(--sp-6); } .fs-band { margin: 0 calc(-1 * var(--sp-4)) var(--sp-4); padding: var(--sp-2) var(--sp-4); } }
/* Notification bell (Facebook-style) */
.notif { position: relative; }
.notif-btn { position: relative; background: var(--surface-2); }
.notif-btn.on { background: var(--primary-container); color: var(--on-primary-container); }
.notif-btn.on .icon { font-variation-settings: "FILL" 1; }
.notif-badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--vh-dot); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid var(--bg); box-sizing: content-box; }
.notif-panel { position: absolute; top: 48px; right: -8px; width: min(400px, calc(100vw - 16px)); max-height: min(560px, calc(100vh - 80px)); overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 4px 8px 3px rgba(60,64,67,.15), 0 1px 3px rgba(60,64,67,.3); padding: var(--sp-2); z-index: 40; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-2) var(--sp-2) var(--sp-1) var(--sp-3); }
.notif-head h2 { font-size: var(--fs-title-l); line-height: var(--lh-title-l); font-weight: 500; }
.notif-tabs { display: flex; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); }
.notif-tabs .chip { border-radius: 16px; }
.notif-item { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; display: grid; grid-template-columns: 48px minmax(0, 1fr) 12px; gap: var(--sp-3); align-items: center;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm); }
.notif-item:hover { background: var(--surface-2); }
.notif-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.notif-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-container); color: var(--on-primary-container); }
.notif-ic.warn { background: var(--high-bg); color: var(--high-fg); }
.notif-txt { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--text-2); }
.notif-txt b { color: var(--text); font-weight: 500; }
.notif-note { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-3); }
.notif-item.unread .notif-time { color: var(--primary); font-weight: 500; }
.notif-dot { width: 12px; height: 12px; border-radius: 50%; }
.notif-item.unread .notif-dot { background: var(--primary); }
.notif-panel .empty { padding: var(--sp-8) var(--sp-4); }
@media (max-width: 600px) { .notif-panel { position: fixed; top: 64px; left: 8px; right: 8px; width: auto; } }
