:root {
  /* Palette — indigo base, clay accent (Komarock brick/earth), muted data tones */
  --ink: #16182b;
  --ink-2: #2a2d44;
  --slate: #5a5e78;
  --mute: #8b8fa6;
  --line: #e6e6ef;
  --line-2: #d9d9e6;
  --paper: #ffffff;
  --bg: #f4f4f8;
  --bg-2: #ececf3;

  --clay: #c25a3a;       /* primary accent */
  --clay-d: #a4472b;
  --clay-soft: #f6e7df;
  --indigo: #3a4180;
  --indigo-soft: #e6e8f5;
  --teal: #2f7d72;
  --gold: #c79a3a;

  /* status */
  --st-done: #2f7d72;
  --st-final: #1d5e54;
  --st-prog: #3a4180;
  --st-hold: #c79a3a;
  --st-none: #8b8fa6;
  --st-cancel: #b23b3b;

  --r: 10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(22,24,43,.06), 0 4px 16px rgba(22,24,43,.05);
  --shadow-lg: 0 8px 40px rgba(22,24,43,.16);
  --display: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--mute); }
a { color: var(--indigo); }
button { font-family: inherit; cursor: pointer; }

/* ---------- LOGIN ---------- */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(194,90,58,.12), transparent),
    radial-gradient(900px 500px at -10% 110%, rgba(58,65,128,.12), transparent),
    var(--ink);
}
.login-wrap { width: 100%; max-width: 400px; padding: 24px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; color: #fff; }
.login-mark {
  width: 52px; height: 52px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--clay), var(--clay-d));
  font-family: var(--display); font-weight: 600; font-size: 19px; color: #fff;
  box-shadow: 0 6px 20px rgba(194,90,58,.4);
}
.login-brand h1 { font-size: 21px; color: #fff; }
.login-brand p { font-size: 12.5px; color: #b8bad0; letter-spacing: .02em; }
.login-card { background: var(--paper); border-radius: 16px; padding: 30px; box-shadow: var(--shadow-lg); }
.login-card h2 { font-size: 23px; }
.login-card > .muted { margin-bottom: 22px; font-size: 13px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 600; color: var(--slate); margin-bottom: 14px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 11px 13px; border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm); font-size: 14px; font-family: inherit; transition: border-color .15s;
}
.login-card input:focus { outline: none; border-color: var(--clay); }
.login-foot { margin-top: 18px; font-size: 11px; color: var(--mute); text-align: center; }
.form-error { color: var(--st-cancel); font-size: 13px; margin-top: 10px; min-height: 18px; }

.btn-primary {
  background: var(--clay); color: #fff; border: none; padding: 11px 18px;
  border-radius: var(--r-sm); font-weight: 600; font-size: 14px; width: 100%; transition: background .15s;
}
.btn-primary:hover { background: var(--clay-d); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ---------- LAYOUT ---------- */
body:has(.sidebar) { display: grid; grid-template-columns: 244px 1fr; }
.sidebar {
  background: var(--ink); color: #cdcfe2; height: 100vh; position: sticky; top: 0;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 18px; }
.side-mark {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--clay), var(--clay-d));
  font-family: var(--display); font-weight: 600; color: #fff; font-size: 15px;
}
.side-title { display: flex; flex-direction: column; line-height: 1.15; }
.side-title strong { color: #fff; font-size: 16px; font-family: var(--display); }
.side-title span { font-size: 11.5px; color: #9a9db8; letter-spacing: .04em; }

.side-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6e7191; margin: 16px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; color: #b6b9d0; padding: 9px 11px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s;
}
.nav-item .ni { width: 18px; text-align: center; opacity: .8; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--clay); color: #fff; }
.nav-item.active .ni { opacity: 1; }
.nav-item[hidden] { display: none; }

.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 0 4px; }
.user-av {
  width: 34px; height: 34px; border-radius: 9px; background: var(--indigo); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { color: #fff; font-size: 13px; }
.user-meta span { font-size: 11px; color: #9a9db8; text-transform: capitalize; }

.content { min-width: 0; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 30px; background: var(--paper); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 23px; }
.topbar .muted { font-size: 13px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.view { padding: 26px 30px 60px; }

/* ---------- BUTTONS / CONTROLS ---------- */
.btn { border: 1.5px solid var(--line-2); background: var(--paper); color: var(--ink); padding: 8px 14px;
  border-radius: var(--r-sm); font-weight: 600; font-size: 13px; transition: .12s; display: inline-flex; align-items: center; gap: 7px; }
.btn:hover { border-color: var(--slate); }
.btn-accent { background: var(--clay); color: #fff; border-color: var(--clay); }
.btn-accent:hover { background: var(--clay-d); border-color: var(--clay-d); }
.btn-ghost { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); color: #cdcfe2; }
.btn-ghost:hover { background: rgba(255,255,255,.16); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
select, input[type=text], input[type=date], input[type=number], input[type=password], input[type=email], textarea {
  font-family: inherit; font-size: 13px; padding: 7px 10px; border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm); background: var(--paper); color: var(--ink);
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--clay); }

/* ---------- CARDS ---------- */
.grid { display: grid; gap: 16px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-size: 15.5px; }
.card-h .sub { font-size: 12px; color: var(--mute); font-weight: 500; }

/* KPI cards */
.kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--indigo)); }
.kpi .v { font-family: var(--display); font-size: 30px; font-weight: 600; line-height: 1; }
.kpi .l { font-size: 12px; color: var(--mute); margin-top: 7px; font-weight: 500; }
.kpi .delta { font-size: 11.5px; margin-top: 4px; }

.prog-ring { position: relative; width: 116px; height: 116px; }
.prog-ring svg { transform: rotate(-90deg); }
.prog-ring .pv { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 26px; font-weight: 600; }

/* ---------- TABLE ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--mute); font-weight: 600; padding: 10px 12px; border-bottom: 1.5px solid var(--line-2); white-space: nowrap; position: sticky; top: 0; background: var(--paper); }
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--bg); }
.tid { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; color: var(--slate); white-space: nowrap; }

/* status pill + select */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-Completed { color: var(--st-done); background: #e4f1ee; }
.s-Final { color: var(--st-final); background: #d8ebe7; }
.s-In.s-Progress, .s-InProgress { color: var(--st-prog); background: var(--indigo-soft); }
.s-On.s-Hold, .s-OnHold { color: var(--st-hold); background: #f7eed3; }
.s-Not.s-Started, .s-NotStarted { color: var(--st-none); background: #ececf3; }
.s-Cancelled { color: var(--st-cancel); background: #f6e2e2; }
.status-select { font-weight: 600; font-size: 12px; padding: 5px 8px; border-radius: 20px; border: 1.5px solid var(--line-2); }

.prio { font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.prio.High { color: var(--clay-d); }
.prio.Medium { color: var(--gold); }
.prio.Low { color: var(--mute); }
.overdue-flag { color: var(--st-cancel); font-weight: 700; font-size: 11px; }

.bar-mini { height: 6px; background: var(--bg-2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar-mini > span { display: block; height: 100%; background: var(--teal); }

/* gate marker */
.gate { font-size: 11px; font-weight: 700; color: var(--clay-d); background: var(--clay-soft); padding: 2px 8px; border-radius: 5px; white-space: nowrap; }

/* ---------- CHART GRID ---------- */
.chart-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.chart-box { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.chart-box h4 { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.chart-box .qn { font-size: 11.5px; color: var(--mute); margin-bottom: 12px; }
.chart-canvas-wrap { position: relative; height: 230px; }
.chart-canvas-wrap.tall { height: 300px; }

/* rating strip */
.rate-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rate-row:last-child { border-bottom: none; }
.rate-label { flex: 1; font-size: 13px; }
.rate-track { width: 160px; height: 8px; background: var(--bg-2); border-radius: 5px; overflow: hidden; }
.rate-track > span { display: block; height: 100%; border-radius: 5px; }
.rate-num { font-family: var(--display); font-weight: 600; width: 42px; text-align: right; font-size: 15px; }

/* tier tabs */
.tier-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.tier-tab { border: 1.5px solid var(--line-2); background: var(--paper); padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--slate); }
.tier-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tier-tab .cnt { opacity: .65; font-weight: 500; margin-left: 4px; }

/* NPS gauge */
.nps-box { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.nps-score { font-family: var(--display); font-size: 48px; font-weight: 600; line-height: 1; }
.nps-split { display: flex; gap: 18px; }
.nps-split div { font-size: 12px; color: var(--mute); }
.nps-split strong { display: block; font-family: var(--display); font-size: 20px; }

/* crosstab heat */
.heat td { text-align: center; font-variant-numeric: tabular-nums; }
.heat td.rowh { text-align: left; font-weight: 600; }

/* toast */
.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow-lg); font-size: 13px; max-width: 360px; animation: slide .25s ease; border-left: 4px solid var(--clay); }
.toast.ok { border-left-color: var(--teal); }
.toast.warn { border-left-color: var(--gold); }
.toast.err { border-left-color: var(--st-cancel); }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } }

/* modal */
.modal-root:empty { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(22,24,43,.5); display: grid; place-items: center; z-index: 150; padding: 20px; }
.modal { background: var(--paper); border-radius: 14px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-h h3 { font-size: 18px; }
.modal-b { padding: 20px 22px; }
.modal-f { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--slate); margin-bottom: 14px; }
.modal label input, .modal label select, .modal label textarea { width: 100%; margin-top: 5px; }
.modal .x { background: none; border: none; font-size: 22px; color: var(--mute); line-height: 1; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* misc */
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--mute); font-weight: 600; margin: 4px 0 12px; }
.row-flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.empty { text-align: center; padding: 50px 20px; color: var(--mute); }
.empty .big { font-family: var(--display); font-size: 18px; color: var(--slate); margin-bottom: 6px; }
.tag { font-size: 11px; background: var(--bg-2); color: var(--slate); padding: 2px 8px; border-radius: 5px; font-weight: 600; }
.loading { text-align: center; padding: 40px; color: var(--mute); }
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .tk { position: absolute; inset: 0; background: var(--line-2); border-radius: 20px; transition: .2s; }
.toggle .tk::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + .tk { background: var(--teal); }
.toggle input:checked + .tk::before { transform: translateX(16px); }

@media (max-width: 860px) {
  body:has(.sidebar) { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; z-index: 100; transition: left .2s; width: 244px; }
  .sidebar.open { left: 0; }
  .view, .topbar { padding-left: 18px; padding-right: 18px; }
  .form-2 { grid-template-columns: 1fr; }
}
