/* ProjectAxis director dashboard. Colours from apps/mobile/src/theme/themes/projectaxis-{light,dark}.ts (Stitch),
   type scale from typography.ts (Inter). Charts: series-1 = brand primary, series-2 = orange (validated pair). */
:root {
  color-scheme: light;
  --background: #F8FAFC;
  --surface: #FFFFFF;
  --surface-raised: #F1F5F9;
  --text: #0F172A;
  --muted: #475569;
  --subtle: #94A3B8;
  --border: #E2E8F0;
  --border-strong: #94A3B8;
  --track: #E2E8F0;
  --primary: #1D4ED8;
  --primary-pressed: #1E40AF;
  --primary-soft: #EFF6FF;
  --primary-text: #FFFFFF;
  --info-text: #1E40AF;
  --success: #16A34A;
  --success-soft: #DCFCE7;
  --success-text: #166534;
  --warning: #D97706;
  --warning-soft: #FEF3C7;
  --warning-text: #92400E;
  --danger: #DC2626;
  --danger-soft: #FEE2E2;
  --danger-text: #991B1B;
  --neutral-soft: #F1F5F9;
  --neutral-text: #475569;
  --notice: #EFF6FF;
  --notice-border: #BFDBFE;
  --shadow: rgba(15, 23, 42, 0.08);
  --series-1: #1D4ED8;
  --series-2: #eb6834;
  --sample: #64748B;
  --sample-soft: #F1F5F9;
  --hatch: rgba(100, 116, 139, 0.22);
  --preview-border: #94A3B8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #0B1120;
    --surface: #131D31;
    --surface-raised: #1E293B;
    --text: #F8FAFC;
    --muted: #94A3B8;
    --subtle: #64748B;
    --border: #283548;
    --border-strong: #475569;
    --track: #1E293B;
    --primary: #3B82F6;
    --primary-pressed: #2563EB;
    --primary-soft: #1E293B;
    --primary-text: #FFFFFF;
    --info-text: #60A5FA;
    --success: #22C55E;
    --success-soft: #064E3B;
    --success-text: #86EFAC;
    --warning: #F59E0B;
    --warning-soft: #451A03;
    --warning-text: #FDE68A;
    --danger: #EF4444;
    --danger-soft: #450A0A;
    --danger-text: #FCA5A5;
    --neutral-soft: #1E293B;
    --neutral-text: #CBD5E1;
    --notice: #0F2042;
    --notice-border: #1D4ED8;
    --shadow: rgba(0, 0, 0, 0.4);
    --series-1: #3B82F6;
    --series-2: #d95926;
    --sample: #94A3B8;
    --sample-soft: #1A2335;
    --hatch: rgba(148, 163, 184, 0.2);
    --preview-border: #475569;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0B1120;
  --surface: #131D31;
  --surface-raised: #1E293B;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --subtle: #64748B;
  --border: #283548;
  --border-strong: #475569;
  --track: #1E293B;
  --primary: #3B82F6;
  --primary-pressed: #2563EB;
  --primary-soft: #1E293B;
  --primary-text: #FFFFFF;
  --info-text: #60A5FA;
  --success: #22C55E;
  --success-soft: #064E3B;
  --success-text: #86EFAC;
  --warning: #F59E0B;
  --warning-soft: #451A03;
  --warning-text: #FDE68A;
  --danger: #EF4444;
  --danger-soft: #450A0A;
  --danger-text: #FCA5A5;
  --neutral-soft: #1E293B;
  --neutral-text: #CBD5E1;
  --notice: #0F2042;
  --notice-border: #1D4ED8;
  --shadow: rgba(0, 0, 0, 0.4);
  --series-1: #3B82F6;
  --series-2: #d95926;
  --sample: #94A3B8;
  --sample-soft: #1A2335;
  --hatch: rgba(148, 163, 184, 0.2);
  --preview-border: #475569;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 110px; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -0.39px; }
h2 { font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.2px; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
p { margin: 0; }
a { color: var(--info-text); }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 16px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Buttons and inputs */
button { font: inherit; cursor: pointer; }
.btn-primary, .btn-outline, .btn-ghost {
  border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 14px; line-height: 20px;
  border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--primary-text); width: 100%; padding: 12px 16px; margin-top: 16px; }
.btn-primary:hover { background: var(--primary-pressed); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-raised); }
.btn-ghost { background: transparent; color: var(--info-text); }
.btn-ghost:hover { background: var(--primary-soft); }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; width: 100%;
}
select { padding: 6px 10px; width: auto; min-width: 120px; }
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }

/* Sign-in */
.signin { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.signin-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: 0 8px 24px var(--shadow);
}
.signin-card h1 { margin: 20px 0 8px; font-size: 24px; line-height: 30px; }
.signin-card .btn-ghost { width: 100%; margin-top: 8px; }
.signin-foot { color: var(--muted); font-size: 12px; margin-top: 16px; }
.password-row { display: flex; gap: 8px; }
.password-row .btn-ghost { width: auto; margin: 0; }
#code { letter-spacing: 6px; font-size: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.hint { color: var(--muted); font-size: 12px; line-height: 16px; margin-top: 12px; }
.notice { background: var(--notice); border: 1px solid var(--notice-border); border-radius: 8px; padding: 10px 12px; margin: 16px 0 0; color: var(--text); }
.notice-danger { background: var(--danger-soft); border-color: var(--danger); }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; letter-spacing: -0.2px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
}
.brand-logo { background: none; object-fit: cover; }
.brand-lg { font-size: 18px; }
.brand-lg .brand-mark { width: 34px; height: 34px; font-size: 13px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1680px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 20px; }
.topbar-title { display: flex; flex-direction: column; line-height: 18px; min-width: 0; }
.topbar-title #org-name { font-weight: 600; white-space: nowrap; }
.topbar-title .muted { font-size: 12px; white-space: nowrap; }
.topnav { display: flex; gap: 2px; margin-left: auto; flex-wrap: wrap; }
.topnav a { color: var(--muted); text-decoration: none; font-weight: 500; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.topnav a:hover { background: var(--surface-raised); color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.who { color: var(--muted); font-size: 13px; padding: 0 6px; white-space: nowrap; }
@media (max-width: 1560px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 6px; }
  .topnav { order: 3; width: 100%; margin-left: 0; }
  .topbar-actions { margin-left: auto; }
}

/* Layout */
.content { max-width: 1680px; margin: 0 auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 20px; }
.section { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.section-head { margin-bottom: 14px; }
.section-head .muted { margin-top: 2px; }
.section-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1500px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.page-foot { color: var(--subtle); font-size: 12px; text-align: center; padding-top: 8px; }
.empty { color: var(--muted); padding: 12px 0; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1280px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; min-width: 0; }
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.24px; text-transform: uppercase; }
.tile-value { font-size: 30px; line-height: 38px; font-weight: 700; letter-spacing: -0.6px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tile-sub strong { color: var(--text); font-weight: 600; }
.risk-counts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.risk-count { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.risk-count .num { font-weight: 700; font-size: 18px; }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px 2px 7px;
  font-size: 12px; line-height: 18px; font-weight: 600; white-space: nowrap;
}
.pill svg { width: 13px; height: 13px; flex: none; }
.pill-on_track, .pill-success { background: var(--success-soft); color: var(--success-text); }
.pill-at_risk, .pill-warning { background: var(--warning-soft); color: var(--warning-text); }
.pill-behind, .pill-danger { background: var(--danger-soft); color: var(--danger-text); }
.pill-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.pill-info { background: var(--primary-soft); color: var(--info-text); }

/* Bars (pipeline, money) */
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: grid; grid-template-columns: minmax(150px, 230px) 1fr 44px; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 6px; }
.bar-row:hover, .bar-row:focus-visible { background: var(--surface-raised); }
.bar-label { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-label .step { color: var(--muted); font-variant-numeric: tabular-nums; display: inline-block; width: 22px; }
.bar-track { height: 14px; position: relative; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 0; }
.bar-fill.zero { background: transparent; }
.bar-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-value.zero { color: var(--subtle); font-weight: 500; }
.phase { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.28px; text-transform: uppercase; margin: 10px 0 2px 4px; }
.phase:first-child { margin-top: 0; }

/* Stacked bar (value by risk) */
.stack { display: flex; height: 18px; gap: 2px; margin: 10px 0 12px; }
.stack > div { height: 100%; }
.stack > div:first-child { border-radius: 4px 0 0 4px; }
.stack > div:last-child { border-radius: 0 4px 4px 0; }
.stack > div:only-child { border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.list .main { min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { color: var(--muted); font-size: 13px; }
.list .side { text-align: right; white-space: nowrap; flex: none; }
.list button.link { background: none; border: 0; padding: 0; color: var(--info-text); font-weight: 600; text-align: left; }
.list button.link:hover { text-decoration: underline; }
.group-title { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 4px; }
.group-title:first-child { margin-top: 0; }
.count-badge { background: var(--surface-raised); color: var(--text); border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Filters + table */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 12px; }
.filters label { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.filters .btn-ghost { padding: 6px 10px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.ptable { width: 100%; min-width: 1060px; border-collapse: collapse; font-size: 13px; }
.ptable th, .ptable td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ptable tbody tr:last-child td { border-bottom: 0; }
.ptable th { background: var(--surface-raised); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
.ptable th button { background: none; border: 0; padding: 0; color: inherit; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.ptable th[aria-sort] button { color: var(--text); }
.ptable td.r, .ptable th.r { text-align: right; }
.ptable tbody tr { cursor: pointer; }
.ptable tbody tr:hover { background: var(--surface-raised); }
.ptable .pname { font-weight: 600; color: var(--text); background: none; border: 0; padding: 0; text-align: left; }
.ptable .pname:hover { color: var(--info-text); text-decoration: underline; }
.ptable .sub { color: var(--muted); font-size: 12px; }
.progress { width: 130px; }
.progress-track { position: relative; height: 8px; background: var(--track); border-radius: 4px; }
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--series-1); border-radius: 4px; }
.progress-expected { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 1px; }
.progress-text { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.late { color: var(--danger-text); font-weight: 600; }

/* Money cards */
.mcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; min-width: 0; }
.mcard h3 { margin-bottom: 2px; }
.mcard .big { font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -0.4px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin-top: 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Preview (sample) section */
.preview {
  border: 2px dashed var(--preview-border); border-radius: 14px; padding: 0 20px 20px;
  background-color: var(--sample-soft);
  background-image: repeating-linear-gradient(135deg, transparent 0 14px, var(--hatch) 14px 16px);
}
.preview-banner {
  margin: 0 -20px 16px; padding: 10px 20px; border-radius: 12px 12px 0 0;
  background: var(--warning-soft); color: var(--warning-text); border-bottom: 1px solid var(--warning);
}
.sample-badge, .sample-tag {
  display: inline-block; vertical-align: middle; margin-left: 8px; border: 1px dashed var(--sample); color: var(--sample);
  border-radius: 999px; padding: 0 8px; font-size: 11px; line-height: 18px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
}
.sample-tag { margin-left: 0; }
.preview .tile, .preview .mcard {
  background: var(--surface); border-style: dashed; border-color: var(--preview-border);
}
.preview .tile-value, .preview .big { color: var(--sample); }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.footnote { color: var(--muted); font-size: 12px; line-height: 17px; margin-top: 14px; max-width: 1100px; }
.preview .tiles { margin-bottom: 16px; }

/* SVG charts */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--surface-raised); opacity: 0.6; }

/* Tooltip */
.tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--text); color: var(--background);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 17px; max-width: 280px; box-shadow: 0 6px 18px var(--shadow);
}
.tooltip strong { display: block; margin-bottom: 2px; }

/* Drill-down */
.drill {
  width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 20px 50px var(--shadow);
}
.drill::backdrop { background: rgba(15, 23, 42, 0.55); }
.drill-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.drill-body { padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 22px; }
.drill-body h3 { margin-bottom: 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.fact { min-width: 120px; }
.fact .k { color: var(--muted); font-size: 12px; }
.fact .v { font-weight: 600; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-raised); display: block; }
.photos figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.gantt .lbl { fill: var(--text); font-size: 12px; font-family: inherit; }
.gantt .planned { fill: var(--track); }
.gantt .actual { fill: var(--series-1); }
.gantt .today { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 3 3; }
