/* ============================================================
   Gulf Coast Mechanical — command center (Fathom Works demo)
   Layout + chart chrome on top of the Fathom design system.
   Prefix: gcm-
   ============================================================ */

:root {
  /* Validated chart hexes for the white/paper surface — see data/PALETTE.md.
     Do not swap for raw brand tokens: a true neutral gray fails the
     colorblind-safety check against this cyan on white (too close in OKLab),
     so the comparison series is a deliberate muted plum instead — validated,
     not an accident. */
  --ch-cyan:  #0077a8;  /* lead series (deep sonar, unchanged from brand) */
  --ch-slate: #763269;  /* comparison series — muted plum, not gray (see above) */
  --ch-gold:  #8a5a08;  /* single-series bars (overtime hours) */
  --ch-good:  #008c48;  /* status good */
  --ch-warn:  #c98a16;  /* status warn */
  --ch-bad:   #d8504f;  /* status bad (large bar-mark use — passes at 4.05:1) */
  --ch-bad-text: #b83a39;  /* darker red for SMALL bad/danger text — #d8504f
    falls just short of 4.5:1 for body-size text (4.05:1); this clears it */

  /* Friendly body/UI font for this contractor-facing demo — a deliberate
     deviation from the brand's mono-only rule for this specific audience. */
  --gcm-font-friendly: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--surface-app); color: var(--text-body); font-family: var(--gcm-font-friendly); font-size: var(--text-base); line-height: var(--leading-normal); }
* { box-sizing: border-box; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--sonar-bright); text-decoration: underline; }

.gcm-app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Shared-component nudges: components.css reaches for raw --line
   directly (bypassing the --border semantic alias), so .theme-paper alone
   doesn't fix their borders. Re-declare here, scoped to this page. ---- */
.fc-panel { border-color: var(--border); }
.fc-input, .fc-select { border-color: var(--border); font-family: var(--gcm-font-friendly); }
.gcm-chips .fc-badge--OPTION { border-color: var(--border); }

/* ---- Topbar ------------------------------------------------ */
.gcm-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-6);
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-well); position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.gcm-brand { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.gcm-brand__mark { height: 22px; width: auto; }
.gcm-prompt { color: var(--buy); }
.gcm-brand__name { color: var(--sonar); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-wide); }
.gcm-brand__tag { color: var(--text-muted); }
.gcm-brand__meta { color: var(--text-muted); font-size: var(--text-xs); }
.gcm-demo-badge {
  display: inline-block; font-size: var(--text-2xs); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide); padding: 1px 7px; border-radius: var(--radius-xs);
  background: var(--hold); color: var(--hold-ink); cursor: help;
}
.gcm-topbar__link { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
.gcm-topbar__link:hover { color: var(--sonar); }

/* ---- Main column ------------------------------------------- */
.gcm-main {
  width: 100%; max-width: 1240px; margin: 0 auto;
  padding: 18px 16px 40px; display: flex; flex-direction: column; gap: 26px; flex: 1;
}
.gcm-panel { background: var(--surface-panel); }

/* ---- KPI row ----------------------------------------------- */
.gcm-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-6); }
.gcm-kpi {
  background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 12px 9px; display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.gcm-kpi__label { color: var(--text-muted); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.gcm-kpi__value { font-size: var(--text-xl); font-weight: var(--weight-semibold); color: var(--text-display); line-height: var(--leading-tight); }
.gcm-kpi__caption { color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-snug); }
.gcm-kpi--alert { border-color: var(--hold); background: rgba(201, 138, 22, 0.10); }
.gcm-kpi--alert .gcm-kpi__value { color: var(--ch-gold); }
.gcm-kpi--alert .gcm-kpi__label { color: var(--ch-gold); }
.gcm-kpi__flag {
  align-self: flex-start; font-size: var(--text-2xs); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide); padding: 0 5px; border-radius: var(--radius-xs);
  background: var(--hold); color: var(--hold-ink); margin-bottom: 1px;
}

/* ---- Shared chart chrome ----------------------------------- */
.gcm-chart-block { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.gcm-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-6); flex-wrap: wrap; }
.gcm-chart-head__right { display: flex; align-items: center; gap: var(--space-6); }
.gcm-chart-title { color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.gcm-chart { width: 100%; min-width: 0; }
.gcm-chart svg { display: block; width: 100%; height: auto; }

.gcm-legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.gcm-legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); }
.gcm-legend__swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.gcm-legend__linekey { width: 16px; height: 2px; border-radius: 1px; flex: none; }

.gcm-note { margin: 0; font-size: var(--text-xs); color: var(--text-body); line-height: var(--leading-snug); }
.gcm-note--dim { color: var(--text-muted); }
.gcm-kicker { margin: 6px 0 0; font-size: var(--text-sm); color: var(--sonar); }

.gcm-callout {
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--text-body);
}
.gcm-callout--warn { border-color: rgba(201, 138, 22, 0.45); }
.gcm-callout strong { color: var(--ch-gold); font-weight: var(--weight-semibold); }
.gcm-callout--bad strong { color: var(--ch-bad-text); }

/* SVG text classes — text tokens, never series color */
.ch-tick   { fill: var(--text-muted); font-family: var(--gcm-font-friendly); font-size: 10px; }
.ch-tick--num { font-variant-numeric: tabular-nums; }
.ch-label  { fill: var(--text-body); font-family: var(--gcm-font-friendly); font-size: 11px; }
.ch-label--dim { fill: var(--text-muted); }
.ch-label--strong { fill: var(--text-display); font-weight: 600; }
.ch-value  { fill: var(--text-display); font-family: var(--gcm-font-friendly); font-size: 11px; font-weight: 600; }
.ch-value--dim { fill: var(--text-muted); font-weight: 400; }
.ch-anno   { fill: var(--text-body); font-family: var(--gcm-font-friendly); font-size: 10.5px; }
.ch-tag-warn { fill: var(--ch-gold); font-family: var(--gcm-font-friendly); font-size: 9.5px; font-weight: 700; letter-spacing: 0.5px; }
.ch-tag-bad  { fill: var(--ch-bad-text); font-family: var(--gcm-font-friendly); font-size: 9.5px; font-weight: 700; letter-spacing: 0.5px; }
.ch-grid   { stroke: var(--border); stroke-width: 1; }
.ch-ref    { stroke: var(--text-muted); stroke-width: 1; }
.ch-cross  { stroke: var(--text-muted); stroke-width: 1; }
.ch-hit    { fill: transparent; outline: none; }
.ch-hit:focus-visible { fill: var(--sonar-wash); }
.ch-lift   { transition: opacity var(--dur-fast) var(--ease); }

/* ---- Tooltip ----------------------------------------------- */
.gcm-tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 9px; font-size: var(--text-xs); line-height: 1.45; color: var(--text-body);
  box-shadow: var(--shadow-dropdown); max-width: 260px;
}
.gcm-tooltip__title { color: var(--text-muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; font-size: var(--text-2xs); }
.gcm-tooltip__row { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.gcm-tooltip__key { width: 12px; height: 2px; border-radius: 1px; flex: none; align-self: center; }
.gcm-tooltip__val { color: var(--text-display); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.gcm-tooltip__lbl { color: var(--text-muted); }

/* ---- Tables ------------------------------------------------ */
.gcm-table-scroll { overflow-x: auto; }
.gcm-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.gcm-table th, .gcm-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; white-space: nowrap; }
.gcm-table thead th { color: var(--text-muted); text-transform: uppercase; font-size: var(--text-2xs); letter-spacing: var(--tracking-wide); background: var(--surface-card); }
.gcm-table tbody tr:nth-child(even) { background: var(--surface-well); }
.gcm-table tbody tr:hover { background: var(--surface-hover); }
.gcm-table td.num, .gcm-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.gcm-table .gcm-id { color: var(--sonar); font-weight: var(--weight-semibold); }
.gcm-table tfoot td { color: var(--text-display); font-weight: var(--weight-semibold); background: var(--surface-card); border: 1px solid var(--border); padding: 4px 8px; }
.gcm-table-cap { color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); margin-bottom: 6px; }

.gcm-chip {
  display: inline-block; font-size: var(--text-2xs); font-weight: var(--weight-bold);
  letter-spacing: 0.4px; padding: 1px 6px; border-radius: var(--radius-xs);
  background: var(--border); color: var(--text-body); font-variant-numeric: tabular-nums;
}
.gcm-chip--bad  { background: rgba(216, 80, 79, 0.14); color: var(--ch-bad-text); }
.gcm-chip--warn { background: rgba(201, 138, 22, 0.14); color: var(--ch-gold); }
.gcm-chip--dim  { background: var(--border); color: var(--text-muted); }
.gcm-chip--unbilled { background: rgba(216, 80, 79, 0.14); color: var(--ch-bad-text); }

.gcm-tablebtn {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  font-family: var(--gcm-font-friendly); font-size: var(--text-2xs); text-transform: uppercase;
  letter-spacing: var(--tracking-wide); padding: 2px 8px; border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.gcm-tablebtn:hover { color: var(--sonar); border-color: var(--sonar); }
.gcm-tablebtn[aria-expanded="true"] { color: var(--sonar); border-color: var(--sonar); background: var(--sonar-wash); }
.gcm-tableview { margin-top: 4px; max-height: 300px; overflow-y: auto; }

/* ---- Hero figures ------------------------------------------ */
/* --hold's light-mode contrast on white (2.95:1) is too thin for text this
   prominent, so the page's single biggest, most important figure uses the
   already-validated deep gold instead — same amber family, readable. */
.gcm-hero-label { color: var(--ch-gold); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.gcm-hero-figure { font-size: 46px; font-weight: var(--weight-bold); color: var(--ch-gold); line-height: 1.05; letter-spacing: var(--tracking-tight); }
.gcm-hero-figure--sm { font-size: var(--text-2xl); color: var(--text-display); }
.gcm-hero-sub { color: var(--text-body); font-size: var(--text-sm); }

/* ---- Panel-specific layout --------------------------------- */
/* grid children must be allowed to shrink below content width,
   or nowrap tables blow the tracks out past the viewport */
.gcm-unbilled > *, .gcm-margin-grid > *, .gcm-quotes-grid > *,
.gcm-cash-grid > *, .gcm-season-bottom > *, .gcm-analyst-grid > * { min-width: 0; }
.gcm-table-scroll { max-width: 100%; }

.gcm-unbilled { display: grid; grid-template-columns: minmax(230px, 1fr) 2fr; gap: 22px; align-items: start; }
.gcm-unbilled__hero { display: flex; flex-direction: column; gap: 6px; }

.gcm-margin-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 26px; align-items: start; }

.gcm-quotes-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 26px; align-items: start; }
.gcm-quotes-callouts { display: flex; flex-direction: column; gap: 10px; }

.gcm-cash-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 24px; align-items: start; }

.gcm-method-grid { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr; gap: 24px; align-items: start; }
.gcm-method-grid > * { min-width: 0; }
.gcm-method-block { display: flex; flex-direction: column; gap: 8px; }
.gcm-chips { display: flex; flex-wrap: wrap; gap: 6px; }
#panel-methodology { display: flex; flex-direction: column; gap: 16px; }
#panel-methodology .gcm-note--dim { border-top: 1px dashed var(--divider); padding-top: 12px; }

.gcm-cite { margin: 4px 0 0; font-size: var(--text-2xs); color: var(--text-muted); letter-spacing: 0.2px; }
.gcm-cite::before { content: "sourced from: "; text-transform: uppercase; letter-spacing: 0.4px; }

#panel-season { display: flex; flex-direction: column; gap: 20px; }
.gcm-season-bottom { display: grid; grid-template-columns: 1fr 1.2fr; gap: 26px; align-items: start; border-top: 1px dashed var(--divider); padding-top: 16px; }
.gcm-pipeline { gap: 4px; }
.gcm-pipeline .gcm-table { margin-top: 8px; }

/* ---- Analyst ----------------------------------------------- */
.gcm-analyst-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 26px; align-items: start; }
.gcm-analyst-chat { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.gcm-chat-log {
  background: var(--surface-well); border: 1px solid var(--border); border-radius: var(--radius-sm);
  min-height: 150px; max-height: 420px; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 12px; font-size: var(--text-base);
}
.gcm-chat-empty { color: var(--text-muted); font-size: var(--text-sm); }
.gcm-chat-q { color: var(--sonar); font-weight: var(--weight-semibold); }
.gcm-chat-q::before { content: "> "; color: var(--buy); font-weight: var(--weight-regular); }
.gcm-chat-a { border-left: 2px solid var(--border); padding-left: 12px; }
.gcm-chat-a p { margin: 0 0 8px; }
.gcm-chat-a p:last-child { margin-bottom: 0; }
.gcm-chat-a strong { color: var(--ch-gold); font-weight: var(--weight-semibold); }
.gcm-chat-a em { color: var(--sonar); font-style: normal; }
.gcm-chat-a--typing { cursor: pointer; }
.gcm-chat-skip { color: var(--text-muted); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.5px; }
.gcm-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.gcm-qchip {
  background: transparent; border: 1px solid var(--border); color: var(--text-body);
  font-family: var(--gcm-font-friendly); font-size: var(--text-xs); padding: 4px 10px;
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.gcm-qchip:hover { border-color: var(--sonar); color: var(--sonar); }
.gcm-qchip--asked { color: var(--text-muted); border-color: var(--divider); }
.gcm-chat-form { display: flex; gap: 8px; }
.gcm-chat-form .fc-input { flex: 1; min-width: 0; }

/* ---- Weekly brief ------------------------------------------ */
.gcm-brief {
  background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
}
.gcm-brief__masthead { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.gcm-brief__mark { height: 18px; width: auto; }
.gcm-brief__name { font-family: var(--font-serif); font-weight: var(--weight-bold); letter-spacing: 2px; color: var(--text-display); font-size: var(--text-sm); }
.gcm-brief__week { margin-left: auto; color: var(--text-muted); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.gcm-brief__kind { color: var(--sonar); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.gcm-brief__headline { color: var(--text-display); font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: var(--leading-snug); margin: 0; }
.gcm-brief__section h4 { margin: 0 0 4px; color: var(--text-muted); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--weight-semibold); }
.gcm-brief__section p, .gcm-brief__section ol { margin: 0 0 4px; font-size: var(--text-sm); line-height: var(--leading-normal); }
.gcm-brief__section ol { padding-left: 18px; }
.gcm-brief__section li { margin-bottom: 4px; }
.gcm-brief__section strong { color: var(--ch-gold); font-weight: var(--weight-semibold); }
.gcm-brief__cta { border-top: 1px dashed var(--divider); padding-top: 10px; color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-snug); }
.gcm-brief__cta em { color: var(--sonar); font-style: normal; }

/* ---- Footer ------------------------------------------------ */
.gcm-footer {
  border-top: 1px solid var(--border); background: var(--surface-hero);
  padding: 18px 16px 26px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.gcm-footer__banner { width: 100%; max-width: 760px; height: auto; display: block; }
.gcm-footer__disclosure { margin: 0; color: var(--text-body); font-size: var(--text-xs); text-align: center; }
.gcm-footer__line { margin: 0; color: var(--text-muted); font-size: var(--text-2xs); letter-spacing: var(--tracking-wide); text-align: center; }

/* ---- Responsive -------------------------------------------- */
@media (max-width: 1080px) {
  .gcm-kpis { grid-template-columns: repeat(3, 1fr); }
  .gcm-cash-grid { grid-template-columns: 1.3fr 1fr; }
  #panel-cash .gcm-chart-block:last-child { grid-column: 1 / -1; }
  .gcm-method-grid { grid-template-columns: 1fr 1fr; }
  #panel-methodology .gcm-method-block:last-child { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .gcm-unbilled, .gcm-margin-grid, .gcm-quotes-grid, .gcm-season-bottom, .gcm-analyst-grid, .gcm-method-grid { grid-template-columns: 1fr; }
  .gcm-cash-grid { grid-template-columns: 1fr; }
  #panel-cash .gcm-chart-block:last-child { grid-column: auto; }
  #panel-methodology .gcm-method-block:last-child { grid-column: auto; }
}
@media (max-width: 560px) {
  .gcm-kpis { grid-template-columns: repeat(2, 1fr); }
  .gcm-kpi--alert { grid-column: 1 / -1; }
  .gcm-main { padding: 14px 10px 30px; gap: 20px; }
  .gcm-topbar { padding: 8px 10px; }
  .gcm-hero-figure { font-size: 38px; }
  .gcm-topbar__link { font-size: var(--text-2xs); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
