/* Merit Prop back office. Desktop only. Own palette: deep forest sidebar, warm gold accent, neutral paper. */
:root {
  --side: #14231d; --side-2: #1d3229; --side-text: #c9d6cf; --side-dim: #7f978b;
  --accent: #2e7d5b; --accent-2: #246a4c; --gold: #c99a2e;
  --paper: #f5f4ef; --card: #ffffff; --line: #e3e1d8; --text: #1f2522; --dim: #6b736e;
  --good: #23784f; --good-bg: #e3f2e9; --bad: #b3372b; --bad-bg: #fbe6e3; --warn: #a2650c; --warn-bg: #fbf0d9;
  --muted-bg: #eeede7;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; color: var(--text); background: var(--paper); }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }

/* layout */
body.app { display: flex; min-width: 1200px; height: auto; min-height: 100vh; }
.side { width: 236px; flex: none; background: var(--side); color: var(--side-text); min-height: 100vh; padding: 18px 12px;
  display: flex; flex-direction: column; }
.side-inner { position: sticky; top: 18px; display: flex; flex-direction: column; min-height: calc(100vh - 36px); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-dim); letter-spacing: .06em; text-transform: uppercase; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--gold); color: var(--side); display: grid;
  place-items: center; font-weight: 800; font-size: 18px; }
.nav-group { margin-bottom: 14px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-dim); padding: 6px 10px; }
.nav-item { display: flex; justify-content: space-between; align-items: center; color: var(--side-text); padding: 8px 10px;
  border-radius: 7px; margin: 1px 0; }
.nav-item:hover { background: var(--side-2); text-decoration: none; color: #fff; }
.nav-item.on { background: var(--accent); color: #fff; font-weight: 600; }
.nav-badge { background: var(--gold); color: var(--side); border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.side-foot { margin-top: auto; font-size: 11px; color: var(--side-dim); padding: 10px; }
.main { flex: 1; min-width: 0; }
.top { height: 60px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 2; }
.search input { width: 380px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font: inherit; }
.who { display: flex; align-items: center; gap: 10px; }
.who small { display: block; color: var(--dim); font-size: 11px; text-transform: capitalize; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.who form { margin: 0 0 0 8px; }
.content { padding: 22px 28px 40px; }
.crumbs { color: var(--dim); font-size: 12px; margin-bottom: 6px; }
.title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

/* buttons and forms */
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); padding: 7px 14px; border-radius: 7px; cursor: pointer; color: var(--text); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.ghost { background: transparent; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text); }
textarea { width: 100%; min-height: 70px; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 0 0 14px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--dim); gap: 4px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--dim); }

/* cards, kpis, tables */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; border-top: 3px solid var(--accent); }
.kpi.bad { border-top-color: var(--bad); } .kpi.warn { border-top-color: var(--gold); } .kpi.muted { border-top-color: var(--line); }
.kpi-label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 12px; color: var(--dim); margin-top: 2px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px; overflow-x: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 14px 16px; }
.card-body:has(> table.grid:only-child) { padding: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.cols-3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; }
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.grid th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim);
  background: #faf9f5; padding: 9px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
table.grid td { padding: 9px 14px; border-bottom: 1px solid #efede6; vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: #fbfaf6; }
td.empty { color: var(--dim); text-align: center; padding: 22px; }
.num { text-align: right; }
dl.facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 7px 14px; margin: 0; }
dl.facts dt { color: var(--dim); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; text-transform: capitalize; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.muted { background: var(--muted-bg); color: var(--dim); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 9px 14px; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab:hover { text-decoration: none; color: var(--text); }
.alert { padding: 10px 12px; border-radius: 8px; margin: 0; }
.alert.bad { background: var(--bad-bg); color: var(--bad); } .alert.good { background: var(--good-bg); color: var(--good); }
.dim { color: var(--dim); }
.bar { height: 8px; background: var(--muted-bg); border-radius: 4px; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.warn > span { background: var(--gold); } .bar.bad > span { background: var(--bad); }
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 70%; padding: 8px 12px; border-radius: 10px; background: var(--muted-bg); }
.msg.user { align-self: flex-start; } .msg.staff { align-self: flex-end; background: var(--good-bg); }
.msg.bot { align-self: flex-start; background: #f1efe6; } .msg.system { align-self: center; background: transparent; color: var(--dim); font-size: 12px; }
.msg small { display: block; color: var(--dim); font-size: 11px; }
.note { border-left: 3px solid var(--gold); padding: 6px 12px; margin-bottom: 10px; background: #fdfbf4; }

/* sign-in pages */
body.bare { display: grid; place-items: center; min-height: 100vh; background: var(--side); }
.auth-card { width: 420px; background: var(--card); border-radius: 14px; padding: 30px 32px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth-card h1 { margin: 8px 0 14px; }
.brand.big { color: var(--text); padding: 0 0 6px; }
.brand.big small { color: var(--dim); }
.fine { font-size: 12px; color: var(--dim); }

/* bar widths (no inline styles: the CSP allows none) */
td.wide { width: 60%; }
.bar > span.w0 { width: 0%; }
.bar > span.w5 { width: 5%; }
.bar > span.w10 { width: 10%; }
.bar > span.w15 { width: 15%; }
.bar > span.w20 { width: 20%; }
.bar > span.w25 { width: 25%; }
.bar > span.w30 { width: 30%; }
.bar > span.w35 { width: 35%; }
.bar > span.w40 { width: 40%; }
.bar > span.w45 { width: 45%; }
.bar > span.w50 { width: 50%; }
.bar > span.w55 { width: 55%; }
.bar > span.w60 { width: 60%; }
.bar > span.w65 { width: 65%; }
.bar > span.w70 { width: 70%; }
.bar > span.w75 { width: 75%; }
.bar > span.w80 { width: 80%; }
.bar > span.w85 { width: 85%; }
.bar > span.w90 { width: 90%; }
.bar > span.w95 { width: 95%; }
.bar > span.w100 { width: 100%; }
/* risk views (beta-4) */
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.risk-chart { display: block; max-width: 100%; height: auto; }
.risk-legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--dim); margin-bottom: 8px; }
.risk-legend span { display: inline-flex; align-items: center; gap: 6px; }
.risk-legend .sw { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); }
.risk-legend .sw.bal { border-top-color: #8b918d; }
.risk-legend .sw.dd { border-top: 2px dashed var(--bad); }
.risk-legend .sw.dl { border-top: 2px dashed var(--warn); }
.risk-legend .sw.br, .risk-legend .sw.wo { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--bad); }
.risk-legend .sw.wo { background: var(--text); }
.risk-meter { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 12px; color: var(--dim); }
.risk-hbars { display: block; max-width: 100%; height: auto; }
.risk-gap { margin-bottom: 14px; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; }
code.hash { word-break: break-all; font-size: 11px; }
