:root {
  /* Light pink with navy lettering and accents */
  --navy: #14244a;
  --navy-2: #1f3a68;
  --accent: #1f3a68;      /* navy: buttons, active tab, highlights */
  --accent-2: #f2a7c3;    /* pink: accents on navy */
  --accent-soft: #fbe3ec; /* pale pink fills */
  --gold: #d4a017;
  --bg: #f6c9da;          /* same pink as the lead bars */
  --card: #ffffff;
  --ink: #14244a;
  --muted: #6b6f8a;
  --line: #f0cfdc;
  --good: #15803d;
  --bad: #b91c1c;
  --radius: 12px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
.hidden { display: none !important; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy), var(--navy-2)); }
.login-card { background: var(--card); padding: 32px; border-radius: 16px; width: 340px; display: grid; gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-card button { padding: 11px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font-weight: 600; font-size: 15px; cursor: pointer; }
.error { color: var(--bad); min-height: 1em; margin: 0; font-size: 13px; }

/* Header */
.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--navy); color: #fff; flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; white-space: nowrap; }
.brand b { color: var(--accent-2); }
.brand.big { font-size: 22px; color: var(--ink); margin-bottom: 8px; }
.mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; font-size: 15px; }
.filters { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
.filters label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #f6d6e3; }
.filters select { background: var(--navy-2); color: #fff; border: 1px solid #3a5487; border-radius: 8px; padding: 7px 10px; font-size: 13px; }
.sync { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #f6d6e3; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; }
.dot.ok { background: #22c55e; } .dot.warn { background: var(--gold); } .dot.bad { background: #ef4444; }
.banner { background: #fef3c7; color: #78350f; padding: 8px 24px; font-size: 13px; border-bottom: 1px solid #fde68a; }

/* Tabs */
.tabs { display: flex; gap: 2px; padding: 0 16px; background: #fff8fb; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 14px 14px 12px; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button .wip { font-size: 10px; background: var(--accent-soft); color: var(--muted); padding: 1px 6px; border-radius: 10px; margin-left: 4px; }
.range-note { padding: 14px 24px 0; font-size: 13px; color: var(--muted); }

main { padding: 16px 24px 40px; display: grid; gap: 18px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); }
.card .sub { color: var(--muted); font-size: 13px; margin: -6px 0 12px; }

/* KPI grid */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi.hero { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; border: 0; }
.kpi.hero .label { color: #f6d6e3; }
.kpi.money .value { color: var(--accent); }
.kpi.hero.money .value { color: var(--accent-2); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: pointer; user-select: none; position: sticky; top: 0; background: #fff; }
th.sorted::after { content: ' ▾'; } th.sorted.asc::after { content: ' ▴'; }
tbody tr:hover { background: #f8fafc; }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
td.missing { color: var(--gold); }
.search { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; width: 220px; margin-bottom: 10px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
.chart-box { position: relative; height: 280px; }

/* Heatmap */
.heat { display: grid; grid-template-columns: 70px repeat(5, 1fr); gap: 3px; font-size: 12px; }
.heat .h { color: var(--muted); font-weight: 600; text-align: center; padding: 6px 0; }
.heat .t { color: var(--muted); text-align: right; padding: 8px 8px 0 0; }
.heat .c { border-radius: 6px; padding: 6px 8px; min-height: 40px; display: flex; flex-direction: column; justify-content: center; }
.heat .c b { font-size: 13px; } .heat .c span { font-size: 11px; opacity: .85; }

.bar { height: 8px; background: var(--accent-2); border-radius: 4px; display: inline-block; vertical-align: middle; margin-right: 8px; }

/* WIP + AskTwenty */
.wip-card { border-style: dashed; }
.wip-card ul { margin: 8px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.ask { display: grid; grid-template-rows: 1fr auto; height: 62vh; }
.ask-log { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.ai { align-self: flex-start; background: #eef2f7; }
.ask-form { display: flex; gap: 8px; }
.ask-form input { flex: 1; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.ask-form button, .chip { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 0 18px; font-weight: 600; cursor: pointer; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { background: var(--accent-soft); color: var(--accent); padding: 7px 12px; font-weight: 500; font-size: 13px; }

/* ---- App window & phones ---- */
/* Grid children may shrink below their content (wide tables scroll inside their card instead). */
main > *, .grid-2 > *, .card { min-width: 0; }
.chart-box canvas { max-width: 100%; }
.topbar { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
.install-btn { background: var(--accent-2); color: var(--navy); border: 0; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
  .brand { font-size: 16px; }
  .filters { gap: 8px; width: 100%; flex: 1 1 100%; }
  .filters label { flex: 1 1 calc(50% - 8px); font-size: 12px; }
  .filters select { width: 100%; min-width: 0; font-size: 14px; padding: 8px; }
  .tabs { padding: 0 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { padding: 12px 10px 10px; font-size: 13px; }
  .range-note { padding: 10px 14px 0; font-size: 12px; }
  main { padding: 12px 10px calc(28px + env(safe-area-inset-bottom)); gap: 12px; }
  .card { padding: 14px 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi .label { font-size: 10.5px; }
  .kpi .value { font-size: 20px; }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .chart-box { height: 230px; }
  table { font-size: 12px; }
  th, td { padding: 8px 7px; }
  .search { width: 100%; }
  .heat { grid-template-columns: 44px repeat(5, minmax(0, 1fr)); font-size: 10px; }
  .heat .c { padding: 4px; min-height: 34px; }
  .heat .c b { font-size: 11px; } .heat .c span { font-size: 9.5px; }
  .ask { height: 70vh; }
  .banner { padding: 8px 14px; }
}
@media (display-mode: standalone) { body { overscroll-behavior-y: none; } }

/* Account menu */
.account { position: relative; margin-left: 8px; }
.account summary { list-style: none; cursor: pointer; background: rgba(255,255,255,.12); color: #fff; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; }
.account summary::-webkit-details-marker { display: none; }
.account-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); color: var(--ink); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.2); padding: 10px; min-width: 240px; display: grid; gap: 4px; z-index: 50; }
.account-menu a, .account-menu button { text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; font-size: 14px; cursor: pointer; }
.account-menu a:hover, .account-menu button:hover { background: var(--accent-soft); }
.account-who { font-size: 12px; color: var(--muted, #5a6585); padding: 4px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
.login-card .sub { margin: 0; font-size: 13px; }
/* Team page */
.team-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.team-table th, .team-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin: 10px 0; }
.form-row label { display: grid; gap: 4px; font-size: 13px; }
.form-row input, .form-row select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 12px; margin: 10px 0; overflow-wrap: anywhere; }
