/* ==========================================================================
   Sample dashboard (sample-dashboard.html only)
   Uses the colour and font tokens from styles.css. The two chart colours
   below were checked for colour-blind separation and contrast on white.
   ========================================================================== */

#dash {
  --chart-profit: #9E1B1E; /* same as --crimson */
  --chart-cost:   #C2873F;
  --chart-grid:   #ECE5DB;
  --chart-axis:   #5A4F47;
  position: relative;
  display: flex; flex-direction: column; gap: 24px;
}

/* Sample-data notice */
.dash-notice { display: flex; gap: 14px; align-items: baseline; padding: 16px 20px; background: var(--white); border-left: 4px solid var(--crimson); border-radius: 4px; font-size: 15px; color: var(--text-muted); }
.dash-notice strong { color: var(--text); }

/* Filter row */
.dash-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; padding: 20px 24px; background: var(--white); border-radius: var(--radius); }
.dash-filters .field { min-width: 200px; }
.dash-filters .field select { height: 48px; font-size: 16px; }
.dash-period { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.dash-period legend { padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: 700; }
.dash-segments { display: flex; border: 2px solid var(--bone-line); border-radius: 4px; overflow: hidden; }
.dash-segments label { position: relative; }
.dash-segments input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.dash-segments span { display: block; padding: 0 16px; line-height: 44px; font-size: 15px; font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.dash-segments label + label span { border-left: 2px solid var(--bone-line); }
.dash-segments input:checked + span { background: var(--ink); color: var(--white); }
.dash-segments input:focus-visible + span { outline: 3px solid var(--crimson); outline-offset: -3px; }
.dash-reset { margin-left: auto; padding: 0 4px; height: 48px; }
.dash-range { width: 100%; margin: -4px 0 0; font-size: 14px; color: #5A4F47; }

/* Stat tiles */
.dash-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin: 0; }
.dash-tile { display: flex; flex-direction: column; justify-content: space-between; gap: 8px; padding: 24px; background: var(--white); border-radius: var(--radius); }
.dash-tile dt { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.dash-tile dd { margin: 0; font-size: clamp(26px, 2.4vw, 34px); font-weight: 800; line-height: 1.1; color: var(--text); }
.dash-tile.is-lead { background: var(--ink); }
.dash-tile.is-lead dt { color: var(--text-on-dark); }
.dash-tile.is-lead dd { color: var(--white); }

/* Panels */
.dash-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; }
.dash-panel { display: flex; flex-direction: column; gap: 20px; padding: clamp(24px, 3vw, 36px); background: var(--white); border-radius: var(--radius); min-width: 0; }
.dash-panel h2 { font-family: var(--font-body); font-size: 22px; font-weight: 800; line-height: 1.3; }
.dash-panel-sub { margin-top: -12px; font-size: 15px; color: var(--text-muted); }
.dash-legend { display: flex; gap: 20px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--text-muted); }
.dash-legend li { display: flex; align-items: center; gap: 8px; }
.dash-key { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }
.dash-key.is-profit { background: var(--chart-profit); }
.dash-key.is-cost { background: var(--chart-cost); }

/* Job-type bars (HTML, so long names wrap neatly on phones) */
.dash-bars { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.dash-bar-row { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 10fr) 76px; align-items: center; gap: 12px; padding: 8px 6px; margin: 0 -6px; border-radius: 4px; cursor: default; transition: opacity 0.2s ease; }
.dash-bar-row:hover, .dash-bar-row:focus-visible { background: var(--bone); }
.dash-bar-row:focus-visible { outline-offset: 0; }
.dash-bar-row.is-dim { opacity: 0.35; }
.dash-bar-name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.dash-bar-track { display: block; height: 20px; }
.dash-bar { display: block; height: 100%; min-width: 2px; background: var(--chart-profit); border-radius: 0 4px 4px 0; }
.dash-bar-value { font-size: 15px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-bar-value span { font-weight: 600; color: var(--text-muted); }

/* Monthly chart (SVG) */
.dash-chart { width: 100%; min-height: 300px; }
.dash-chart svg { display: block; overflow: visible; max-width: 100%; height: auto; }
.dash-gridline { stroke: var(--chart-grid); stroke-width: 1; }
.dash-baseline { stroke: var(--bone-line); stroke-width: 1; }
.dash-axis { font-family: var(--font-body); font-size: 12px; fill: var(--chart-axis); font-variant-numeric: tabular-nums; }
.dash-profit { fill: var(--chart-profit); }
.dash-cost { fill: var(--chart-cost); }
.dash-hit { fill: transparent; cursor: default; }
.dash-hit:hover, .dash-hit:focus { fill: rgba(21, 17, 15, 0.04); outline: none; }

/* Tooltip */
.dash-tooltip { position: absolute; left: 0; top: 0; z-index: 10; min-width: 200px; padding: 12px 14px; background: var(--ink); color: var(--white); border-radius: 4px; font-size: 14px; line-height: 1.5; pointer-events: none; box-shadow: 0 8px 24px rgba(21, 17, 15, 0.2); }
.dash-tooltip[hidden] { display: none; }
.dash-tooltip > strong { display: block; margin-bottom: 6px; font-size: 15px; }
.dash-tip-row { display: flex; align-items: center; gap: 8px; color: var(--text-on-dark); }
.dash-tip-row strong { margin-left: auto; padding-left: 16px; color: var(--white); font-variant-numeric: tabular-nums; }

/* Tables */
.dash-table-wrap { overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.dash-table th, .dash-table td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--bone-line); white-space: nowrap; }
.dash-table th:first-child { text-align: left; }
.dash-table thead th { font-size: 13px; font-weight: 700; color: var(--text-muted); border-bottom-width: 2px; }
.dash-table tbody th { font-weight: 700; }
.dash-details summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--crimson); }
.dash-details[open] summary { margin-bottom: 12px; }

/* Findings */
.dash-findings-panel { background: var(--ink); color: var(--white); border-top: 6px solid var(--crimson); }
.dash-findings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 0; padding: 0; list-style: none; }
.dash-findings li { padding-left: 18px; border-left: 3px solid var(--crimson); color: var(--text-on-dark); }
.dash-findings strong { display: block; margin-bottom: 6px; color: var(--white); }

.dash-method { font-size: 14px; color: #5A4F47; max-width: 860px; }

@media (prefers-reduced-motion: reduce) { .dash-bar-row { transition: none; } }

@media (max-width: 1080px) {
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-tile.is-lead { grid-column: 1 / -1; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-findings { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-tile.is-lead { grid-column: 1 / -1; }
  .dash-tile { padding: 18px; }
  .dash-filters { padding: 20px; }
  .dash-filters .field, .dash-period { width: 100%; min-width: 0; }
  .dash-segments label { flex: 1; text-align: center; }
  .dash-segments span { padding: 0 8px; }
  .dash-reset { margin-left: 0; }
  .dash-bar-row { grid-template-columns: minmax(0, 1fr) 76px; row-gap: 6px; }
  .dash-bar-name { grid-column: 1 / -1; }
}
