/* Dashboard — a one-column decision cockpit. Instrument strip, action table,
   aging heatmap, then this week's press plan. */

.dash {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Holds only the screen-reader h1. Out of flow, so it takes no gap above the first section. */
.dash-head { position: absolute; }

/* Section turns carry the reading order; sections are not cards.
   The 24px flex gap plus this margin is the 48px turn DESIGN.md specifies. */
.dash-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.dash-head + .dash-section { margin-top: 0; }

.dash-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.dash-section-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  line-height: 26px;
  color: var(--ink);
}

.dash-section-lede {
  max-width: 72ch;
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  line-height: 20px;
  color: var(--ink-muted);
}

.dash-subhead + .dash-section-lede { margin-top: 0; }

.dash-subhead {
  margin: var(--space-4) 0 0;
  font-size: var(--text-md);
  font-weight: var(--font-weight-semibold);
  line-height: 24px;
  color: var(--ink);
}

.section-open {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding-inline: var(--space-2);
  margin-inline: calc(var(--space-2) * -1);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: 20px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.section-open:hover { color: var(--link); }
.section-open:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }

.dash-note {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 20px;
  color: var(--ink-muted);
}

.dash-note.is-critical a { color: var(--error); }

/* Dashboard tables inherit .table; these rules add data roles only. */
/* Dashboard-specific table roles. Cell roles and the responsive dash-table
   layout live in base.css. */

/* Status is a dot plus a word — the word survives without the color. */
.state-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.state-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--hairline-strong);
}

tr.is-nominal .state-dot { background: var(--success); }
tr.is-warning .state-dot { background: var(--warning); }
tr.is-critical .state-dot { background: var(--error); }
tr.is-warning .dash-cell-due { color: var(--warning); }
tr.is-critical .dash-cell-due { color: var(--error); }

.state-flag {
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--ds-gray-alpha-200);
  font-size: var(--text-xs);
  line-height: 16px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.dash-table td.is-warning { color: var(--warning); }
.dash-table td.is-critical { color: var(--error); }

.dash-table--load .dash-group {
  border-left: 1px solid var(--hairline);
  text-align: center;
}

.dash-corner { background: transparent; }
.dash-table--load tr.is-current .dash-cell-key { color: var(--ink); font-weight: var(--font-weight-semibold); }

.dash-fallback-title {
  margin: var(--space-2) 0 calc(var(--space-2) * -1);
  font-size: var(--text-xs);
  line-height: 16px;
  color: var(--ink-muted);
}

.dashboard-chart-panel {
  margin: 0;
  padding: var(--space-4);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--ds-shadow-border);
}

.dashboard-chart-canvas { min-height: 280px; }
.dashboard-chart-panel figcaption {
  margin-top: var(--space-3);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: 16px;
}

.dashboard-chart-empty { margin: 0; color: var(--ink-muted); }

.dash-gap-row td {
  font-size: var(--text-xs);
  line-height: 16px;
  color: var(--ink-muted);
}

.meter {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.meter-bar {
  width: 48px;
  height: 4px;
  overflow: hidden;
  background: var(--surface-active);
  border-radius: var(--radius-full);
}

.meter-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink);
  transform: scaleX(calc(var(--meter-pct, 0%) / 100));
  transform-origin: left center;
}

.meter.is-over .meter-fill { background: var(--warning); }
.meter-value { min-width: 3rem; text-align: right; }

/* The heatmap is a chart, not a tinted data table. Every cell is a queue link. */
.dashboard-heatmap { overflow-x: auto; }
.heatmap-grid {
  display: grid;
  grid-template-columns: minmax(7rem, 1.4fr) repeat(var(--heatmap-columns), minmax(44px, 1fr));
  gap: var(--space-2);
  min-width: 22rem;
}

.heatmap-band,
.heatmap-department {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: 16px;
}

.heatmap-band { justify-content: center; text-align: center; }
.heatmap-department { color: var(--ink); font-weight: var(--font-weight-medium); }
.heatmap-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 52px;
  padding: var(--space-1);
  border-radius: var(--radius);
  background: var(--surface-active);
  color: var(--ink-muted);
  text-align: center;
  text-decoration: none;
}

.heatmap-cell.is-nominal { background: var(--success-soft); color: var(--success); }
.heatmap-cell.is-warning { background: var(--warning-soft); color: var(--warning); }
.heatmap-cell.is-critical { background: var(--error-soft); color: var(--error); }
.heatmap-cell.is-empty { color: var(--ink-subtle); }
.heatmap-cell:hover { box-shadow: inset 0 0 0 2px currentColor; }
.heatmap-cell:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
.heatmap-cell strong { font-family: var(--font-mono); font-size: var(--text-md); font-variant-numeric: tabular-nums; }
.heatmap-cell span { font-size: var(--text-xs); line-height: 16px; }

/* Needs action gets the room its table needs; This month is a short list. */
.dash-columns {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(220px, 1fr);
  gap: var(--space-6);
  align-items: start;
}
.dash-columns > .dash-section { min-width: 0; margin-top: 0; }
.dash-columns .dash-table th,
.dash-columns .dash-table td { white-space: normal; }
.dash-columns .dash-table .dash-cell-num,
.dash-columns .dash-table td[data-label="Due"],
.dash-columns .dash-table td[data-label="Late"] { white-space: nowrap; }

.month-list { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.month-item { display: grid; gap: 2px; padding-bottom: var(--space-3); border-bottom: 1px solid var(--hairline); }
.month-item:last-child { border-bottom: 0; }
.month-item dt { font-size: var(--text-sm); color: var(--ink-muted); }
.month-item dd { margin: 0; }
.month-value { font-family: var(--font-mono); font-size: var(--text-lg); font-variant-numeric: tabular-nums; color: var(--ink); }
.month-context { font-size: var(--text-xs); line-height: 16px; color: var(--ink-muted); }

.area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.area-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
.area-tile:hover { border-color: var(--ink-subtle); }
.area-tile:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
.area-tile-title { margin: 0; font-size: var(--text-md); font-weight: var(--font-weight-semibold); }
.area-tile-empty { margin: 0; font-size: var(--text-sm); color: var(--ink-muted); }
.area-tile-figures { display: grid; gap: var(--space-1); margin: 0; font-size: var(--text-sm); }
.area-tile-figures div { display: flex; justify-content: space-between; gap: var(--space-3); }
.area-tile-figures dt { color: var(--ink-muted); white-space: nowrap; }
.area-tile-figures dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }

@media (max-width: 1279px) {
  .dash-columns { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .meter-bar { display: none; }

  .dash .table-container { overflow: visible; }
  .dash-table .dash-gap-row td { display: block; width: 100%; }

  .dashboard-chart-panel { padding: var(--space-3); }
}

/* Coarse pointers get a 44px row and link target on the shop floor. */
@media (pointer: coarse) {
  .section-open,
  .dash-note a,
  .dash-table .empty-state a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
}

/* Print: one ink-on-white column, exact numbers, no canvas-only charts. */
@media print {
  .dash { gap: var(--space-4); }
  .dash-section { margin-top: var(--space-4); break-inside: avoid; }
  .dash-head { display: none; }
  .dash-columns { grid-template-columns: 1fr; }
  .area-grid { grid-template-columns: repeat(3, 1fr); }
  .area-tile { break-inside: avoid; }
  .meter-bar,
  .dashboard-chart-canvas,
  .section-open { display: none !important; }
  .heatmap-cell { min-height: 44px; background: #ffffff !important; color: #000000 !important; box-shadow: inset 0 0 0 1px #000000; }
  .dash-table tr { break-inside: avoid; }
}
