/* =========================================================
 * TITAN — DuluxGroup theme
 * Light by default (matches duluxgroup.com.au look & feel),
 * dark variant kicks in via prefers-color-scheme: dark.
 * ========================================================= */

:root {
  /* DuluxGroup brand */
  --dulux-red: #d10024;
  --dulux-red-dark: #a8001d;
  --dulux-red-soft: #e8546a;     /* lighter, friendlier hover */
  --dulux-red-tint: #fdecef;     /* very light wash for hover bgs */
  --dulux-navy: #1d2a3a;
  --dulux-navy-2: #2c3e50;

  /* Light surface tokens */
  --bg:        #ffffff;
  --surface:   #f6f7f9;
  --surface-2: #eef0f3;
  --border:    #dfe3e8;
  --text:      #1a2330;
  --muted:     #5b6470;
  --accent:    var(--dulux-red);
  --link:      #0a558c;
  --success:   #1a7f37;
  --error:     #b42318;
  --warn:      #b76e00;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, .08);
  --radius:    6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1418;
    --surface:   #161b22;
    --surface-2: #1c232c;
    --border:    #2a313c;
    --text:      #e6edf3;
    --muted:     #9aa4b1;
    --link:      #6cb6ff;
    --success:   #3fb950;
    --error:     #ff7b72;
    --warn:      #d29922;
    --dulux-red-tint: rgba(232, 84, 106, 0.12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: var(--dulux-navy);
  color: #fff;
  border-bottom: 3px solid var(--dulux-red);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo {
  width: 42px; height: 42px;
  background: var(--dulux-red);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  letter-spacing: 1px;
}
.brand .title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 3px;
  font-weight: 700;
}
.brand .title span {
  font-size: 11px;
  opacity: .85;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.auth { display: flex; align-items: center; gap: 10px; }
.auth .user { font-size: 13px; opacity: .92; }

/* ---------- Buttons ---------- */
button {
  background: var(--dulux-red);
  color: #fff;
  border: 0;
  padding: 8px 16px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
}
button:hover:not(:disabled) { background: var(--dulux-red-soft); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  opacity: .85;
}
button.ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, .08);
  opacity: 1;
}

/* In the body (non-topbar), ghost buttons should adapt to surface */
main button.ghost {
  color: var(--text);
  border-color: var(--border);
  opacity: 1;
}
main button.ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

/* ---------- Layout ---------- */
main {
  max-width: 1240px;
  margin: 24px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.prompt-card,
.results-card,
.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.prompt-card label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: .3px;
  color: var(--text);
}
.prompt-card textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.prompt-card textarea:focus {
  outline: 2px solid var(--dulux-red);
  border-color: transparent;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
  align-items: center;
}
.examples span {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}
.chip {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 99px;
}
.chip:hover {
  background: var(--dulux-red-tint);
  border-color: var(--dulux-red-soft);
}

.sub-chips {
  margin-top: -4px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.sub-chips span#subChipsLabel {
  font-weight: 600;
  color: var(--text);
}
.sub-chips .chip.secondary {
  background: var(--surface-2);
  border-style: dashed;
}
.sub-chips .chip.secondary.active {
  background: var(--dulux-red-tint);
  border-color: var(--dulux-red);
  color: var(--dulux-red);
  border-style: solid;
  font-weight: 600;
}
.sub-chips .chip.primary.apply-chip {
  background: var(--dulux-red);
  color: #fff;
  border-color: var(--dulux-red);
  font-weight: 600;
  margin-left: 8px;
}
.sub-chips .chip.primary.apply-chip:hover {
  filter: brightness(1.1);
}

/* Context-aware facet bar above tables */
.facets {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.facets .facet-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.facets .facet-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight: 600;
  margin-right: 6px;
  min-width: 110px;
}
.facets .facet-chip {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
  user-select: none;
}
.facets .facet-chip:hover {
  background: var(--dulux-red-tint);
  border-color: var(--dulux-red-soft);
}
.facets .facet-chip.active {
  background: var(--dulux-red);
  color: #fff;
  border-color: var(--dulux-red);
}
.facets .facet-chip .cnt {
  margin-left: 6px;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}
.facets .facet-clear {
  margin-left: auto;
  font-size: 12px;
  color: var(--link);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
.facets .facet-clear:hover { text-decoration: underline; }
.facets .facet-hint {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Empty-state notice */
.empty-state {
  padding: 24px 18px;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text);
  margin-bottom: 12px;
}
.empty-state .es-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dulux-navy);
  margin-bottom: 6px;
}
@media (prefers-color-scheme: dark) {
  .empty-state .es-title { color: var(--text); }
}
.empty-state .es-body {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.status {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
}
.status.success { color: var(--success); }
.status.error   { color: var(--error); }

/* ---------- Results ---------- */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  gap: 12px;
}
.results-header h2 {
  margin: 0;
  font-size: 16px;
  color: var(--dulux-navy);
}
@media (prefers-color-scheme: dark) {
  .results-header h2 { color: var(--text); }
}
.meta { font-size: 12px; color: var(--muted); }

.wiql {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--warn);
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 12px;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg);
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th.th-sort {
  background: var(--surface-2);
  position: sticky;
  top: 0;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.th-sort:hover { color: var(--text); background: var(--surface); }
th .sort-ind {
  display: inline-block;
  margin-left: 6px;
  color: var(--dulux-red);
  font-size: 10px;
  opacity: .9;
}
th .sort-ind.dim { color: var(--muted); opacity: .55; }

tr.th-filter-row th {
  background: var(--surface);
  position: sticky;
  top: 36px;
  padding: 4px 8px;
  text-transform: none;
  letter-spacing: 0;
  cursor: default;
}
tr.th-filter-row input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 12px;
}
tr.th-filter-row input:focus {
  outline: 1px solid var(--dulux-red-soft);
  border-color: transparent;
}
tr:hover td { background: var(--surface); }
td a { color: var(--link); text-decoration: none; }
td a:hover { text-decoration: underline; }
td.drill-cell { cursor: pointer; }
td.drill-cell:hover { background: var(--dulux-red-tint); }
td.drill-cell .drill-link { color: var(--link); font-weight: 600; }

.error-card { border-color: var(--error); }
.error-card pre { color: var(--error); white-space: pre-wrap; word-break: break-all; }

.text-area {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
}
.text-area .wiki-hit {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}
.text-area .wiki-hit:last-child { border-bottom: 0; }
.text-area .wiki-hit a { color: var(--link); font-weight: 600; }
.text-area .wiki-hit .wiki-snippet { color: var(--muted); margin-top: 4px; }

/* ---------- Dashboard ---------- */
#dashboardArea {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 12px;
}
#dashboardArea.bars-hidden > :not(.kpis-row):not(.dash-tabs):not(.dash-view) { display: none; }
#dashboardArea.bars-hidden .dash-view > :not(.kpis-row) { display: none; }
#dashboardArea .dash-view { display: none; }
#dashboardArea .dash-view.active { display: block; }

.dash-tabs {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border, #e0e0e0);
  margin-bottom: 12px;
}
.dash-tab {
  background: transparent; border: none; cursor: pointer;
  padding: 8px 16px; font-size: 14px; font-weight: 500;
  color: var(--muted, #666); border-bottom: 3px solid transparent;
  margin-bottom: -2px; transition: color .15s, border-color .15s;
}
.dash-tab:hover { color: var(--dulux-red, #c8102e); }
.dash-tab.active { color: var(--dulux-red, #c8102e); border-bottom-color: var(--dulux-red, #c8102e); }

.kpis-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.kpi-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--dulux-red);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
  user-select: none;
}
.kpi-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--dulux-red-tint);
  border-color: var(--dulux-red-soft);
}
.kpi-tile.active {
  background: var(--dulux-red-tint);
  border-color: var(--dulux-red-soft);
  box-shadow: 0 0 0 2px rgba(232, 84, 106, .25);
}
.kpi-tile .v {
  font-size: 26px;
  font-weight: 700;
  color: var(--dulux-red);
}
.kpi-tile .l {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 4px;
}

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

.dash-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.dash-card h3 {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.dash-card h3 .muted { font-weight: 500; text-transform: none; letter-spacing: 0; }

/* Prompt-driven chart that appears above the results table */
.chart-area { margin: 0 0 12px; }

/* Workshop monthly calendar */
.calendar-area { margin: 0 0 12px; }
.cal-card { padding: 10px 12px; }
.cal-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.cal-title {
  flex: 1; margin: 0; font-size: 14px; font-weight: 600;
  color: var(--text); text-transform: none; letter-spacing: 0;
}
.cal-nav {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-size: 13px;
}
.cal-nav:hover { background: var(--dulux-red-tint); color: var(--dulux-red); border-color: var(--dulux-red-soft); }
.cal-today { font-size: 11px; }

.cal-filter {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px; margin-bottom: 8px;
}
.cal-filter .facet-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 600; margin-right: 4px;
}
.cal-filter .facet-chip {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 99px;
  font-size: 12px; padding: 3px 10px; cursor: pointer; user-select: none;
}
.cal-filter .facet-chip:hover { background: var(--dulux-red-tint); border-color: var(--dulux-red-soft); }
.cal-filter .facet-chip.active { background: var(--dulux-red); color: #fff; border-color: var(--dulux-red); }
.cal-filter .facet-chip .cnt { margin-left: 6px; opacity: .7; font-variant-numeric: tabular-nums; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  /* Ensure every implicit row reserves at least one cell-height so the
     trailing weeks of the Workshop Calendar never get truncated. */
  grid-auto-rows: minmax(92px, auto);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.cal-dh {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px;
  text-align: center; padding: 6px 0;
}
.cal-cell {
  background: var(--bg);
  min-height: 92px;
  padding: 4px 5px;
  font-size: 11px;
  display: flex; flex-direction: column; gap: 2px;
  /* Without this, nowrap event pills force grid columns wider than 1fr
     and the right-hand weekdays (Thu/Fri/Sat) get clipped off-screen. */
  min-width: 0;
  overflow: hidden;
}
.cal-cell.cal-empty { background: var(--surface); }
.cal-cell.is-today { background: var(--dulux-red-tint); }
.cal-cell.is-today .cal-day { color: var(--dulux-red); font-weight: 700; }
/* Light tints per month to make month boundaries obvious in the team-holiday calendar. */
.cal-cell.cal-mo-0  { background: #fef3f2; }   /* Jan - red tint   */
.cal-cell.cal-mo-1  { background: #fff4e5; }   /* Feb - orange     */
.cal-cell.cal-mo-2  { background: #fffbe6; }   /* Mar - yellow     */
.cal-cell.cal-mo-3  { background: #f0fdf4; }   /* Apr - mint       */
.cal-cell.cal-mo-4  { background: #ecfeff; }   /* May - cyan       */
.cal-cell.cal-mo-5  { background: #eff6ff; }   /* Jun - blue       */
.cal-cell.cal-mo-6  { background: #eef2ff; }   /* Jul - indigo     */
.cal-cell.cal-mo-7  { background: #f5f3ff; }   /* Aug - violet     */
.cal-cell.cal-mo-8  { background: #fdf4ff; }   /* Sep - fuchsia    */
.cal-cell.cal-mo-9  { background: #fff1f2; }   /* Oct - rose       */
.cal-cell.cal-mo-10 { background: #f0fdfa; }   /* Nov - teal       */
.cal-cell.cal-mo-11 { background: #f5f5f4; }   /* Dec - stone      */
.cal-cell.is-today { background: var(--dulux-red-tint) !important; }
/* "All resources" entries (e.g. company-wide public holidays) — highlight dark. */
.cal-cell.is-all-day { background: #1f2937 !important; color: #f8fafc; }
.cal-cell.is-all-day .cal-day,
.cal-cell.is-all-day .cal-mo { color: #f8fafc !important; }
.cal-evt.evt-all { background: #111827; color: #f9fafb; border: 1px solid #374151; font-weight: 600; }
#holidayList tr.row-all td { background: #1f2937; color: #f8fafc; font-weight: 600; }
.res-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1px solid #999; margin-right: 6px; vertical-align: middle; }
.holiday-controls .inline-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.holiday-controls .inline-check input { margin: 0; }
.cal-day {
  font-size: 11px; color: var(--muted); font-weight: 600;
  align-self: flex-end; margin-bottom: 2px;
}
.cal-day .cal-mo { color: var(--dulux-red); font-weight: 700; margin-left: 2px; }
.cal-evt {
  background: var(--dulux-navy);
  color: #fff;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10.5px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.cal-evt:hover { filter: brightness(1.15); }
.cal-evt.evt-func { background: var(--dulux-red); }
.cal-evt.evt-tech { background: #4a6fa5; }
.cal-evt.evt-closed { background: #c8e6c9; color: #1b3a1b; }
.cal-evt.evt-overdue { background: #ffcdd2; color: #5b1414; }
/* Breakout sessions — always brown, overrides workstream/type colors. */
.cal-evt.evt-breakout { background: #6b4423 !important; color: #fff !important; }
/* Workstream color palette (used for future, non-closed workshops when a workstream is set) */
.cal-evt.evt-ws-1 { background: #1f77b4; }
.cal-evt.evt-ws-2 { background: #d62728; }
.cal-evt.evt-ws-3 { background: #2ca02c; }
.cal-evt.evt-ws-4 { background: #ff7f0e; }
.cal-evt.evt-ws-5 { background: #9467bd; }
.cal-evt.evt-ws-6 { background: #17becf; color: #0b3a40; }
.cal-evt.evt-ws-7 { background: #bcbd22; color: #3a3a05; }
.cal-evt.evt-ws-8 { background: #8c564b; }
.ws-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 6px; vertical-align: middle;
}
.ws-swatch.evt-ws-1 { background: #1f77b4; }
.ws-swatch.evt-ws-2 { background: #d62728; }
.ws-swatch.evt-ws-3 { background: #2ca02c; }
.ws-swatch.evt-ws-4 { background: #ff7f0e; }
.ws-swatch.evt-ws-5 { background: #9467bd; }
.ws-swatch.evt-ws-6 { background: #17becf; }
.ws-swatch.evt-ws-7 { background: #bcbd22; }
.ws-swatch.evt-ws-8 { background: #8c564b; }
.cal-more { font-size: 10px; color: var(--dulux-red); padding: 0 4px; text-decoration: underline; cursor: pointer; display: inline-block; }
.cal-more:hover { color: #6b1414; }
.cal-cell.is-expanded { z-index: 2; }
@media (max-width: 700px) {
  .cal-cell { min-height: 70px; }
  .cal-evt { font-size: 10px; padding: 1px 4px; }
}
.chart-card .bar-row { cursor: pointer; border-radius: 4px; padding: 2px 4px; }
.chart-card .bar-row:hover { background: var(--surface); }
.chart-card .bar-row:focus { outline: 2px solid var(--dulux-red-soft); outline-offset: 1px; }
.chart-card .bar-row.active { background: var(--dulux-red-tint); }
.chart-card .bar-row.active .lbl { color: var(--dulux-red); font-weight: 600; }
.chart-card .pct { color: var(--muted); font-weight: 400; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 12px;
}
.bar-row .lbl {
  flex: 0 0 40%;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-row .lbl a {
  color: var(--text);
  text-decoration: none;
}
.bar-row .lbl a:hover { text-decoration: underline; color: var(--link); }
.bar-row .bar {
  flex: 1;
  height: 12px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.bar-row .bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--dulux-red), #f5a524);
}
.bar-row .v {
  flex: 0 0 40px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Process Area x Functional Area matrix */
.matrix-wrap { overflow-x: auto; max-width: 100%; }
table.matrix {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 100%;
}
table.matrix th,
table.matrix td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: center;
  white-space: nowrap;
}
table.matrix th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .6px;
  position: sticky;
  top: 0;
}
table.matrix th.rowhead {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface-2);
  z-index: 2;
}
table.matrix td.c { color: var(--text); font-variant-numeric: tabular-nums; background: var(--bg); }
table.matrix td.c.empty { color: var(--border); }
table.matrix td.c.drill { cursor: pointer; }
table.matrix td.c.drill:hover { background: var(--dulux-red-tint); color: var(--dulux-red); }
table.matrix td.total,
table.matrix th.total { background: var(--surface-2); color: var(--dulux-red); font-weight: 700; }
table.matrix tr.totrow td { background: var(--surface-2); color: var(--dulux-red); font-weight: 700; }
table.matrix td.grand { color: var(--dulux-red-dark); }

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.muted { opacity: .85; }

/* ---------- PAT dialog ---------- */
.pat-dialog {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 22px 24px;
  max-width: 520px;
  box-shadow: var(--shadow-md);
}
.pat-dialog::backdrop { background: rgba(15, 23, 42, .55); }
.pat-dialog h3 { margin: 0 0 8px; color: var(--dulux-navy); }
@media (prefers-color-scheme: dark) {
  .pat-dialog h3 { color: var(--text); }
}
.pat-dialog p { color: var(--muted); font-size: 13px; }
.pat-dialog a { color: var(--link); }
.pat-dialog input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: monospace;
  font-size: 13px;
  margin: 8px 0 14px;
}
.pat-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.pat-actions button { background: var(--dulux-red); color: #fff; }
.pat-actions button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

/* ---------- Top menu (ADO / Governance) ---------- */
.top-menu {
  display: flex;
  gap: 4px;
  margin: 18px 28px 0;
  border-bottom: 1px solid var(--border);
}
.top-menu .menu-item {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
}
.top-menu .menu-item:hover { color: var(--dulux-red); }
.top-menu .menu-item.active {
  color: var(--dulux-red);
  border-bottom-color: var(--dulux-red);
}

/* ---------- Horizontal date range in sub-chips ---------- */
.sub-chips .date-range-row {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sub-chips .date-range-row label {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.sub-chips .date-range-row input[type=date] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
}

/* ---------- SOW (Governance) ---------- */
.gov-subnav {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.gov-pill {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.gov-pill:hover { border-color: var(--dulux-red-soft); color: var(--dulux-red); }
.gov-pill.active {
  background: var(--dulux-red);
  color: #fff;
  border-color: var(--dulux-red);
}
.gov-panel { }

.about-content { max-width: 980px; line-height: 1.55; font-size: 14px; }
.about-block { margin: 18px 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.about-block h3 { margin: 0 0 8px; color: var(--dulux-red); font-size: 15px; }
.about-block ul, .about-block ol { margin: 6px 0 0 20px; padding: 0; }
.about-block li { margin: 4px 0; }
.about-block p { margin: 6px 0; }
.about-block .muted { color: var(--muted, #6b7280); font-size: 12px; }
.about-block code { background: var(--surface, #f3f4f6); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.about-steps { counter-reset: step; list-style: decimal; }
.about-steps > li { margin: 8px 0; }
.about-glossary { margin: 6px 0 0; padding: 0; }
.about-glossary dt { font-weight: 600; color: var(--dulux-red); margin-top: 10px; }
.about-glossary dt:first-child { margin-top: 0; }
.about-glossary dd { margin: 2px 0 0 0; padding-left: 0; }
#aboutSiteLink { color: inherit; text-decoration: underline; cursor: pointer; }
#aboutSiteLink:hover { color: var(--dulux-red); }
.about-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.about-table th, .about-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.about-table th { background: var(--dulux-red-soft, #fceaea); color: var(--text); }
.about-table tr.total td { font-weight: 600; background: var(--bg); }
.about-glossary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 6px 0 0; }
.about-glossary dt { font-weight: 600; color: var(--dulux-red); }
.about-glossary dd { margin: 0; }
.trace-flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.trace-flow span { background: var(--dulux-red-soft, #fceaea); color: var(--text); border: 1px solid var(--border); padding: 4px 10px; border-radius: 4px; }
.about-source { margin-top: 18px; font-style: italic; }
.holiday-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}
.holiday-controls select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  min-width: 220px;
}
#holidayCalendar { margin-bottom: 12px; }
#holidayList { width: 100%; border-collapse: collapse; font-size: 13px; }
#holidayList th, #holidayList td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
#holidayList th { background: var(--surface); font-weight: 600; }

.sow-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
}
.sow-controls .sow-label {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.sow-controls select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  min-width: 220px;
}
.sow-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sow-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.sow-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--dulux-navy);
  border-bottom: 2px solid var(--dulux-red-soft);
  padding-bottom: 6px;
}
@media (prefers-color-scheme: dark) {
  .sow-section h3 { color: var(--text); }
}
.sow-section p, .sow-section li { font-size: 13px; line-height: 1.55; }
.sow-section ul { margin: 6px 0 0 18px; padding: 0; }

/* ---------- Status spinner (busy indicator) ---------- */
.status.busy {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status.busy::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--dulux-red);
  border-radius: 50%;
  animation: titan-spin 0.7s linear infinite;
}
@keyframes titan-spin { to { transform: rotate(360deg); } }

/* RAID (Risks & Issues) panel */
#raidList { width: 100%; border-collapse: collapse; font-size: 13px; }
#raidList th, #raidList td { border-bottom: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
#raidList th { background: var(--bg); font-weight: 600; }
#raidList tr:hover td { background: var(--dulux-red-soft, #fceaea); }
.raid-pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.raid-pill.raid-risk  { background: #ffe0b2; color: #8a4b00; }
.raid-pill.raid-issue { background: #fbd0d0; color: #8a1c1c; }
.raid-state { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.raid-state.raid-open   { background: #d6f0d6; color: #1f5e1f; }
.raid-state.raid-closed { background: #e1e1e1; color: #555; }
#raidStatus { margin-left: 8px; }
.raid-pill.raid-action   { background: #d6e6ff; color: #1a3a8a; }
.raid-pill.raid-decision { background: #e6d6ff; color: #4a1a8a; }

/* Sign-in screenshots in About this site */
.signin-shot { margin: 12px 0 18px; padding: 0; }
.signin-shot img { display: block; max-width: 720px; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); background: #fff; }
.signin-shot figcaption { margin-top: 6px; font-size: 12px; color: var(--muted, #666); font-style: italic; }
.about-content h4 { margin: 18px 0 6px; color: var(--dulux-red); font-size: 15px; }

/* Financials panel */
.finance-gate { padding: 16px; border: 1px dashed var(--border); border-radius: 6px; max-width: 480px; }
.finance-gate-form { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.finance-gate-form input[type=password] { padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; min-width: 180px; }
.finance-gate-form button { padding: 6px 14px; background: var(--dulux-red); color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
.finance-totals { display: flex; gap: 18px; flex-wrap: wrap; margin: 8px 0 10px; padding: 8px 12px; background: var(--bg); border-radius: 4px; font-size: 13px; }
.finance-totals span strong { color: var(--dulux-red); margin-right: 4px; }
.finance-totals .fin-split { color: var(--muted); font-size: 11px; margin-left: 4px; }
.finance-pocc { margin: 4px 0 12px; padding: 10px 12px; background: #fff7f6; border: 1px solid #f5c2c2; border-radius: 6px; }
.finance-pocc .pocc-title { font-weight: 600; color: var(--dulux-red); margin-bottom: 8px; font-size: 13px; }
.finance-pocc .pocc-header { display: flex; align-items: center; gap: 4px; }
.finance-pocc .pocc-toggle { display: inline-block; width: auto; flex: 0 0 auto; text-align: left; background: transparent; border: 0; padding: 4px 0; cursor: pointer; font-weight: 600; color: var(--dulux-red); font-size: 13px; font-family: inherit; }
.finance-pocc .pocc-toggle:hover { color: #7f1d1d; }
.finance-pocc .pocc-caret { display: inline-block; width: 14px; }
.finance-pocc .pocc-body { margin-top: 8px; }
.finance-pocc .pocc-info { position: relative; display: inline-block; margin-left: 6px; color: var(--dulux-red); font-size: 14px; cursor: help; outline: none; }
.finance-pocc .pocc-info .pocc-tip { display: none; position: absolute; top: calc(100% + 6px); left: 0; width: 360px; max-width: 90vw; background: #fff; color: #222; border: 1px solid #d0d7de; border-radius: 6px; padding: 10px 12px; box-shadow: 0 6px 18px rgba(0,0,0,0.12); font-size: 12px; font-weight: 400; line-height: 1.45; z-index: 50; }
.finance-pocc .pocc-info:hover .pocc-tip,
.finance-pocc .pocc-info:focus .pocc-tip,
.finance-pocc .pocc-info:focus-within .pocc-tip { display: block; }
.finance-pocc .pocc-tip-title { font-weight: 700; color: var(--dulux-red); margin-bottom: 6px; font-size: 12px; }
.finance-pocc .pocc-tip-row { margin: 6px 0; padding-top: 6px; border-top: 1px dashed #e5e7eb; }
.finance-pocc .pocc-tip-row:first-of-type { border-top: 0; padding-top: 0; }
.finance-pocc .pocc-tip-note { margin-top: 8px; padding-top: 6px; border-top: 1px solid #eee; color: var(--muted); font-style: italic; font-size: 11px; }
.finance-pocc .pocc-sub { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 6px; }
.finance-pocc .pocc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.finance-pocc .pocc-card { background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; }
.finance-pocc .pocc-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.finance-pocc .pocc-value { font-size: 16px; font-weight: 700; color: #222; margin-top: 2px; }
.finance-pocc .pocc-value.pocc-hero { font-size: 22px; color: var(--dulux-red); }
.finance-pocc .pocc-foot { font-size: 10px; color: var(--muted); margin-top: 2px; }
.finance-tablewrap { overflow-x: auto; }
#financeTable { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 100%; }
#financeTable th, #financeTable td { border: 1px solid var(--border); padding: 3px 6px; text-align: right; white-space: nowrap; }
#financeTable th.fin-wk-head { text-align: center; background: var(--bg); font-weight: 600; }
#financeTable th.fin-sub { font-weight: 400; font-size: 11px; background: var(--bg); }
#financeTable td.fin-name, #financeTable td.fin-role { text-align: left; }
#financeTable td.fin-name { font-weight: 600; }
/* Freeze Resource Name column */
#financeTable th:first-child,
#financeTable td.fin-name,
#financeTable tr.fin-total-row td:first-child {
  position: sticky; left: 0; z-index: 2;
  background: #fff;
  box-shadow: 2px 0 0 var(--border);
}
#financeTable thead th:first-child { z-index: 4; background: var(--bg); }
#financeTable tr.fin-total-row td:first-child { background: var(--dulux-red-soft, #fceaea); z-index: 3; }
#financeTable td.fin-zero { color: #bbb; }
#financeTable .fin-snap-diff { display: inline-block; margin-left: 4px; padding: 0 4px; background: #fde2e2; color: #7f1d1d; border: 1px solid #f5c2c2; border-radius: 3px; font-size: 11px; font-weight: 600; }
#financeTable td.fin-cost { color: #8a4b00; }
#financeTable td.fin-rev  { color: #1f5e1f; }
#financeTable th.fin-sub.fin-cost { color: #8a4b00; }
#financeTable th.fin-sub.fin-rev  { color: #1f5e1f; }
#financeTable td.fin-total { font-weight: 600; background: #fafafa; }
#financeTable tr.fin-total-row td { font-weight: 700; background: var(--dulux-red-soft, #fceaea); border-top: 2px solid var(--dulux-red); }
.fin-wk-date { font-weight: 400; font-size: 10px; color: var(--muted, #666); }
.finance-refresh { font-size: 12px; color: var(--muted, #6b7280); margin: 0 0 8px; padding: 6px 10px; background: var(--bg); border-left: 3px solid var(--dulux-red); border-radius: 3px; }
.finance-refresh strong { color: var(--dulux-red); }
.fin-filter-wrap { position: relative; display: inline-block; }
.fin-filter-panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; width: 280px; max-width: 90vw; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.12); padding: 8px; }
.fin-filter-head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.fin-filter-head input[type=search] { flex: 1; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
.btn-link { background: transparent; border: 0; color: var(--dulux-red); cursor: pointer; font-size: 12px; padding: 2px 6px; text-decoration: underline; }
.btn-link:hover { color: #7f1d1d; }
.fin-filter-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 4px; padding: 4px; background: #fafafa; }
.fin-filter-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; font-size: 12px; cursor: pointer; border-radius: 3px; }
.fin-filter-row:hover { background: #fff; }
.fin-filter-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
#financeFromWeek, #financeToWeek { padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
#financeTable td.fin-past, #financeTable th.fin-past { background: #e6f4e6 !important; }
#financeTable tr.fin-total-row td.fin-past { background: #cde8cd !important; }
.finance-row-2 { margin-top: -4px; }
.finance-res-filter select { min-width: 220px; max-width: 320px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
.finance-res-filter { align-items: flex-start; gap: 4px; }
.finance-tablewrap { max-width: 100%; overflow-x: auto; padding-bottom: 4px; }
.finance-refresh .muted { color: var(--muted, #6b7280); font-weight: 400; }
