/* =========================================================================
   HGS brand tokens — https://hgs.com/brand/
   Impact Green #ABCF02 · Primary Blue #00B0F0 · System (navy) #26476B
   Foundation Grey #5C6D72 · Core Charcoal #2D2D2D · Teal #3D9B99
   Alerts: Orange #E67300 · Red #D12536
   Type: Kanit (headlines/body/buttons, sentence case), Raleway Medium (sub-heads)
   ========================================================================= */
:root {
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #2d2d2d;              /* Core Charcoal */
  --muted: #5c6d72;            /* Foundation Grey */
  --border: #e2e7e6;
  --navy: #26476b;             /* System */
  --navy-deep: #001c41;
  --brand: #00b0f0;            /* Primary Blue */
  --brand-dark: #0088dd;
  --brand-light: #e6f7fe;
  --accent: #abcf02;           /* Impact Green */
  --accent-ink: #4a5a00;       /* dark-enough text to sit on Impact Green */
  --accent-bg: #f2f8d9;
  --teal: #3d9b99;
  --teal-bg: #e6f4f3;
  --amber: #e67300;
  --amber-bg: #fdecdc;
  --red: #d12536;
  --red-bg: #fbe6e8;
  --blue-bg: #e2f7ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(38, 71, 107, 0.05), 0 4px 16px rgba(38, 71, 107, 0.06);
  --font-head: "Kanit", "Segoe UI", Arial, sans-serif;
  --font-sub: "Raleway", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { font-size: 14px; line-height: 1.45; font-family: var(--font-head); }

header.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel);
  color: var(--navy-deep);
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 3px solid var(--accent);
  box-shadow: var(--shadow);
}
header.appbar .brand { display: flex; align-items: center; gap: 10px; }
header.appbar .wordmark {
  font-family: var(--font-head); font-weight: 700; font-size: 20px; letter-spacing: 0.5px;
  color: var(--navy-deep); display: flex; align-items: center; gap: 6px;
}
header.appbar .wordmark .dot { color: var(--accent); font-size: 22px; line-height: 0; }
header.appbar .brand .divider { width: 1px; height: 26px; background: var(--border); }
header.appbar .brand .title { font-family: var(--font-sub); font-weight: 600; font-size: 14px; color: var(--navy); }
header.appbar .brand .sub { font-weight: 400; font-size: 11.5px; color: var(--muted); }
header.appbar .header-actions { display: flex; align-items: center; gap: 8px; }

nav#tabNav {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  position: sticky; top: 58px; z-index: 19;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.tab-btn, .header-tab-btn {
  border: none; background: transparent; color: var(--muted); font-family: var(--font-head);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab-btn:hover, .header-tab-btn:hover { background: var(--brand-light); color: var(--brand-dark); }
.tab-btn.active, .header-tab-btn.active { background: var(--brand); color: white; }
.header-tab-btn { border: 1px solid rgba(255,255,255,0.5); background: var(--bg); color: var(--navy); }
.header-tab-btn:hover { background: var(--brand-light); }
.header-tab-btn.active { background: var(--navy); color: white; }

main#view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex; flex-direction: column; gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.panel h1 { font-family: var(--font-head); font-weight: 700; font-size: 21px; margin: 0 0 6px; color: var(--navy-deep); }
.panel h2 { font-family: var(--font-sub); font-weight: 600; font-size: 15.5px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--navy-deep); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.intro-panel { background: linear-gradient(135deg, var(--brand-light), #ffffff); border-color: var(--brand-light); }

.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); border-top: 3px solid var(--accent);
  font-family: inherit; text-align: left; width: 100%; margin: 0;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.kpi-card.clickable { cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; }
.kpi-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(38, 71, 107, 0.14); }
.kpi-label { font-family: var(--font-sub); font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.3; }
.kpi-value { font-family: inherit; font-size: 27px; font-weight: 700; margin-top: 4px; color: var(--navy-deep); line-height: 1.2; }
.kpi-sub { font-family: var(--font-sub); font-size: 11px; margin-top: auto; padding-top: 4px; }
/* Dashboard hero rows (Item B/E redesign) — two fixed 6-up rows instead of
   an auto-fit wrap, so the grid never breaks unevenly (e.g. 8-then-2) as
   tiles are added/removed. flex-direction:column + margin-top:auto on
   .kpi-sub above keeps every card's baseline aligned even when one card's
   label wraps to two lines and a neighbour's doesn't. Over-allocated stays
   amber unconditionally (it's the one figure that's always worth a calm
   reminder of); On hold / At-risk only pick up the amber "attention" accent
   once their count is non-zero, same semantics as .cell-amber/.sev-review
   elsewhere. */
.kpi-row-1, .kpi-row-2 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) { .kpi-row-1, .kpi-row-2 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .kpi-row-1, .kpi-row-2 { grid-template-columns: repeat(2, 1fr); } }
.kpi-row-2 { margin-top: 12px; }
.kpi-hero .kpi-card-warn { border-top-color: var(--amber); }
.kpi-hero .kpi-card-warn .kpi-value { color: var(--amber); }

.kpi-chip-row { display: flex; flex-wrap: wrap; gap: 10px; }
.kpi-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-weight: 600; font-family: inherit;
}
.kpi-chip.clickable { cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.kpi-chip.clickable:hover { background: var(--brand-light); border-color: var(--brand); }

/* unified "needs attention" list */
.attn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attn-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--bg); border-left: 4px solid var(--border);
}
.attn-kind { font-family: var(--font-sub); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); min-width: 128px; }
.attn-name { flex: 1; font-weight: 500; }
.attn-value { font-size: 14px; }
.attn-row.sev-critical { border-left-color: var(--red); background: var(--red-bg); }
.attn-row.sev-critical .attn-value { color: var(--red); }
.attn-row.sev-over { border-left-color: var(--red); background: var(--red-bg); }
.attn-row.sev-over .attn-value { color: var(--red); }
.attn-row.sev-review { border-left-color: var(--amber); background: var(--amber-bg); }
.attn-row.sev-review .attn-value { color: var(--amber); }
.attn-row.sev-under { border-left-color: var(--brand); background: var(--blue-bg); }
.attn-row.sev-under .attn-value { color: var(--brand-dark); }
.attn-row.sev-none { border-left-color: var(--accent); background: var(--accent-bg); }
.attn-row.sev-more { border-left-color: var(--border); background: transparent; color: var(--muted); font-size: 12.5px; font-style: italic; justify-content: center; }
.attn-row.sev-leave { border-left-color: var(--teal); background: var(--teal-bg); }
.attn-row.clickable { cursor: pointer; border: none; width: 100%; font-family: inherit; font-size: inherit; text-align: left; transition: filter 0.12s, transform 0.12s; }
.attn-row.clickable:hover { filter: brightness(0.97); transform: translateX(2px); }
.attn-group-label { font-family: var(--font-sub); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--navy); margin: 14px 0 6px; }
.attn-group-label:first-of-type { margin-top: 0; }

/* Needs-attention / leave — card grid (Dashboard redesign). Same colour
   semantics as .attn-row above (kept for any other consumer), presented as
   a responsive grid of small cards with an icon + coloured left edge,
   rather than a single-column list, so it reads as a scannable panel of
   the app's existing card language, not a plain list. */
.attn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin: 0; padding: 0; }
.attn-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border); border-left: 4px solid var(--border);
  box-shadow: 0 1px 2px rgba(38, 71, 107, 0.05);
  font-family: inherit; text-align: left; width: 100%; margin: 0;
}
.attn-icon { font-size: 15px; line-height: 1; flex-shrink: 0; }
.attn-card-body { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.attn-card .attn-kind { font-family: var(--font-sub); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.attn-card .attn-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn-card .attn-value { font-size: 14px; flex-shrink: 0; }
.attn-card.sev-critical { border-left-color: var(--red); background: var(--red-bg); }
.attn-card.sev-critical .attn-value { color: var(--red); }
.attn-card.sev-over { border-left-color: var(--red); background: var(--red-bg); }
.attn-card.sev-over .attn-value { color: var(--red); }
.attn-card.sev-review { border-left-color: var(--amber); background: var(--amber-bg); }
.attn-card.sev-review .attn-value { color: var(--amber); }
.attn-card.sev-under { border-left-color: var(--brand); background: var(--blue-bg); }
.attn-card.sev-under .attn-value { color: var(--brand-dark); }
.attn-card.sev-none { border-left-color: var(--accent); background: var(--accent-bg); grid-column: 1 / -1; }
.attn-card.sev-more { border-left-color: var(--border); background: transparent; color: var(--muted); font-size: 12.5px; font-style: italic; justify-content: center; box-shadow: none; }
.attn-card.sev-leave { border-left-color: var(--teal); background: var(--teal-bg); }
.attn-card.clickable { cursor: pointer; transition: filter 0.12s, transform 0.12s; }
.attn-card.clickable:hover { filter: brightness(0.97); transform: translateY(-1px); }

/* Dashboard charts */
.chart-panel h2 { margin-bottom: 2px; }
.chart-empty { padding: 24px 0; text-align: center; }

.bar-chart { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bar-chart-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 10px; }
.bar-chart-label { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-chart-track { position: relative; height: 14px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-chart-fill { height: 100%; border-radius: 999px; transition: width 0.2s; }
.bar-chart-fill.bar-over { background: var(--red); }
.bar-chart-fill.bar-healthy { background: var(--accent); }
.bar-chart-fill.bar-under { background: var(--brand); }
.bar-chart-ref { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 2px dashed rgba(38,71,107,0.35); }
.bar-chart-value { font-size: 12.5px; font-weight: 700; text-align: right; color: var(--navy-deep); }
.bar-chart-legend { font-size: 11px; margin-top: 4px; }
.legend-dot.bar-over { background: var(--red); }
.legend-dot.bar-healthy { background: var(--accent); }
.legend-dot.bar-under { background: var(--brand); }

.trend-svg { width: 100%; height: auto; display: block; margin-top: 6px; }
.trend-area { fill: var(--brand-light); }
.trend-line { fill: none; stroke: var(--brand-dark); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend-dot { fill: var(--brand-dark); }
.trend-dot-cur { fill: var(--navy-deep); stroke: white; stroke-width: 1.5; }
.trend-ref-line { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 4 3; }
.trend-ref-label { font-size: 9px; fill: var(--amber); font-family: var(--font-sub); }
.trend-month-label { font-size: 9px; fill: var(--muted); font-family: var(--font-sub); }
.trend-month-label.cur { fill: var(--navy-deep); font-weight: 700; }

/* Dashboard "as of" date filter (Item A) */
.dash-filter-panel { padding: 12px 20px; }
.dash-filter-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dash-filter-label {
  display: flex; align-items: center; gap: 8px; font-family: var(--font-sub);
  font-weight: 600; font-size: 12.5px; color: var(--navy);
}
.dash-filter-input {
  border: 1px solid var(--border); background: white; border-radius: 6px;
  padding: 6px 8px; font-size: 12.5px; font-family: inherit; color: var(--ink);
}
.dash-filter-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }

/* Projects-by-status vertical stack (Item E) — minimal, numbers-only,
   click-through rows replacing the old horizontal chip row. */
.status-stack { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.status-stack-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; font-family: inherit; cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.status-stack-row:hover { background: var(--brand-light); border-color: var(--brand); }
.status-stack-count { font-size: 16px; font-weight: 700; color: var(--navy-deep); font-variant-numeric: tabular-nums; }

/* Utilisation trend — billable/non-billable lines + dynamic capacity
   reference line (Items G & H) */
.trend-line-billable { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-line-nonbillable { fill: none; stroke: var(--navy); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 5 3; }
.trend-ref-line-path { fill: none; stroke: var(--amber); stroke-width: 1.25; stroke-dasharray: 4 3; }

/* Actual-vs-Planned billable/non-billable points on the utilisation trend
   line above — filled dot = Actual (imported hours), hollow dot = Planned
   estimate (allocation-based). See computeMonthlyBillableSplitWithSource. */
.billsrc-dot-actual { fill: var(--teal); stroke: none; }
.billsrc-dot-planned { fill: white; stroke: var(--teal); stroke-width: 1.5; }
.nbsrc-dot-actual { fill: var(--navy); stroke: none; }
.nbsrc-dot-planned { fill: white; stroke: var(--navy); stroke-width: 1.5; }
.src-legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 2px -1px 4px; background: var(--teal); }
.src-legend-dot.src-legend-planned { background: white; border: 1.5px solid var(--teal); }

/* Small "Actual" / "Planned (est.)" source badge — Dashboard hour KPI
   tiles (billable/non-billable hours) and anywhere else that needs to flag
   which figures come from imported actuals vs an allocation-based estimate. */
.src-pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-left: 5px; vertical-align: middle; }
.src-pill-actual { background: var(--teal-bg); color: var(--teal); }
.src-pill-planned { background: #ececec; color: #666; }

/* Planned vs Actual utilisation chart (Insights → Utilisation) */
.pva-svg { margin-top: 4px; }
.pva-bar.pva-planned { fill: var(--brand); }
.pva-bar.pva-actual { fill: var(--teal); }
.pva-bar.pva-nodata { fill: #d7dcdb; }
.legend-dot.pva-planned { background: var(--brand); }
.legend-dot.pva-actual { background: var(--teal); }
.legend-dot.pva-nodata { background: #d7dcdb; }
.pva-nodata-label { font-size: 8.5px; font-style: italic; fill: var(--muted); font-family: var(--font-sub); }

/* MoM project trend chart — new / completed / on-hold (Item F) */
.mom-svg { margin-top: 4px; }
.mom-axis { stroke: var(--border); stroke-width: 1; }
.mom-bar.mom-new { fill: var(--brand); }
.mom-bar.mom-completed { fill: var(--accent); }
.mom-bar.mom-onhold { fill: var(--amber); }
.legend-dot.mom-new { background: var(--brand); }
.legend-dot.mom-completed { background: var(--accent); }
.legend-dot.mom-onhold { background: var(--amber); }
.mom-summary { font-weight: 600; color: var(--navy-deep); margin: 10px 0 4px; }
.mom-note { font-size: 11.5px; margin: 0; }

/* Billable/non-billable by group (Dashboard) */
.billing-group-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 10px; }
.billing-group-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.billing-group-head { font-weight: 700; font-size: 13px; color: var(--navy-deep); margin-bottom: 6px; }
.billing-group-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--border); margin-bottom: 8px; }
.billing-group-bar-billable { height: 100%; background: var(--teal); }
.billing-group-bar-nonbillable { height: 100%; background: #b9c2c4; }
.billing-group-card .kpi-chip-row { gap: 6px; }
.billing-group-card .kpi-chip { padding: 4px 9px; font-size: 12px; }

/* Insights-summary panel (Item I, Dashboard redesign round 2) — three
   click-through cards, one per Insights sub-view, matching the same
   card language (bg panel, border, radius) already used by
   .billing-group-card / .kpi-card elsewhere on the Dashboard. */
.insight-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 10px; }
.insight-summary-card {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-family: inherit; width: 100%; margin: 0;
}
.insight-summary-card.clickable { cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.12s; }
.insight-summary-card.clickable:hover { background: var(--brand-light); border-color: var(--brand); transform: translateY(-1px); }
.insight-summary-head { font-family: var(--font-sub); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--navy); }
.insight-summary-stat { font-size: 22px; font-weight: 700; color: var(--navy-deep); margin-top: 2px; }
.insight-summary-stat-label { font-size: 11px; margin-top: -2px; }
.insight-summary-sub { font-size: 11.5px; margin-top: 6px; }

/* Executive summary panel (Item J, reorganized) — narrative, three-column
   read (Accomplishments / Next steps / Risks & notes), one content type per
   column: plain factual sentences, not marketing copy, so type stays at
   body size rather than the larger KPI/heading treatments used elsewhere. */
.exec-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 8px; }
@media (max-width: 1100px) { .exec-summary-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .exec-summary-grid { grid-template-columns: 1fr; } }
.exec-summary-col-risk { border-left: 2px solid var(--amber-bg); padding-left: 16px; }
@media (max-width: 1100px) { .exec-summary-col-risk { border-left: none; padding-left: 0; grid-column: 1 / -1; } }
.exec-summary-label { font-family: var(--font-sub); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--navy); margin-bottom: 6px; }
.exec-summary-line { margin: 0 0 8px; font-size: 13px; line-height: 1.5; }
.exec-summary-line:last-child { margin-bottom: 0; }
.exec-summary-line a { color: var(--brand-dark); }
.exec-notes { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.exec-notes-label { font-weight: 700; font-size: 12px; color: var(--navy-deep); margin-bottom: 4px; }
.exec-notes-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.exec-notes-list li { font-size: 12.5px; background: var(--bg); border-radius: 8px; padding: 6px 10px; }
.exec-notes-empty { margin-top: 10px; font-size: 12.5px; }

@keyframes rowFlash { 0%, 60% { background: var(--brand-light); } 100% { background: transparent; } }
tr.flash td { animation: rowFlash 2s ease-out; }
tr.flash td.sticky-col { animation: rowFlash 2s ease-out; }
li.flash { outline: 2px solid var(--brand); outline-offset: 2px; }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mini-list li { display: flex; justify-content: space-between; padding: 6px 10px; background: var(--bg); border-radius: 8px; }
.mini-list li.muted { justify-content: flex-start; }

.txt-red { color: var(--red); }
.txt-amber { color: var(--amber); }
.txt-green { color: var(--teal); }
.txt-blue { color: var(--brand-dark); }

.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 2px -1px 4px; }
.legend-panel { padding: 12px 20px; font-size: 12.5px; }

.fixes-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.fixes-list.hidden { display: none; }

/* segmented control (Insights sub-nav) */
.seg-row { display: inline-flex; gap: 3px; background: var(--bg); border: 1px solid var(--border); padding: 3px; border-radius: 999px; width: fit-content; }
.seg-btn {
  border: none; background: transparent; color: var(--muted); font-family: var(--font-head);
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.seg-btn:hover { color: var(--brand-dark); }
.seg-btn.active { background: var(--navy); color: white; }

/* buttons */
.btn {
  border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: filter 0.15s, background 0.15s; font-family: var(--font-head);
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--brand-light); color: var(--brand-dark); }
.btn-secondary:hover { filter: brightness(0.97); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-xs { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.file-btn { position: relative; display: inline-flex; align-items: center; }

/* tables */
.table-scroll { overflow: auto; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
table.grid-table { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 12.5px; }
table.grid-table th, table.grid-table td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 4px 6px; text-align: center; white-space: nowrap; }
table.grid-table th { background: #f4f7f8; position: sticky; top: 0; z-index: 2; font-weight: 700; color: var(--navy); font-family: var(--font-sub); }
table.grid-table td.name-cell, table.grid-table th.sticky-col { text-align: left; }
table.grid-table .sticky-col { position: sticky; left: 0; background: #fff; z-index: 3; box-shadow: 2px 0 4px rgba(0,0,0,0.03); }
table.grid-table th.sticky-col { z-index: 4; background: #f4f7f8; }
table.grid-table tbody tr:hover td { background: #f7fbfd; }
table.grid-table tbody tr:hover td.sticky-col { background: #f7fbfd; }
th.cur-month, td.cur-month { background: var(--brand-light) !important; }
table.grid-table th.role-head { min-width: 90px; }

.cell-input {
  width: 100%; min-width: 46px; border: 1px solid transparent; background: transparent;
  border-radius: 4px; padding: 4px 4px; font-size: 12.5px; text-align: center; color: var(--ink);
  font-family: inherit;
}
.cell-input:hover { border-color: var(--border); }
.cell-input:focus { outline: none; border-color: var(--brand); background: white; box-shadow: 0 0 0 2px var(--brand-light); }
.name-input { text-align: left; min-width: 170px; font-weight: 600; }
.notes-input { text-align: left; min-width: 160px; }
.role-input { min-width: 120px; }
.role-pct-input { width: 56px; }
select.cell-input { cursor: pointer; min-width: 108px; }
input[type="date"].cell-input { min-width: 120px; }
.readonly { color: var(--muted); background: #fafbfd; }
.comment-cell { text-align: left; min-width: 220px; white-space: normal; }

.cell-green { background: var(--accent-bg) !important; }
.cell-amber { background: var(--amber-bg) !important; }
.cell-red { background: var(--red-bg) !important; }
.cell-blue { background: var(--blue-bg) !important; }

.status-pill, .pr-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.st-active { background: var(--accent-bg); color: var(--accent-ink); }
.st-planning { background: var(--blue-bg); color: var(--brand-dark); }
.st-pipeline { background: #ececec; color: #666; }
.st-hold { background: var(--amber-bg); color: var(--amber); }
.st-completed { background: var(--teal-bg); color: var(--teal); }
.st-billable { background: var(--teal-bg); color: var(--teal); }
.st-nonbillable { background: #ececec; color: #666; }
.pr-high { background: var(--red-bg); color: var(--red); }
.pr-medium { background: var(--amber-bg); color: var(--amber); }
.pr-low { background: #eee; color: #666; }

.badge { display: inline-block; min-width: 22px; padding: 2px 6px; border-radius: 6px; font-size: 11px; font-weight: 800; }
.badge-c { background: var(--red-bg); color: var(--red); }
.badge-r { background: var(--amber-bg); color: var(--amber); }
.badge-ok { background: var(--accent-bg); color: var(--accent-ink); }
.score-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* Allocations grid — compact per-cell status icon (replaces the old
   verbose "44h left" / "over by 132h" text line). Colour matches the
   cell's own background tint so it reads as reinforcement, not noise;
   the exact hour figure lives in this element's title tooltip. */
.cell-icon { font-size: 12px; line-height: 1; cursor: default; }
.cell-red .cell-icon { color: var(--red); }
.cell-green .cell-icon { color: var(--accent-ink); }
.cell-blue .cell-icon { color: var(--brand); }
.cell-amber .cell-icon { color: var(--amber); }

footer.appfoot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; font-family: var(--font-sub); }

/* Resources — working-hours sub-label under month header */
.th-sub { font-weight: 400; font-size: 10px; color: var(--muted); margin-top: 2px; text-transform: none; letter-spacing: 0; }

/* Resources — capacity cell + holiday/leave note icon.
   The number gets the cell's full width; the note toggle is a small
   corner badge layered on top rather than squeezed in beside it, so the
   value stays legible even when the column itself is narrow. */
table.grid-table td:has(.cap-cell), table.grid-table th.sortable:has(.th-sub) { min-width: 68px; }
.cap-cell { position: relative; }
.cap-cell .cell-input { width: 100%; min-width: 52px; padding: 4px 11px 4px 4px; text-align: center; font-size: 12.5px; }
.note-btn {
  position: absolute; top: 2px; right: 2px; width: 11px; height: 11px; line-height: 11px;
  border: none; background: transparent; cursor: pointer; font-size: 7px; text-align: center;
  padding: 0; border-radius: 50%; opacity: 0.35; color: var(--muted);
}
.note-btn:hover { opacity: 1; background: var(--bg); }
.note-btn.has-note { opacity: 1; color: var(--amber); background: var(--amber-bg); }
/* Logged-holiday month cell — a real amber fill (matching the same
   --amber-bg fill used everywhere else in the app for "highlighted in
   amber": .cell-amber, .st-hold, .pr-medium, .badge-r, .sev-review, …)
   rather than an inset box-shadow border alone. A box-shadow-only outline
   on a <td> inside a `border-collapse: collapse` table gets painted under
   the neighbouring cells' collapsed borders in most browsers, so it read
   as "basically invisible" even though the class was applied correctly —
   this is the fix for that. The border is kept as a secondary accent now
   that the fill makes the cell unmistakably highlighted. */
td.has-note { background: var(--amber-bg) !important; box-shadow: inset 0 0 0 2px var(--amber); position: relative; z-index: 1; }
.legend-dot.note-dot { background: var(--amber); border-radius: 50%; }

/* Projects — status filter chips */
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-filter {
  border: 1px solid var(--border); background: var(--panel); color: var(--ink); font-family: inherit;
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.chip-filter:hover { background: var(--brand-light); border-color: var(--brand); }
.chip-filter.active { background: var(--navy); color: white; border-color: var(--navy); }
.chip-filter.active .muted { color: rgba(255,255,255,0.75); }

/* Projects — multi-line bullet notes */
td.notes-cell { white-space: normal; }
textarea.notes-input { min-width: 200px; min-height: 60px; text-align: left; resize: vertical; line-height: 1.4; white-space: pre-wrap; }
textarea.notes-input::placeholder { color: var(--muted); opacity: 0.65; font-style: italic; }

/* Modal (holiday/public holiday capture) */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 28, 65, 0.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: var(--panel); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  padding: 22px 24px; width: 420px; max-width: 100%; max-height: 90vh; overflow: auto;
}
.modal-box h3 { margin: 0 0 8px; font-family: var(--font-sub); color: var(--navy-deep); font-size: 16px; }
.modal-label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--navy); margin-top: 12px; }
.modal-label .cell-input { border: 1px solid var(--border); text-align: left; padding: 7px 8px; }
.modal-suggest { margin-top: 12px; font-size: 12.5px; background: var(--accent-bg); border-radius: 8px; padding: 8px 10px; min-height: 0; }
.modal-suggest:empty { padding: 0; }
.modal-actions { margin-top: 16px; }

/* "Add assignment" modal (Allocations tab) — same modal-box/modal-label
   pattern as the holiday note modal above, just a touch wider to fit the
   Project/Resource selects and role-fill chips comfortably. */
.add-assignment-box { width: 480px; }
.alloc-hint { font-size: 11.5px; margin: 4px 0 0; min-height: 14px; }

/* Role-fill counts (Item 3) — compact, numbers-only "Role X/Y" chips.
   Shared between the small summary strip above the Allocations table and
   the live context inside the "Add assignment" modal, so both read
   identically. Colour reuses the app's existing txt-red/txt-amber/
   txt-green vocabulary (see .role-fill-chip's cls in roleFillChipsHtml). */
.role-fill-summary { font-size: 12.5px; margin: 4px 0 12px; }
.role-fill-row { margin-top: 4px; }
.role-fill-chip { display: inline-block; margin: 2px 10px 2px 0; font-size: 12px; }
.role-fill-chip b { font-variant-numeric: tabular-nums; }

/* "Import Actual Hours" modal (Actuals tab) — same modal-box/modal-label
   pattern as the other modals, wider still to comfortably fit the review
   table of distinct projects + their billable toggle. */
.import-actuals-box { width: 560px; }
.import-actuals-review { width: 620px; }
.ia-error { margin-top: 10px; }
.file-drop {
  margin-top: 12px; border: 2px dashed var(--border); border-radius: 10px;
  padding: 22px 16px; text-align: center; transition: background 0.12s, border-color 0.12s;
}
.file-drop p { margin: 0 0 8px; }
.file-drop p:last-child { margin-bottom: 0; }
.file-drop-active { background: var(--brand-light); border-color: var(--brand); }
.ia-summary-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px;
  margin-top: 12px; font-size: 12.5px;
}
.ia-summary-grid > div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.ia-cols { margin-top: 8px; }
.ia-subhead { margin: 16px 0 6px; font-size: 13px; color: var(--navy-deep); }
.ia-projects-scroll { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.ia-projects-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.ia-projects-table th, .ia-projects-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
.ia-projects-table th { background: #f4f7f8; font-weight: 700; color: var(--navy); font-family: var(--font-sub); position: sticky; top: 0; }
.ia-projects-table tbody tr:last-child td { border-bottom: none; }
.ia-projects-table .ia-billable-select { padding: 4px 6px; width: auto; min-width: 130px; border: 1px solid var(--border); background: var(--panel); }
.ia-warnings, .ia-unmatched {
  margin-top: 12px; background: var(--amber-bg); color: var(--amber); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5;
}
.ia-unmatched b { display: block; margin-bottom: 4px; }

/* Add-assignment modal's pending queue (Item 1) — one removable line item
   per resource added before "Save assignments" is clicked. */
.aa-queue-empty { margin: 10px 0; font-size: 12.5px; }
.aa-queue-list { margin: 10px 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.aa-queue-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; font-size: 12.5px; border-bottom: 1px solid var(--border);
}
.aa-queue-item:last-child { border-bottom: none; }
.aa-queue-item:nth-child(even) { background: var(--bg); }
.aa-queue-remove { padding: 2px 8px; line-height: 1; }

/* Header — logged-in user chip */
.user-chip {
  font-family: var(--font-sub); font-size: 12px; font-weight: 600; color: var(--navy);
  white-space: nowrap;
}

/* Version history + audit log — tags */
.tag-auto, .tag-manual {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.tag-auto { background: var(--bg); color: var(--muted); }
.tag-manual { background: var(--blue-bg); color: var(--brand-dark); }

.tag-action {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.tag-create { background: var(--accent-bg); color: var(--accent-ink); }
.tag-update { background: var(--blue-bg); color: var(--brand-dark); }
.tag-delete { background: var(--red-bg); color: var(--red); }
.tag-import { background: var(--teal-bg); color: var(--teal); }
.tag-restore { background: var(--amber-bg); color: var(--amber); }
.tag-version { background: #ececec; color: #666; }

table.grid-table.log-table { min-width: 0; }
table.grid-table.log-table td { white-space: normal; text-align: left; }
table.grid-table.log-table td.nowrap { white-space: nowrap; }

/* Sortable column headers + per-column filter row, shared by every table */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: var(--blue-bg); color: var(--brand-dark); }
.sort-ind { font-size: 9px; margin-left: 2px; }
.sort-ind.muted { opacity: 0.35; }
.sort-ind.active { color: var(--brand-dark); opacity: 1; }

tr.filter-row-cells td { background: #fafbfd; padding: 3px 4px; }
tr.filter-row-cells td.sticky-col { background: #fafbfd; }
.filter-input {
  width: 100%; min-width: 70px; border: 1px solid var(--border); background: white;
  border-radius: 5px; padding: 4px 6px; font-size: 11.5px; font-family: inherit; color: var(--ink);
}
.filter-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }
select.filter-input { cursor: pointer; }

.table-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px; font-size: 12px;
}
.table-toolbar-actions { display: flex; align-items: center; gap: 8px; }

/* Column visibility picker — Excel-style "hide column" */
.col-picker { position: relative; }
.col-picker-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14); padding: 8px; min-width: 190px; max-width: 260px;
  max-height: 320px; overflow-y: auto;
}
.col-picker-menu[hidden] { display: none; }
.col-picker-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: var(--font-sub); font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--muted); padding: 2px 4px 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.btn-link { border: none; background: none; color: var(--brand-dark); font-weight: 600; font-size: 11px; cursor: pointer; padding: 0; font-family: inherit; text-transform: none; letter-spacing: 0; }
.btn-link:hover { text-decoration: underline; }
.col-picker-item {
  display: flex; align-items: center; gap: 7px; padding: 4px; border-radius: 5px;
  font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.col-picker-item:hover { background: var(--bg); }
.col-picker-item input { cursor: pointer; }

/* Data tab — "How to use this planner" instructions */
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 6px; }
.help-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  border-top: 3px solid var(--teal); padding: 12px 14px;
}
.help-card h4 { margin: 0 0 8px; font-family: var(--font-sub); font-size: 13px; color: var(--navy-deep); }
.help-card ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink); }
.help-card li::marker { color: var(--teal); }

/* Login gate — full-screen overlay shown until someone is signed in */
.login-overlay { z-index: 200; background: linear-gradient(135deg, var(--navy-deep), var(--navy)); }
.login-box { width: 380px; text-align: center; }
.login-brand { margin-bottom: 10px; }
.login-brand .wordmark { font-family: var(--font-head); font-weight: 700; font-size: 24px; color: var(--navy-deep); display: inline-flex; align-items: center; gap: 6px; }
.login-brand .dot { color: var(--accent); font-size: 26px; line-height: 0; }
.login-box h3 { text-align: left; }
.login-box p.muted { text-align: left; }
.login-box .modal-label { text-align: left; }
.login-error { color: var(--red); font-size: 12.5px; font-weight: 600; min-height: 0; text-align: left; }
.login-error:empty { display: none; }
.login-box .modal-actions button { width: 100%; }
.login-switch { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.login-switch a { color: var(--brand-dark); font-weight: 600; text-decoration: none; }
.login-switch a:hover { text-decoration: underline; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-restore { width: 100%; justify-content: center; font-size: 12px; }
.login-caveat { text-align: left; font-size: 11px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); line-height: 1.5; }
.dev-mode-banner {
  text-align: left; font-size: 12px; line-height: 1.5; margin: 10px 0;
  background: var(--accent-bg); color: var(--accent-ink); border: 1px dashed var(--accent);
  border-radius: 8px; padding: 8px 10px; word-break: break-all;
}
.dev-mode-banner a { color: var(--accent-ink); }

body.locked header.appbar, body.locked nav#tabNav, body.locked main#view, body.locked footer.appfoot { filter: blur(3px); pointer-events: none; user-select: none; }

@media (max-width: 680px) {
  header.appbar { flex-wrap: wrap; row-gap: 8px; }
  .login-box { width: 100%; }
}
