/* aleph stats: Grafana-like panels on aleph's dark page.
   Chart colours are the validated dark categorical palette (slots 1-4),
   checked against the chart surface below. */

.stats-page {
  --surface-1: #1a1a19;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --hairline: rgba(255, 255, 255, .10);
  --series-1: #3987e5; /* blue */
  --series-2: #d95926; /* orange */
  --series-3: #199e70; /* aqua */
  --series-4: #c98500; /* yellow */
  --series-5: #d55181; /* magenta (test build's NudeNet panel) */
  color-scheme: dark;
}
.stats-page .logo { text-decoration: none; }
.stats-back { color: var(--bezel); font-weight: 700; text-decoration: none; }
.stats-back:hover { color: var(--yellow); }

.stats { flex: 1; padding: 16px; display: grid; gap: 14px; max-width: 1400px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.stats-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.stats-filters-label { color: var(--lilac); text-transform: uppercase; letter-spacing: 1px; font-size: 12px; }
.range-btn { padding: 3px 10px; font-size: 13px; }
.range-btn[aria-pressed='true'] { background: var(--yellow); }
.stats-conn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); flex-wrap: wrap; }
.stats-note { margin: 0; font-size: 12px; color: var(--text-muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tile { background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px 14px; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; }
.tile-label { font-size: 12px; color: var(--text-secondary); }
.tile-value { font-size: 26px; font-weight: 600; color: var(--text-primary); margin-top: 4px; }
.tile--hero .tile-value { font-size: 48px; line-height: 1.05; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 12px; align-items: start; }
.chart-card {
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px 14px 8px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; min-width: 0;
}
.chart-card h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.chart-sub { margin: 2px 0 6px; font-size: 12px; color: var(--text-muted); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 4px; padding: 0; list-style: none; font-size: 12px; color: var(--text-secondary); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.chart-plot { position: relative; outline: none; }
.chart-plot:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; border-radius: 4px; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-plot .tick { font-size: 11px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart-plot .end-label { font-size: 11px; fill: var(--text-secondary); }
.chart-empty { font-size: 12px; fill: var(--text-muted); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3; min-width: 120px; padding: 6px 8px; border-radius: 6px;
  background: #2a2a28; border: 1px solid var(--hairline); color: var(--text-secondary); font-size: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.chart-tip-time { color: var(--text-muted); margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.chart-tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip-row strong { color: var(--text-primary); font-weight: 600; min-width: 3.5em; }
/* layout: the panels menu and drag handles */
.panels-menu { position: relative; font-size: 13px; }
.panels-menu > summary { cursor: pointer; list-style: none; padding: 3px 10px; border: var(--line); border-radius: 8px; background: var(--bezel); color: var(--ink); font-weight: 700; }
.panels-menu > summary::-webkit-details-marker { display: none; }
.panels-menu > summary::after { content: ' ▾'; }
.panels-panel {
  position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; width: min(300px, calc(100vw - 32px)); display: grid; gap: 6px;
  padding: 10px 12px; background: #1b1320; border: 2px solid var(--yellow); box-shadow: 4px 4px 0 var(--ink);
}
.panels-panel .check { display: flex; gap: 8px; align-items: center; color: var(--paper); cursor: pointer; }
.panels-reset { justify-self: start; margin-top: 4px; font-size: 12px; padding: 2px 10px; }
.panels-hint { margin: 0; font-size: 11px; color: #9c8aa3; }
.chart-card { position: relative; }
.chart-card h2 { padding-right: 32px; }
.panel-handle {
  position: absolute; top: 8px; right: 8px; padding: 0 6px; font-size: 16px; line-height: 1.4; cursor: grab; touch-action: none;
  background: transparent; color: var(--text-muted); border: 1px solid transparent; border-radius: 6px;
}
.panel-handle:hover, .panel-handle:focus-visible { color: var(--text-primary); border-color: var(--hairline); background: rgba(255, 255, 255, .05); }
.chart-card.is-dragging { opacity: .55; outline: 2px dashed var(--yellow); outline-offset: 2px; }
.chart-card.is-dragging .panel-handle { cursor: grabbing; }
.nn-controls { display: grid; gap: 8px; margin: 6px 0 8px; }
.nn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.nn-start { font-size: 13px; padding: 3px 12px; }
.nn-status { font-size: 12px; color: var(--text-secondary); }
.nn-status[data-state='blocked'], .nn-status[data-state='failed'] { color: #ff8b8b; }
.nn-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.nn-tile { display: grid; gap: 2px; padding: 6px 8px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 11px; color: var(--text-secondary); }
.nn-tile strong { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.chart-plot .unit { fill: var(--text-secondary); }
.chart-total { margin: 0 0 6px; font-size: 12px; color: var(--text-secondary); }
.share-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.share-row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); border-radius: 4px; padding: 1px 2px; }
.share-row:hover, .share-row:focus-visible { background: rgba(255, 255, 255, .05); outline: none; }
.share-name { color: var(--text-primary); overflow-wrap: anywhere; }
.share-track { height: 14px; display: flex; align-items: center; }
.share-bar { display: block; height: 14px; background: var(--series-1); border-radius: 0 4px 4px 0; }
.share-value { white-space: nowrap; font-variant-numeric: tabular-nums; }
.share-value strong { color: var(--text-primary); font-weight: 600; }
.chart-table { margin-top: 4px; font-size: 12px; color: var(--text-secondary); }
.chart-table summary { cursor: pointer; color: var(--text-muted); }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 4px; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { text-align: right; padding: 2px 6px; border-bottom: 1px solid var(--grid); }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
@media (max-width: 720px) {
  .panels-panel { right: auto; left: 0; }
  .tile--hero .tile-value { font-size: 40px; }
  .stats-conn { margin-left: 0; }
}
