/* Shared styles for the Tech Billing dashboards (per-source pages + overview).
   Each page links this file, then sets its own theme by overriding the CSS
   variables below in a small inline <style>:root{...}. Component rules here
   reference the variables, so they re-theme automatically per page. */

:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #e6e8ec;
  --text: #1c1f23;
  --muted: #6b7280;
  --accent: #cbd2db;
  --accent-strong: #475569;
  --chart-grid: #eef0f3;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 32px;
}
.container { max-width: 1100px; margin: 0 auto; }
h1 {
  font-size: 24px; font-weight: 600; margin: 0 0 4px;
  display: flex; align-items: center; gap: 12px;
}
.brand-logo {
  width: 26px; height: 26px;
  color: var(--accent-strong);
  flex-shrink: 0;
}
.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.subtitle a { color: var(--muted); }
.subtitle a:hover { color: var(--accent-strong); }
/* "Updated as of ..." pill, shared by all pages (set by Dash.setFooter or the
   page's own script). */
.updated-chip {
  display: inline-block; background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px; font-size: 12px; margin-right: 6px;
}
.period-toggle {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 2px;
}
.period-toggle button {
  background: transparent;
  border: none;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-radius: 7px;
  font-family: inherit;
  transition: background 0.1s ease, color 0.1s ease;
}
.period-toggle button:hover { color: var(--text); }
.period-toggle button.active {
  background: var(--accent-strong);
  color: white;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.kpi-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.panel h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.panel h2 .hint {
  font-weight: 400; text-transform: none; letter-spacing: 0;
  font-size: 11px; color: var(--muted);
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
td.muted { color: var(--muted); font-size: 12px; }
tr:last-child td { border-bottom: none; }
tr.total-row td { font-weight: 600; border-top: 2px solid var(--border); }
.table-scroll { max-height: 420px; overflow-y: auto; }
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.sm { height: 280px; }
footer { color: var(--muted); font-size: 12px; text-align: center; margin-top: 24px; }
/* Quiet "a source didn't refresh" note under the footer timestamp. Deliberately
   small — it's a caveat on the numbers above, not an alert. */
.stale-note { color: #a1642f; font-size: 11px; margin-top: 6px; line-height: 1.5; }

/* Empty / stale-data banner */
.empty-state {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #78350f;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}
.empty-state code {
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Long-table helpers (GitHub repo list "show more") */
.hidden-row { display: none; }
.show-more {
  background: transparent;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
  font-family: inherit;
  transition: color 0.1s ease, border-color 0.1s ease;
}
.show-more:hover { color: var(--text); border-color: var(--accent-strong); }

/* Overview anomaly flag + per-app row styling */
.flag {
  margin-top: 12px;
  background: #fff4ed;
  border: 1px solid #f6c9a8;
  color: #8a4b22;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.app-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 8px; vertical-align: middle;
}
.app-link { color: var(--text); text-decoration: none; font-weight: 500; }
.app-link:hover { text-decoration: underline; color: var(--accent-strong); }
.app-link .arrow { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }

/* Subscription-cost editor (detail pages only) — low-key bar at page bottom */
.sub-editor {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 14px; color: var(--muted);
}
.sub-editor-title { font-weight: 600; color: var(--text); }
.sub-editor-lead { display: inline-flex; align-items: center; gap: 7px; }
.sub-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sub-row input {
  width: 90px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; font-family: inherit;
}
/* no spinner arrows — typing only */
.sub-row input::-webkit-outer-spin-button,
.sub-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sub-row input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.sub-btn {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; font-family: inherit;
}
.sub-btn:hover { color: var(--text); border-color: var(--accent-strong); }
.sub-row .ok { color: #5f8a76; }
.sub-row .err { color: #e0533d; }

/* Subscription-vs-usage split bar */
.split-bar {
  display: flex; height: 12px; border-radius: 6px; overflow: hidden;
  margin-bottom: 14px; background: var(--chart-grid);
}
.split-seg { height: 100%; }

@media (max-width: 760px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 1fr; }
}
