:root {
  --canvas: #f7f6f4;
  --panel: #fff;
  --ink: #191d22;
  --ink-2: #4e5965;
  --muted: #7b838c;
  --line: #e4e3df;
  --line-strong: #d7d6d1;
  --blue: #0e86c8;
  --blue-soft: #e8f4fa;
  --red: #c63f3f;
  --red-soft: #fff1f0;
  --amber: #a96508;
  --amber-soft: #fff7e7;
  --green: #16804d;
  --shadow: 0 8px 24px rgba(28, 33, 38, .065);
  --radius: 10px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #e9e7e3;
  color: var(--ink);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

body {
  min-width: 1080px;
}

.dashboard {
  width: min(1280px, calc(100vw - 48px));
  min-height: calc(100vh - 48px);
  margin: 24px auto;
  padding: 24px 24px 30px;
  background: var(--canvas);
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(31, 34, 38, .11);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.logo {
  width: 100px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}

.logo img {
  display: block;
  width: 80px;
  height: auto;
}

.title h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0;
}

.title {
  min-width: 0;
}

.title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.freshness {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  color: var(--ink-2);
  font-size: 11px;
  white-space: nowrap;
}

.sync-check { color: var(--green); font-weight: 700; }
.freshness.stale { background: var(--amber-soft); border-color: #ead3a4; color: var(--amber); }
.freshness-loading { color: var(--muted); }

.tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  background: #eceeec;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  margin-bottom: 16px;
}

.tabs button {
  width: 170px;
  height: 35px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font: 600 12px var(--font);
}

.tabs .active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(25, 29, 34, .08);
}

.view { display: none; }
.active-view { display: block; }

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.service-kpis { grid-template-columns: 1.35fr 1fr 1fr; }
.service-v3-kpis { grid-template-columns: 1fr 1.15fr 1fr; }

.kpi {
  min-height: 121px;
  padding: 17px 17px 15px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .055em;
  text-transform: uppercase;
  color: var(--muted);
}

.formula-trigger {
  cursor: help;
  text-decoration: underline dotted rgba(123, 131, 140, .7);
  text-underline-offset: 3px;
}

.formula-trigger:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 3px;
}

.member-hover {
  cursor: help;
  text-decoration: underline dotted rgba(123, 131, 140, .45);
  text-underline-offset: 3px;
}

.member-hover:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 3px;
}

.member-popover {
  position: fixed;
  z-index: 1000;
  width: max-content;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(320px, calc(100vh - 16px));
  padding: 12px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.35;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, visibility 120ms ease;
}

.member-popover.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.member-popover-header {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.member-popover-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 18px;
  row-gap: 3px;
  min-width: 280px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.35;
}

.member-popover-list li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.kpi-value {
  font-size: 34px;
  line-height: 1;
  margin-top: 12px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.kpi-value span {
  font-size: .42em;
  color: var(--muted);
}

.kpi.hero .kpi-value { font-size: 38px; }
.kpi.hero .kpi-value span { font-size: .46em; }
.kpi.service-hero { position: relative; }
.kpi.service-hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--amber); }

.kpi-hint {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.kpi-hint strong { color: var(--ink-2); font-weight: 600; }

.portfolio-trend-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
}

.portfolio-trend-main .kpi-value {
  margin-top: 0;
  font-size: 34px;
}

.portfolio-signal {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.portfolio-signal .spark { width: 44px; height: 22px; }
.portfolio-wow { font-size: 13px; font-weight: 700; }
.portfolio-wow.red { color: var(--red); }
.portfolio-wow.green { color: var(--green); }
.portfolio-wow.amber { color: var(--amber); }
.muted-value { color: var(--muted); }

.history-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
}

.history-preview strong { font-weight: 600; color: var(--ink-2); }

.table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-head {
  min-height: 62px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.table-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.table-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.table-legend {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.legend-item { display: flex; align-items: center; gap: 5px; }
.rail-key { width: 4px; height: 14px; border-radius: 2px; background: #86a293; }
.rail-key.amber { background: var(--amber); }
.rail-key.red { background: var(--red); }

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

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  height: 38px;
  padding: 0 10px;
  background: #fafaf8;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .055em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 18px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  vertical-align: middle;
}

.num { text-align: right; white-space: nowrap; }
.dept, .team { font-weight: 700; }
.capacity { color: var(--ink-2); font-weight: 500; }
.maint { color: var(--ink); font-weight: 700; }
.sales { color: var(--ink-2); font-weight: 500; }

.band-row td {
  height: 34px;
  padding: 0 13px !important;
  background: #f4f3f0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  font-size: 10.5px !important;
  font-weight: 700;
  letter-spacing: .065em;
  text-transform: uppercase;
  color: var(--muted);
}

#constructionView .table-card > .table-wrap > table > thead th {
  height: 47px;
  vertical-align: middle;
}

.band-row:first-child td { border-top: 0; }
.band-meta { float: right; font-size: 10px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); }

.health-red, .health-amber, .health-green, .health-info { position: relative; }
.health-red td:first-child, .health-amber td:first-child, .health-green td:first-child { position: relative; padding-left: 16px; }
.health-red td:first-child::before, .health-amber td:first-child::before, .health-green td:first-child::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.health-red td:first-child::before { background: var(--red); }
.health-amber td:first-child::before { background: var(--amber); }
.health-green td:first-child::before { width: 3px; background: #86a293; }
.health-info { background: #fbfbf9; color: var(--ink-2); }

.overrun { font-weight: 700; }
.overrun.red { color: var(--red); }
.overrun.amber { color: var(--amber); }
.overrun.green { color: var(--green); }
.variance-cell { text-align: right; }
.variance { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 27px; line-height: 1; font-weight: 700; letter-spacing: 0; }
.variance.red { color: var(--red); }
.variance.amber { color: var(--amber); }
.variance.green { color: var(--green); }
.variance.muted { color: var(--muted); }
.variance-note { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 7px; color: var(--muted); font-size: 10.5px; }
.trend-empty { color: #a3a8ad; font-size: 18px; line-height: 1; }

.spark { display: inline-block; width: 28px; height: 14px; vertical-align: middle; }
.spark path { fill: none; stroke: #929aa2; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.spark circle.red { fill: var(--red); }
.spark circle.green { fill: var(--green); }
.spark circle.amber { fill: var(--amber); }

.decision-note {
  min-height: 36px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.decision-note strong { color: var(--ink-2); }
.service-note { margin-top: 14px; color: var(--muted); font-size: 11px; }

.data-quality {
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid #ead3a4;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  line-height: 1.35;
}

.data-quality summary {
  cursor: pointer;
  font-weight: 700;
}

.data-quality ul {
  margin: 9px 0 0;
  padding-left: 18px;
  color: var(--ink-2);
}

.data-quality li + li { margin-top: 5px; }
.data-quality li span { color: var(--muted); }
.loading-cell { color: var(--muted); text-align: center; height: 260px; }
.error-cell { color: var(--red); text-align: center; height: 260px; }

@media (max-width: 1180px) {
  body { min-width: 0; }
  .dashboard { width: calc(100vw - 24px); margin: 12px; padding: 16px; }
  .topbar, .table-head { align-items: flex-start; flex-direction: column; }
  .brand { align-items: flex-start; width: 100%; }
  .title h1 { font-size: 22px; white-space: normal; }
  .title p { max-width: 100%; }
  .kpis, .service-kpis, .service-v3-kpis { grid-template-columns: 1fr; }
  .portfolio-trend-main, .history-preview { flex-wrap: wrap; }
  .history-preview { align-items: flex-start; flex-direction: column; row-gap: 4px; }
  .table-legend { flex-wrap: wrap; }
  table { min-width: 980px; }
  .service-table, .service-v3-table { min-width: 1080px; }
}

@media (max-width: 520px) {
  .dashboard { width: calc(100vw - 16px); margin: 8px; padding: 14px; }
  .brand { flex-direction: column; gap: 10px; }
  .logo { width: 100px; }
  .title h1 { font-size: 21px; }
  .tabs { width: 100%; }
  .tabs button { width: auto; }
}

.legend-red { color: var(--red); }
.legend-green { color: var(--green); }
.legend-amber { color: var(--amber); }
.support { color: #6d7680; font-weight: 500; }
.weeks-hero { font-size: 17px; font-weight: 700; }
.weeks-hero.red { color: var(--red); }
.weeks-hero.amber { color: var(--amber); }
.weeks-hero.green { color: var(--green); }
.utilization { font-weight: 600; color: var(--ink-2); }
.sort-button {
  display: inline;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: inherit;
  cursor: pointer;
}
.num .sort-button { text-align: right; }
.sort-button::after { content: ""; display: inline-block; width: 1em; }
.sort-button.active-sort::after { content: "▲"; color: var(--blue); font-size: .8em; }
.sort-button.active-sort[aria-sort="desc"]::after { content: "▼"; }
.sort-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 3px; }
.service-v3-table thead th { height: 42px; white-space: normal; line-height: 1.2; }
.service-v3-table tbody td { padding-top: 21px; padding-bottom: 21px; }

@media (max-width: 520px) {
  .member-popover-list {
    grid-template-columns: 1fr;
    min-width: 0;
  }
}

/* --- Service v3 enhanced: zones, Total Hours, Unassigned/Other, Controls section, drilldown, hover popovers --- */

.zone-key { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.zone-key i { width: 1px; height: 14px; background: var(--line-strong); }

.table-foot {
  min-height: 38px;
  padding: 9px 13px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 10px;
}

.service-v3-table .zone-row th { height: 27px; background: #f3f2ef; border-bottom: 1px solid var(--line); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; color: #687078; font-weight: 600; }
.service-v3-table .zone-row .zone-demand { background: #efefec; }
.service-v3-table .header-row th { height: 47px; background: #fafaf8; }
.service-v3-table .zone-start { border-left: 1px solid var(--line-strong); }
.service-v3-table th.feeder { position: relative; background: #f1f0ec; }
.service-v3-table th.feeder:before { content: ""; position: absolute; left: 7px; right: 7px; top: 5px; border-top: 1px solid #bfc2bf; }
.service-v3-table th.feeder-start:after, .service-v3-table th.feeder-end:after { content: ""; position: absolute; top: 5px; height: 6px; border-left: 1px solid #bfc2bf; }
.service-v3-table th.feeder-start:after { left: 7px; }
.service-v3-table th.feeder-end:after { right: 7px; }
.service-v3-table th.total-head { color: var(--ink-2); font-weight: 700; background: #f4f3f0; border-left: 2px solid #c7c9c5; }
.service-v3-table th.total-head small { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 9px; color: var(--muted); }

.capacity-cell, .actual-cell { color: #6f7780; }
.demand-cell { position: relative; padding-left: 4px !important; padding-right: 4px !important; background: #f3f2ee; }
.demand-cell + .demand-cell:before {
  content: "+";
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  color: #9aa0a0;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  pointer-events: none;
}

.total-cell {
  position: relative;
  padding-left: 21px !important;
  border-left: 2px solid #c7c9c5;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  background: #f8f7f4;
}
.total-cell:before {
  content: "=";
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa0a0;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  pointer-events: none;
}

.demand-button {
  width: 100%;
  min-height: 32px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font);
  font-size: inherit;
  font-weight: 600;
  text-align: right;
  cursor: pointer;
}
.demand-button:hover { background: var(--blue-soft); color: #086999; }
.demand-button.selected {
  background: var(--blue-soft);
  border-color: rgba(14, 134, 200, .28);
  color: #086999;
  box-shadow: inset 0 0 0 1px rgba(14, 134, 200, .08);
}
.demand-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.demand-zero { display: inline-block; padding: 7px; color: var(--muted); }

.unassigned-row td { background: #faf7f2; border-top: 2px solid var(--line-strong); }
.unassigned-row .team { color: var(--ink-2); }
.catch-note { display: block; margin-top: 3px; font-size: 10px; color: var(--muted); }

.section-row td {
  height: 34px !important;
  padding: 0 12px !important;
  background: #e4e7ea !important;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  color: #5f676e;
  font-size: 10px !important;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.section-row:first-child td { border-top: 0; }
.section-row .section-meta { float: right; color: var(--muted); font-size: 9.5px; font-weight: 500; letter-spacing: 0; text-transform: none; }

/* Shared hover popover system: column-header formulas + KPI formulas (Part F) */
.info-host { position: relative; overflow: visible; outline: none; }
.info-trigger { display: inline; border-bottom: 1px dotted #9aa0a0; cursor: help; }
.info-popover {
  display: none;
  position: absolute;
  z-index: 80;
  left: 50%;
  top: calc(100% + 7px);
  transform: translateX(-50%);
  width: 240px;
  padding: 10px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 10.5px;
  line-height: 1.4;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  pointer-events: none;
}
.info-host.edge-left .info-popover { left: 0; transform: none; }
.info-host.edge-right .info-popover { left: auto; right: 0; transform: none; }
.info-host:hover .info-popover,
.info-host:focus .info-popover,
.info-host:focus-within .info-popover { display: block; }
.info-popover strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 11px; font-weight: 700; }
.formula-line {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  line-height: 1.45;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.kpi.info-host { overflow: visible; }
.kpi.info-host:hover, .kpi.info-host:focus-within { z-index: 30; }

/* Backlog drilldown panel */
.detail-panel { margin-top: 14px; }
.detail-panel[hidden] { display: none; }
.detail-head {
  min-height: 58px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}
.detail-title { font-size: 14px; font-weight: 700; }
.detail-title span { color: var(--muted); font-weight: 500; }
.close-detail { width: 32px; height: 32px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font-size: 20px; cursor: pointer; }
.close-detail:hover { background: #f0efec; }
.close-detail:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.detail-scroll { max-height: 1080px; overflow: auto; }
.detail-table { min-width: 1120px; width: 100%; border-collapse: collapse; table-layout: fixed; }
.detail-table thead th {
  height: 36px;
  padding: 0 9px;
  background: #fafaf8;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.detail-table thead th.num { text-align: right; }
.detail-table thead th:hover { color: var(--blue); }
.sort-indicator { display: inline-block; width: 12px; margin-left: 4px; color: var(--blue); }
.detail-table tbody td { padding: 9px 9px; border-bottom: 1px solid var(--line); font-size: 12.5px; vertical-align: middle; }
.detail-table tbody td.num { text-align: right; white-space: nowrap; }
.detail-table .job-num { font-weight: 700; }
.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  background: #ecefed;
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 600;
}
.stage-pill.progress { background: var(--blue-soft); color: #086999; }
.workflow-status { color: var(--ink-2); }
.unassigned-tech { color: var(--amber); font-weight: 600; }
.remaining { font-size: 15px; font-weight: 700; color: var(--ink); }
.empty-state { padding: 36px; text-align: center; color: var(--muted); font-size: 13px; }


/* Construction revamp: date lens, department-row drilldown, windowed state */
.kpi-zone-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: -2px 0 10px;
}

.date-lens { position: relative; }
.date-chip {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font: 600 11px var(--font);
  cursor: pointer;
}
.date-chip.active {
  background: var(--blue-soft);
  border-color: rgba(14, 134, 200, .28);
  color: #086999;
}
.date-chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.reset-range { color: inherit; font-size: 14px; font-weight: 700; line-height: 1; }
.range-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 90;
  width: 430px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.range-popover[hidden] { display: none; }
.presets { display: flex; gap: 5px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.preset {
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: #f4f3f0;
  color: var(--ink-2);
  font: 600 10px var(--font);
  cursor: pointer;
}
.preset:hover, .preset:focus-visible { background: var(--blue-soft); color: #086999; }
.month-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin-top: 10px; }
.date-field { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.date-field select {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  padding: 0 8px;
  color: var(--ink-2);
  font: 500 11px var(--font);
}
.apply-range {
  height: 34px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font: 600 11px var(--font);
  cursor: pointer;
}
.daily-slot { display: none; }
.kpi-windowed {
  display: block;
  margin-top: 5px;
  color: var(--blue);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.kpi-windowed[hidden], .windowed-extra[hidden], .window-marker[hidden] { display: none !important; }
.dept-row { cursor: pointer; }
.dept-row:hover td, .dept-row:focus td { background: rgba(232, 244, 250, .48); }
.dept-row.selected td { background: var(--blue-soft); }
.dept-row:focus { outline: none; }
.dept-row:focus-visible td:first-child { box-shadow: inset 2px 0 0 var(--blue); }
.remaining-cell .expandable-number {
  display: inline-block;
  padding: 3px 5px;
  border-bottom: 1px dotted #9aa0a0;
}
.remaining-cell .expandable-number.zero { border-bottom-color: transparent; color: var(--muted); }
.window-marker { margin-right: 4px; color: var(--muted); font-size: 11px; }
.member-wrap { position: relative; display: inline-block; }
.member-count {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: 600;
  cursor: help;
  padding: 5px 7px;
  border-radius: 6px;
}
.member-count:hover, .member-count:focus-visible { background: var(--blue-soft); color: #086999; outline: none; }
.roster-popover {
  display: none;
  position: absolute;
  z-index: 80;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
  width: 190px;
  max-height: 300px;
  overflow: auto;
  padding: 10px 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 10.5px;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
}
.member-wrap:hover .roster-popover,
.member-count:focus + .roster-popover { display: grid; gap: 4px; }
.roster-popover strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 11px; font-weight: 700; }
.roster-popover span { font-size: 10.5px; color: var(--ink-2); }
.detail-sparkbar {
  min-height: 62px;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: #fafaf8;
}
.sparkbar-head { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.month-spark { width: 100%; height: 30px; display: block; }
.month-spark rect { fill: #929aa2; }
.month-spark rect.outside { opacity: .3; }
.month-spark text { fill: var(--muted); font: 8px var(--font); }
.dates-pending { color: var(--muted); font-size: 10px; }
.construction-detail-table { min-width: 1180px; }
.construction-detail-table + .empty-state { border-top: 1px solid var(--line); }
.detail-date { color: var(--ink-2); }
.detail-date.undated { color: #a3a8ad; font-size: 16px; }

.info-host:hover .info-popover,
.info-host:focus .info-popover,
.info-host:focus-within .info-popover { animation: popover-in .12s ease-out; }
@keyframes popover-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-2px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.info-host.edge-left:hover .info-popover,
.info-host.edge-left:focus .info-popover,
.info-host.edge-left:focus-within .info-popover,
.info-host.edge-right:hover .info-popover,
.info-host.edge-right:focus .info-popover,
.info-host.edge-right:focus-within .info-popover { animation: popover-edge-in .12s ease-out; }
@keyframes popover-edge-in {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 520px) {
  .range-popover { width: min(430px, calc(100vw - 28px)); }
  .presets { flex-wrap: wrap; }
  .month-fields { grid-template-columns: 1fr; }
}
