/* OctoForge — management dashboard styling. Committed light theme. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: #dde3ee;
  --text: #1c2433;
  --muted: #64748b;
  --accent: #d9531e;      /* ember */
  --accent-soft: rgba(217, 83, 30, 0.10);
  --blue: #2563eb; --green: #16a34a; --amber: #d97706; --red: #dc2626;
  --purple: #7c3aed; --teal: #0d9488; --slate: #64748b;
  --radius: 12px;
  --shadow: 0 6px 18px rgba(28, 36, 51, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 0 22px; height: 62px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 3px rgba(28,36,51,0.05);
}
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-product { font-weight: 700; font-size: 18px; letter-spacing: 0.3px; color: var(--text); }
.brand-sub { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 2px; }
.brand.big .brand-product { font-size: 26px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { color: var(--muted); font-size: 13px; }
.logout { color: var(--muted); font-size: 13px; }

/* ---------- filter bar ---------- */
.filterbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 12px 22px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filterbar label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.filterbar select, .filterbar input {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; font-size: 13px; min-width: 120px;
  color-scheme: light;
}
.filterbar select:focus, .filterbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.filterbar button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 18px; font-weight: 600; cursor: pointer;
}
.filterbar button:hover { filter: brightness(1.08); }
.filterbar .clear { color: var(--muted); font-size: 13px; padding: 8px 4px; }

main { max-width: 1280px; margin: 0 auto; padding: 22px; }
h1 { font-size: 22px; margin: 6px 0 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text); }
h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
h2 a { color: inherit; }
.crumb { color: var(--muted); font-size: 13px; margin: 4px 0 2px; }
.crumb a { color: var(--muted); }
.lvl {
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; padding: 2px 8px; border-radius: 20px; margin-left: 6px;
  text-transform: uppercase; letter-spacing: 0.8px;
}
.muted { color: var(--muted); }

/* ---------- KPI grid (level 1) ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.kpi-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.kpi-card.accent { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 65%); }
.kpi-card.warn { border-color: var(--red); }
.kpi-card.warn .kpi-value { color: var(--red); }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; }
.kpi-value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; color: var(--text); }
.kpi-sub { color: var(--muted); font-size: 12px; }

/* ---------- panels ---------- */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; overflow-x: auto;
  box-shadow: var(--shadow);
}
.panel.wide { grid-column: 1 / -1; }
.legend { float: right; font-size: 11px; text-transform: none; letter-spacing: 0; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 10px; }
.sw.blue { background: var(--blue); } .sw.green { background: var(--green); }
.big-stat { font-size: 30px; font-weight: 700; margin: 8px 0; color: var(--text); }

/* ---------- charts ---------- */
svg.hbar, svg.cols, svg.funnel, svg.donut { width: 100%; height: auto; display: block; }
svg .c-label { fill: var(--muted); font-size: 12px; }
svg .c-val { fill: var(--text); font-size: 12px; }
svg a rect:hover, svg a path:hover { opacity: 1 !important; filter: brightness(1.1) saturate(1.15); }
.chart-empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* ---------- group tabs (level 2) ---------- */
.group-tabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.group-tabs a {
  padding: 7px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.group-tabs a:hover { color: var(--text); text-decoration: none; }
.group-tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.stat-row { display: flex; gap: 26px; margin: 0 0 16px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--text); }
.stat.neg .stat-num { color: var(--red); }
.stat-cap { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }

/* ---------- tables (level 3) ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:hover td { background: var(--surface-2); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.late { color: var(--red); font-weight: 600; }
.drill-link { font-size: 12px; white-space: nowrap; }

/* ---------- status pills (light-tuned: tinted bg, dark text) ---------- */
.status {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.s-new, .s-confirmed, .s-testing { background: rgba(37,99,235,.10); color: #1d4ed8; }
.s-under_review, .s-in_production, .s-fabrication, .s-submitted { background: rgba(217,119,6,.12); color: #b45309; }
.s-bid, .s-engineering { background: rgba(124,58,237,.10); color: #6d28d9; }
.s-quoted, .s-procurement { background: rgba(13,148,136,.10); color: #0f766e; }
.s-won, .s-dispatched, .s-dispatch_ready, .s-accepted, .s-paid { background: rgba(22,163,74,.10); color: #15803d; }
.s-lost, .s-cancelled, .s-rejected { background: rgba(220,38,38,.10); color: #b91c1c; }
.s-no_bid, .s-on_hold, .s-closed, .s-draft, .s-planned, .s-expired { background: rgba(100,116,139,.12); color: #475569; }

/* ---------- progress bars ---------- */
.bar {
  display: inline-block; width: 90px; height: 8px; vertical-align: middle;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.bar.wide-bar { width: 200px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--amber)); }

/* ---------- key/value lists ---------- */
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; padding-top: 2px; }
dl.kv dd { margin: 0; }
dd.late { color: var(--red); font-weight: 600; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 40px; width: 380px; box-shadow: var(--shadow);
}
.login-tag { color: var(--muted); font-size: 13px; margin: 6px 0 22px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.login-card input {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-card button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 11px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 6px;
}
.flash.error {
  background: rgba(220,38,38,.08); border: 1px solid rgba(220,38,38,.35);
  color: #b91c1c; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
}

@media (max-width: 800px) {
  .topbar { gap: 12px; padding: 0 12px; }
  main { padding: 14px; }
  dl.kv { grid-template-columns: 110px 1fr; }
}

/* ==================== v0.2 — ERP shell (sidebar layout) ==================== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { padding: 18px 18px 12px; border-bottom: 1px solid var(--border); }
.sidenav { padding: 8px 10px 24px; }
.nav-sec {
  margin: 14px 8px 4px; font-size: 10.5px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px;
}
.sidenav a {
  display: block; padding: 6px 10px; border-radius: 7px;
  color: var(--text); font-size: 13px;
}
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.shell-main .topbar {
  justify-content: space-between; height: 52px; gap: 14px;
  position: sticky; top: 0;
}
.page-slot { font-weight: 600; color: var(--muted); }
.shell-main main { max-width: none; width: 100%; }

.count-chip {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 20px;
}
.num-cell { font-variant-numeric: tabular-nums; }

/* in-page section tabs (job detail) */
.tabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.tabs a {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500;
}
.tabs a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidenav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-sec { flex-basis: 100%; margin: 8px 4px 2px; }
}

/* ==================== v0.3 — user administration ==================== */
.flash.ok {
  background: rgba(22,163,74,.08); border: 1px solid rgba(22,163,74,.35);
  color: #15803d; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px;
}
.user-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.user-form label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.user-form input, .user-form select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; min-width: 150px;
}
.user-form button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font-weight: 600; cursor: pointer;
}
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form select, .inline-form input {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 8px; font-size: 12px;
}
.btn-sm {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px; font-size: 12px; cursor: pointer; list-style: none;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.actions-cell { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pw-reset summary::-webkit-details-marker { display: none; }
.pw-reset[open] summary { display: none; }
.row-dim td { opacity: 0.55; }

/* ==================== v0.4 — demo mode role picker ==================== */
.picker-wrap { width: min(920px, 94vw); padding: 40px 0; }
.role-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px; margin-top: 26px;
}
.role-card {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; cursor: pointer; text-align: left; font: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.role-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.role-name { font-size: 16px; font-weight: 700; color: var(--accent); }
.role-blurb { font-size: 12.5px; color: var(--muted); }
.picker-foot { text-align: center; margin-top: 26px; font-size: 13px; }
.picker-foot a { color: var(--muted); }

/* Donuts scale with their panel otherwise — cap them so a donut panel
   sits at the same height as its hbar/funnel neighbours. */
svg.donut { max-width: 300px; margin: 0 auto; }

/* ==================== v0.5 — executive dashboard redesign ==================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { margin-bottom: 2px; }

.attn-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--red);
  border-radius: 10px; padding: 10px 14px; margin: 14px 0 18px;
}
.attn-strip.clear { border-left-color: var(--green); color: var(--muted); font-size: 13px; }
.attn-title { font-size: 11px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: 1px; }
.attn-title.ok { color: var(--green); }
.attn-chip {
  display: inline-flex; gap: 5px; align-items: baseline;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 12px; font-size: 12.5px; color: var(--text);
}
.attn-chip:hover { border-color: var(--red); text-decoration: none; }
.attn-chip strong { color: var(--red); }

.kpi-section { margin-bottom: 18px; }
.kpi-sec-title {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1.2px; margin: 0 0 8px 2px;
}
.kpi-grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kpi-grid.three .kpi-value { font-size: 30px; }

/* ---------- HTML bar lists (the house ranking chart) ---------- */
.bar-list { display: flex; flex-direction: column; }
.bl-head, .bl-row {
  display: grid; grid-template-columns: minmax(120px, 165px) 1fr 86px 48px;
  gap: 10px; align-items: center; padding: 5px 6px;
}
.bl-head {
  font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px;
  padding-bottom: 2px;
}
.bl-head span:nth-child(3), .bl-head span:nth-child(4) { text-align: right; }
.bl-row { border-radius: 8px; color: var(--text); font-size: 13.5px; }
a.bl-row:hover { background: var(--surface-2); text-decoration: none; }
.bl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bl-track { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.bl-fill { display: block; height: 100%; border-radius: 7px; min-width: 3px; }
.bl-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bl-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }

/* remaining SVG charts (trend columns, donuts): larger, readable text */
svg .c-label { font-size: 14px; }
svg .c-val { font-size: 14px; font-weight: 600; }

/* ---------- composition strip (progress map) ---------- */
.strip-panel { margin-bottom: 14px; }
.stack-wrap { display: flex; flex-direction: column; gap: 12px; }
.stack {
  display: flex; height: 34px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border);
}
.stack-seg {
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.12s ease; min-width: 4px;
}
.stack-seg:hover { filter: brightness(1.12) saturate(1.1); }
.seg-pct { color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,0.35); }
.stack-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.leg-row { display: inline-flex; align-items: baseline; gap: 7px; font-size: 13px; color: var(--text); padding: 2px 4px; border-radius: 6px; }
a.leg-row:hover { background: var(--surface-2); text-decoration: none; }
.leg-row .sw { width: 11px; height: 11px; border-radius: 3px; align-self: center; margin: 0; }
.leg-label { font-weight: 500; }
.leg-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.leg-pct { color: var(--muted); font-size: 12px; }
