/* 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);
}

.dash-head {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: var(--space-6);
  flex-wrap: wrap;
}

.signal-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
}

a.signal {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  min-height: 44px;
  padding: var(--space-4);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--ds-shadow-border);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--duration) var(--ease);
}

a.signal:hover { background: var(--surface-hover); }
a.signal:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }

.signal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 20px;
}

.signal-label {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  line-height: 16px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

.signal-figure {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  overflow: hidden;
}

.signal-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: var(--font-weight-semibold);
  line-height: 32px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.signal-unit {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ink-subtle);
  white-space: nowrap;
}

.signal-context {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.signal-sparkline {
  display: block;
  width: 100%;
  height: 28px;
  margin-top: auto;
  overflow: hidden;
}

.signal-sparkline > div,
.signal-sparkline canvas {
  display: block;
  width: 100% !important;
  height: 28px !important;
}

.signal-status {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px 2px 6px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-muted);
  white-space: nowrap;
}

.signal-value--exact { display: none; }
.signal.is-nominal .signal-status { background: var(--success-soft); color: var(--success); }
.signal.is-warning .signal-status { background: var(--warning-soft); color: var(--warning); }
.signal.is-critical .signal-status { background: var(--error-soft); color: var(--error); }
.signal.is-nominal .signal-status .state-dot { background: var(--success); }
.signal.is-warning .signal-status .state-dot { background: var(--warning); }
.signal.is-critical .signal-status .state-dot { background: var(--error); }

/* 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-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: 20px;
  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: 13px;
  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: 16px;
  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: 13px;
  font-weight: var(--font-weight-medium);
  line-height: 20px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

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

.dash-note {
  margin: 0;
  font-size: 13px;
  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-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0;
  text-transform: uppercase;
  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-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0;
  text-transform: uppercase;
  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: 12px;
  line-height: 16px;
}

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

.dash-gap-row td {
  font-size: 12px;
  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: 12px;
  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: 16px; font-variant-numeric: tabular-nums; }
.heatmap-cell span { font-size: 12px; line-height: 16px; }

@media (max-width: 900px) {
  .signal-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .signal-row { grid-template-columns: 1fr; }
  .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); }
}

@media (max-width: 360px) {
  .signal-row { grid-template-columns: 1fr; }
}

/* 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;
  }
}

@media (prefers-reduced-motion: reduce) {
  a.signal { transition: none; }
}

/* 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; }
  .signal-row { grid-template-columns: repeat(2, 1fr); }
  .meter-bar,
  .dashboard-chart-canvas,
  .signal-sparkline,
  .section-open { display: none !important; }
  .signal-value--compact { display: none; }
  .signal-value--exact { display: inline; }
  .signal-unit { display: none; }
  .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; }
}
