/* Data Listo portal — dashboard.css
   Widget pages rendered by js/dash.js. Uses the tokens defined in portal.css
   (--surface, --border, --accent, --radius, …) so branded tenant themes and the
   light/dark toggle apply with no extra work here. */

.dash { min-width: 0; }
.dash .pv-head { margin-bottom: 4px; }

/* ---------- provenance strip ---------- */
.dash-prov {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px;
  margin: 10px 0 12px; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.dash-prov > span { display: inline-flex; align-items: center; }
.dash-prov > span + span::before { content: '·'; margin-right: 16px; color: var(--text-dim); }
.dash-prov-err { color: var(--err); font-weight: 600; }
.dash-prov-load { color: var(--text-dim); }

/* ---------- page controls (optional; see dash.js `controls`) ---------- */
.dash-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px;
  margin: 10px 0 0; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px;
}
.dash-control { display: inline-flex; align-items: center; gap: 8px; }
.dash-control-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-dim);
}
.dash-control select {
  height: 26px; max-width: 220px; padding: 0 6px;
  font: inherit; font-size: 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 3px; cursor: pointer;
}
.dash-control select:hover:not(:disabled) { border-color: var(--accent); }
.dash-control select:disabled { color: var(--text-dim); cursor: default; }

/* ---------- grid ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; align-items: start; }
.dash-lg { grid-column: span 12; }
.dash-md { grid-column: span 6; }
.dash-sm { grid-column: span 3; }

.dash-card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.dash-card-head { padding: 12px 14px 0; }
.dash-card-title { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text); }
.dash-card-note { margin: 4px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.dash-card-note:empty { display: none; }
.dash-card-body { flex: 1; padding: 12px 14px; min-width: 0; }
.dash-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 7px 14px; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums;
}
.dash-foot-acts { white-space: nowrap; }
.dash-foot-acts .link-btn { font-size: 11px; text-decoration: none; }
.dash-foot-acts a.link-btn:hover { text-decoration: underline; }

/* ---------- loading / empty / error ---------- */
.dash-skel { display: flex; flex-direction: column; gap: 9px; padding: 4px 0; }
.dash-skel-bar, .dash-skel-chip {
  height: 10px; border-radius: 3px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: dashShimmer 1.3s ease infinite;
}
.dash-skel-chip { width: 140px; height: 8px; }
@keyframes dashShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .dash-skel-bar, .dash-skel-chip { animation: none; } }
.dash-empty { padding: 26px 8px; text-align: center; color: var(--text-dim); font-size: 12px; }
.dash-err { padding: 14px; border-radius: var(--radius); background: var(--err-dim); color: var(--err); font-size: 12px; line-height: 1.5; }

/* ---------- stats strip ---------- */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.dash-stat { padding: 2px 0; }
.dash-stat-val { font-size: 24px; font-weight: 600; line-height: 1.15; color: var(--accent); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-stat-label { margin-top: 3px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* ---------- charts ---------- */
.dash-chart { position: relative; height: 260px; }
.dash-chart-tall { height: 420px; }
.dash-chart canvas { max-height: 100%; }

/* ---------- ranked bars ---------- */
.dash-bars { list-style: none; margin: 0; padding: 0; }
.dash-bar + .dash-bar { margin-top: 2px; }
.dash-bar-link {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto 1fr 58px;
  align-items: center; gap: 8px; padding: 4px 6px;
  border-radius: 3px; color: inherit; text-decoration: none; font-size: 12px;
}
a.dash-bar-link:hover { background: var(--surface-2); }
a.dash-bar-link:hover .dash-bar-label { color: var(--accent); }
.dash-bar-rank { color: var(--text-dim); font-variant-numeric: tabular-nums; text-align: right; font-size: 11px; }
.dash-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dash-bar-sub { color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.dash-bar-track { position: relative; height: 8px; border-radius: 2px; background: var(--surface-2); }
.dash-bar-fill { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--accent); }
.dash-bar-fill.neg { background: var(--err); }
.dash-bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.dash-bar-val.pos { color: var(--ok); }
.dash-bar-val.neg { color: var(--err); }

/* ---------- mini rank lists ---------- */
.dash-sub-label { margin: 10px 0 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.dash-sub-label:first-child { margin-top: 0; }
.dash-mini { list-style: none; margin: 0; padding: 0; }
.dash-mini li > * {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 6px; border-radius: 3px; color: inherit; text-decoration: none; font-size: 12px;
}
.dash-mini li a:hover { background: var(--surface-2); }
.dash-mini li a:hover .dash-mini-label { color: var(--accent); }
.dash-mini-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-mini-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.dash-mini-val.pos { color: var(--ok); }
.dash-mini-val.neg { color: var(--err); }

/* ---------- tables (standings, leaders) ---------- */
.dash-standings { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px 16px; }
/* One wrapper per group. A grid item defaults to min-width: auto, and an
   auto-layout table never shrinks below its min-content width -- `width: 100%`
   is a floor there, not a ceiling -- so a table wider than its track used to
   overflow and paint over the next group rather than shrink. The wrapper takes
   the min-width: 0 and scrolls, which keeps groups apart at any card width. */
.dash-standings-col { min-width: 0; overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.dash-table th {
  padding: 4px 6px; text-align: right; font-weight: 700; font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.dash-table td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-table .dash-t-label { text-align: left; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.dash-table .dash-t-label a { color: inherit; text-decoration: none; }
.dash-table .dash-t-label a:hover { color: var(--accent); text-decoration: underline; }
.dash-table td.pos { color: var(--ok); }
.dash-table td.neg { color: var(--err); }
.dash-table-wide .dash-t-label { max-width: 190px; }

/* ---------- tabs ---------- */
.dash-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.dash-tab {
  height: 24px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-muted); font-size: 12px; cursor: pointer;
}
.dash-tab:hover { color: var(--text); }
.dash-tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ---------- SQL modal ---------- */
.dash-modal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0, 0, 0, 0.45); }
.dash-modal-card { display: flex; flex-direction: column; width: min(820px, 100%); max-height: 80vh; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.dash-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.dash-modal-id { color: var(--text-dim); font-size: 12px; margin-left: 6px; }
.dash-modal-sql { flex: 1; margin: 0; padding: 16px; overflow: auto; background: var(--surface-2); font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre; color: var(--text); }
.dash-modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .dash-sm { grid-column: span 6; }
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-lg, .dash-md, .dash-sm { grid-column: span 1; }
  .dash-chart { height: 240px; }
  .dash-chart-tall { height: 320px; }
  .dash-bar-link { grid-template-columns: 16px minmax(0, 1fr) auto 52px; }
  .dash-bar-track { display: none; }
}
