/* Look and feel mirrors the Shofar WhatsApp Manager (its admin-theme.css plus the Tailwind slate
   palette its templates use), hand-written (by way of Tertius) so this app needs no Tailwind build or CDN.
   Dark mode is the .dark class on <html>, set by the inline script in base.html / login.html. */
:root {
  --brand: #ff571f; --brand-rgb: 255, 87, 31; --brand-hover: #e04815;
  --white: #ffffff;
  --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1; --slate-400: #94a3b8;
  --slate-400-rgb: 148, 163, 184;
  --slate-500: #64748b; --slate-600: #475569; --slate-700: #334155; --slate-800: #1e293b; --slate-900: #0f172a;

  --bg: var(--slate-100); --surface: var(--white); --surface-alt: var(--slate-50);
  --text: var(--slate-900); --text-soft: var(--slate-700); --muted: var(--slate-500);
  --border: var(--slate-200); --border-soft: var(--slate-100); --input-border: var(--slate-300);
  --input-bg: var(--slate-50); --chip: var(--slate-100); --chip-hover: var(--slate-200); --row-hover: var(--slate-50);
  --brand-soft: rgba(var(--brand-rgb), 0.1); --brand-pill: var(--brand-hover);

  --ok: #047857; --ok-bg: #ecfdf5; --ok-border: #a7f3d0;
  --warn: #b45309; --warn-bg: #fffbeb; --warn-border: #fcd34d;
  --error: #e11d48; --error-bg: #fff1f2; --error-border: #fecdd3;
  color-scheme: light;
}
html.dark {
  --bg: var(--slate-900); --surface: var(--slate-800); --surface-alt: rgba(15, 23, 42, 0.5);
  --text: var(--slate-100); --text-soft: var(--slate-300); --muted: var(--slate-400);
  --border: var(--slate-700); --border-soft: rgba(51, 65, 85, 0.6); --input-border: var(--slate-700);
  --input-bg: var(--slate-900); --chip: var(--slate-700); --chip-hover: var(--slate-600); --row-hover: var(--slate-900);
  --brand-soft: rgba(var(--brand-rgb), 0.18); --brand-pill: #ff7a4d;

  --ok: #6ee7b7; --ok-bg: rgba(6, 78, 59, 0.4); --ok-border: rgba(4, 120, 87, 0.6);
  --warn: #fcd34d; --warn-bg: rgba(120, 53, 15, 0.3); --warn-border: #b45309;
  --error: #fb7185; --error-bg: rgba(76, 5, 25, 0.4); --error-border: rgba(136, 19, 55, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
main { flex: 1; width: 100%; max-width: 80rem; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; margin: 0 0 16px; }
h2 { font-size: 1.125rem; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 6px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 9999px; }
html.dark ::-webkit-scrollbar-thumb { background: var(--slate-700); }

/* ---- Header ---- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.topbar-inner { max-width: 80rem; margin: 0 auto; padding: 0 16px; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.125rem; letter-spacing: -0.025em; color: var(--text); white-space: nowrap; }
.brand:hover { color: var(--text); opacity: 0.9; }
.brand img { width: 28px; height: 28px; }
.brand .brand-sub { font-weight: 400; color: var(--brand); }
.main-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; font-size: 0.875rem; font-weight: 500; color: var(--text-soft); white-space: nowrap; }
.nav-link:hover { color: var(--brand); }
html.dark .nav-link:hover { color: var(--white); }
.nav-link i { color: var(--brand); }
.nav-link.active { background: var(--brand-soft); }
.user-nav { display: flex; align-items: center; gap: 16px; }
.user-link { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 500; color: var(--text-soft); white-space: nowrap; }
.user-link:hover { color: var(--brand); }
html.dark .user-link:hover { color: var(--white); }
button.logout-link { display: inline-flex; align-items: center; gap: 4px; padding: 0; background: none; border: 0; box-shadow: none; font-size: 0.75rem; font-weight: 500; color: #e11d48; cursor: pointer; }
button.logout-link:hover { background: none; color: #be123c; }
button.icon-btn { padding: 8px; border-radius: 6px; background: none; box-shadow: none; color: var(--text-soft); font-size: 1rem; line-height: 1; }
button.icon-btn:hover { background: var(--chip); color: var(--text); }
html:not(.dark) .show-dark, html.dark .show-light { display: none; }
#mobile-menu-btn { display: none; font-size: 1.25rem; }
.mobile-menu { display: none; border-top: 1px solid var(--border); padding: 8px 16px 16px; }
.mobile-menu.open { display: block; }
.mobile-menu a, .mobile-menu button.mobile-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border-radius: 6px; font-size: 1rem; font-weight: 500; color: var(--text-soft); background: none; box-shadow: none; text-align: left; justify-content: flex-start; }
.mobile-menu a:hover, .mobile-menu button.mobile-item:hover { background: var(--chip); color: var(--text); }
.mobile-menu i { color: var(--brand); width: 1.1em; text-align: center; }
.mobile-menu .mobile-section { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.mobile-menu button.mobile-item.logout, .mobile-menu button.mobile-item.logout i { color: #e11d48; }
@media (max-width: 1023px) {
  .main-nav, .user-nav { display: none; }
  #mobile-menu-btn { display: inline-flex; }
}

/* ---- Page headings and cards ---- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-left: 4px solid var(--brand); border-bottom: 1px solid var(--border); padding: 0 0 20px 16px; margin-bottom: 24px; }
.page-header h1 { margin: 0; }
.page-header p { margin: 2px 0 0; font-size: 0.875rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-top: 2px solid var(--brand); border-radius: 16px; padding: 24px; margin-bottom: 24px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
@media (min-width: 640px) { .card { padding: 28px 32px; } }
.card.narrow { max-width: 32rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin: 0 0 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-soft); }
.card-head h2 { margin: 0; }
.card-head p { margin: 0; font-size: 0.75rem; color: var(--muted); }
.card-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.8rem; margin: -8px 0 16px; }

/* ---- Forms ---- */
label { display: block; margin-bottom: 18px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
label .badge { text-transform: none; letter-spacing: 0; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 0.875rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text); }
.inline-check { display: inline-flex !important; margin: 0 0 0 10px; }
.hint label.check { font-size: 0.8rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=file], select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px;
  font: inherit; font-size: 0.875rem; font-weight: 400; text-transform: none; letter-spacing: 0;
  background: var(--input-bg); color: var(--text); transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--slate-400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.25); }
input[type=file] { padding: 8px; cursor: pointer; }
input[type=file]::file-selector-button { margin-right: 12px; padding: 6px 14px; border: 0; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; }
input[type=file]:hover::file-selector-button { background: rgba(var(--brand-rgb), 0.2); }
input.compact { display: inline-block; width: 160px; margin: 0 4px 0 0; padding: 6px 10px; }
textarea { resize: vertical; }
input[type=radio], input[type=checkbox] { accent-color: var(--brand); width: 1.05rem; height: 1.05rem; margin: 0; cursor: pointer; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset !important; -webkit-text-fill-color: var(--text) !important; caret-color: var(--text);
}
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px 6px; margin: 0 0 20px; }
legend { padding: 0 6px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
details { margin-bottom: 20px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px 0; }
summary { cursor: pointer; font-weight: 600; font-size: 0.875rem; margin-bottom: 12px; color: var(--text); }
summary::marker { color: var(--brand); }

/* ---- Buttons ---- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--brand); color: var(--white); border: 0; border-radius: 12px; padding: 10px 24px; font: inherit; font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); transition: background-color 0.15s, color 0.15s; }
button:hover, .button:hover { background: var(--brand-hover); color: var(--white); }
button:disabled { opacity: 0.6; cursor: wait; }
.button.cta { border-radius: 8px; padding: 10px 20px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; box-shadow: 0 10px 15px -3px rgba(var(--brand-rgb), 0.25); }
.button.small, button.small { padding: 6px 14px; font-size: 0.8rem; border-radius: 8px; }
.button.secondary, button.secondary { background: var(--chip); color: var(--text-soft); box-shadow: none; }
.button.secondary:hover, button.secondary:hover { background: var(--chip-hover); color: var(--text); }
button.link { background: none; color: var(--brand); padding: 0; font-size: 0.8rem; font-weight: 600; box-shadow: none; border-radius: 0; }
button.link:hover { background: none; color: var(--brand-hover); }
button.danger { background: transparent; color: var(--error); border: 1px solid var(--error-border); box-shadow: none; }
button.danger:hover { background: var(--error-bg); color: var(--error); }
form.inline { display: inline; }
.hidden { display: none !important; }

/* ---- Alerts (icons need Font Awesome, linked from the templates) ---- */
.flash { display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-size: 0.875rem; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.flash::before { font: var(--fa-font-solid); margin-top: 3px; flex: none; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok); }
.flash.ok::before { content: "\f058"; }
.flash.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.flash.warn::before { content: "\f071"; }
.flash.error { background: var(--error-bg); border-color: var(--error-border); color: var(--error); }
.flash.error::before { content: "\f06a"; }

/* ---- Tables (sit inside a .card.table-card) ---- */
.card.table-card { padding: 12px 16px 8px; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.list th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--slate-600); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
html.dark table.list th { color: var(--slate-400); }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-soft); vertical-align: middle; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--row-hover); }
table.list td.strong, table.list td.strong a { font-weight: 600; color: var(--text); }
table.list td.strong a:hover { color: var(--brand); }
tr.inactive td { opacity: 0.6; }
.row-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.row-actions form { display: inline-flex; gap: 10px; align-items: center; }

/* ---- Pills ---- */
.status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; text-transform: capitalize; white-space: nowrap; background: rgba(var(--slate-400-rgb), 0.2); color: var(--muted); }
.status.completed, .status.active { background: var(--ok-bg); color: var(--ok); }
.status.completed.warn { background: var(--warn-bg); color: var(--warn); }
.status.failed { background: var(--error-bg); color: var(--error); }
.status.transcribing, .status.cleaning, .status.queued, .status.superadmin { background: rgba(var(--brand-rgb), 0.15); color: var(--brand-pill); }
.badge { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.shared { background: rgba(var(--brand-rgb), 0.15); color: var(--brand-pill); }
.badge.off { background: var(--chip); color: var(--muted); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; }
button.tab { background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; padding: 8px 18px; box-shadow: none; }
button.tab:hover { background: var(--chip); color: var(--text); }
button.tab.active { position: relative; margin-bottom: -1px; background: var(--surface); color: var(--brand); border-color: var(--border); border-top: 2px solid var(--brand); }
.tab-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 0 16px 16px 16px; padding: 20px; margin-bottom: 24px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.actions { display: flex; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
.working { display: flex; align-items: center; margin: 0 0 4px; font-weight: 500; }
.working::before { content: ""; flex: none; width: 14px; height: 14px; margin-right: 12px; border: 2px solid var(--brand); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.danger-zone { margin-top: 32px; }

/* ---- Login ---- */
body.login-page { align-items: center; justify-content: center; padding: 16px; }
.login-wrap { width: 100%; max-width: 28rem; }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand img { display: block; margin: 0 auto; height: 13rem; width: auto; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05)); }
.login-brand h1 { margin: 12px 0 0; line-height: 2rem; }
.login-brand p { margin: 12px 0 0; font-size: 0.75rem; line-height: 1rem; color: var(--muted); }
.login-wrap .card { border-radius: 12px; }
@media (min-width: 640px) { .login-wrap .card { padding: 32px; } }
.login-wrap .flash { padding: 12px; font-size: 0.75rem; line-height: 1rem; }
.login-wrap label { margin-bottom: 20px; line-height: 1rem; }
.login-wrap input[type=text], .login-wrap input[type=password] { line-height: 1.25rem; }
.login-title { display: flex; align-items: center; gap: 8px; margin: 0 0 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); font-size: 1.125rem; line-height: 1.75rem; font-weight: 700; }
.login-title i { color: var(--brand); }
.login-wrap button[type=submit] { width: 100%; padding: 12px 16px; border-radius: 12px; font-size: 1rem; line-height: 1.5rem; }
.login-theme { position: fixed; top: 12px; right: 12px; }
.login-support { margin: 28px 0 0; text-align: center; font-size: 0.75rem; line-height: 1rem; color: var(--muted); }
.login-support a { font-weight: 500; }
.login-powered { margin-top: 24px; text-align: center; font-size: 0.75rem; line-height: 1rem; color: var(--muted); }
.login-powered strong { color: var(--text); font-weight: 600; }

/* Show/Hide toggle inside password and API key fields (added by app.js). */
.password-field { position: relative; display: block; margin-top: 6px; }
.password-field input { margin-top: 0; padding-right: 60px; }
.password-field.compact { display: inline-block; width: 180px; margin: 0 4px 0 0; }
.password-field.compact input { width: 100%; padding-right: 50px; }
button.password-toggle { position: absolute; top: 0; bottom: 0; right: 0; display: flex; align-items: center; padding: 0 12px;
  background: none; border: 0; box-shadow: none; color: var(--slate-500); font-size: 0.75rem; font-weight: 500; text-transform: none; letter-spacing: 0; cursor: pointer; }
button.password-toggle:hover { background: none; color: var(--text-soft); }

/* ---- Range links, tiles, pagination ---- */
.range-links { display: flex; gap: 8px; }
.range-link { padding: 6px 14px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; border: 1px solid var(--input-border); color: var(--text-soft); background: var(--surface); }
.range-link:hover { color: var(--text); border-color: var(--brand); }
.range-link.active, .range-link.active:hover { background: var(--brand); border-color: var(--brand); color: var(--white); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.tile-title { font-size: 0.75rem; color: var(--muted); }
.tile-value { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-top: 2px; }
.tile-sub { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.progress.credit-meter { height: 22px; margin: 12px 0 14px; }
.card .card-intro { margin: -16px 0 16px; font-size: 0.8rem; color: var(--muted); }
.card.table-card .card-head { margin: 8px 0 8px; padding: 0 0 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { display: block; font-size: 0.7rem; color: var(--muted); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-top: 1px solid var(--border); font-size: 0.75rem; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; align-items: center; }
.pagination a, .pagination span.page { padding: 4px 10px; border-radius: 8px; font-weight: 600; border: 1px solid var(--input-border); color: var(--text-soft); }
.pagination a:hover { border-color: var(--brand); color: var(--text); }
.pagination span.page.current { background: var(--brand); border-color: var(--brand); color: var(--white); }
.pagination span.page.disabled { opacity: 0.4; }
.usage-range { margin: -8px 0 16px; }
.usage-subhead { margin: 24px 0 4px; }
.table-scroll { overflow-x: auto; }
.usage-empty { margin-top: 16px; }

/* ======================================================================
   Numbers: dashboards, comparisons and the data grid
   ====================================================================== */
input[type=date], input[type=search], input[type=email] {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px;
  font: inherit; font-size: 0.875rem; background: var(--input-bg); color: var(--text);
}
html.dark input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1); }
.brand .brand-icon { width: 28px; height: 28px; }
.status.up, .verdict.up { background: var(--ok-bg); color: var(--ok); }
.status.down, .verdict.down { background: var(--error-bg); color: var(--error); }
.status.flat, .verdict.flat { background: var(--warn-bg); color: var(--warn); }
.status.na, .verdict.na { background: var(--chip); color: var(--muted); }
.status.apostolic, .status.regional, .status.pastor { background: var(--chip); color: var(--text-soft); }

/* Page header with the scope and month pickers */
.page-header .crumbs { font-size: 0.75rem; color: var(--muted); margin: 0 0 4px; }
.page-header .crumbs a { color: var(--muted); }
.page-header .crumbs a:hover { color: var(--brand); }
.page-header .crumbs span + span::before { content: "/"; margin: 0 6px; color: var(--slate-400); }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.verdict { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar label { margin: 0; min-width: 12rem; }
.toolbar label.narrow { min-width: 9rem; }
.toolbar select, .toolbar input { margin-top: 4px; padding: 8px 10px; }
.toolbar .button, .toolbar button { padding: 9px 16px; }
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; margin: -12px 0 20px; font-size: 0.8rem; }
.quick-links a { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-soft); background: var(--surface); }
.quick-links a:hover { border-color: var(--brand); color: var(--brand); }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); display: flex; flex-direction: column; gap: 4px; text-align: left; color: var(--text);
  font: inherit; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
button.kpi { background: var(--surface); color: var(--text); border-radius: 14px; padding: 16px 18px 14px; align-items: stretch; justify-content: flex-start; font-weight: 400; }
button.kpi:hover { background: var(--surface); color: var(--text); border-color: var(--slate-400); }
.kpi.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.18); }
.kpi-head { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
.kpi-head i { color: var(--brand); }
.kpi-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi-basis { font-size: 0.72rem; color: var(--muted); line-height: 1.35; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--error); }
.delta.flat, .delta.na { color: var(--muted); font-weight: 600; }
.spark { flex: none; overflow: visible; }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-dot { fill: var(--brand); stroke: var(--surface); stroke-width: 2; }

/* Charts */
.metric-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.metric-tabs button { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
  font-size: 0.8rem; font-weight: 600; box-shadow: none; }
.metric-tabs button:hover { background: var(--surface); color: var(--text); border-color: var(--slate-400); }
.metric-tabs button.active { background: var(--brand); color: var(--white); border-color: var(--brand); }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 24px; }
@media (max-width: 640px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); min-width: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { margin: 0; font-size: 0.9rem; }
.chart-card .chart-sub { margin: 2px 0 10px; font-size: 0.75rem; color: var(--muted); }
.chart-box { position: relative; height: 260px; }
.chart-card.wide .chart-box { height: 300px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.75rem; color: var(--text-soft); margin: 0 0 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i.swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.chart-legend i.swatch.box { height: 10px; width: 10px; border-radius: 3px; }
.chart-table { margin-top: 10px; font-size: 0.8rem; }
.chart-table summary { font-size: 0.75rem; color: var(--muted); font-weight: 600; margin: 0; }
.chart-table details, details.chart-table { border: 0; padding: 0; margin: 0; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 0.85rem; }

/* Breakdown and comparison tables */
table.list th.sortable { cursor: pointer; user-select: none; }
table.list th.sortable:hover { color: var(--brand); }
table.list th.sorted-asc::after { content: " \2191"; }
table.list th.sorted-desc::after { content: " \2193"; }
table.list td.delta-cell { font-weight: 600; font-variant-numeric: tabular-nums; }
td.up, span.up { color: var(--ok); }
td.down, span.down { color: var(--error); }
td.muted-cell { color: var(--muted); }
table.list.dense td, table.list.dense th { padding: 7px 9px; }
table.list .group-row td { background: var(--surface-alt); font-weight: 700; color: var(--text); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.list tbody tr:hover .sticky-col { background: var(--row-hover); }
table.list th.span-head { text-align: center; border-bottom: 1px solid var(--border); }
.tag { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--chip); color: var(--muted); vertical-align: 1px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.03em; }

/* Source dots in the data grid */
.src { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: 1px; flex: none; }
.src.manual { background: var(--brand); }
.src.pco { background: #2a78d6; }
.src.sheet { background: var(--slate-400); }
.src.blank { background: transparent; border: 1.5px solid var(--error); }
.legend-row { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.75rem; color: var(--muted); margin: 0 0 12px; align-items: center; }
.legend-row .src { margin: 0 4px 0 0; }
.cell { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
input.cell-input { display: inline-block; width: 7rem; margin: 0; padding: 5px 8px; text-align: right; font-variant-numeric: tabular-nums; border-radius: 6px; }
input.cell-input.changed { border-color: var(--brand); background: var(--brand-soft); }
input.cell-input.blanked { text-decoration: line-through; color: var(--error); }
button.cell-revert { background: none; box-shadow: none; padding: 2px 4px; color: var(--muted); font-size: 0.75rem; border-radius: 4px; }
button.cell-revert:hover { background: var(--chip); color: var(--brand); }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--brand); border-radius: 12px; padding: 12px 16px; margin-top: 16px; box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08); }
.save-bar input[type=text] { margin: 0; max-width: 28rem; }

/* Watch list */
.heat { display: inline-block; min-width: 4.2rem; text-align: right; padding: 2px 8px; border-radius: 6px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.heat.down { background: var(--error-bg); color: var(--error); }
.heat.up { background: var(--ok-bg); color: var(--ok); }
.heat.na { color: var(--muted); }
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 1.6rem; border-radius: 8px; font-weight: 700; background: var(--chip); color: var(--text-soft); }
.score.s-high { background: var(--error-bg); color: var(--error); }
.score.s-mid { background: var(--warn-bg); color: var(--warn); }

/* Admin sub navigation */
.sub-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: -8px 0 20px; border-bottom: 1px solid var(--border); }
.sub-nav a { padding: 8px 14px; font-size: 0.85rem; font-weight: 600; color: var(--text-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sub-nav a:hover { color: var(--brand); }
.sub-nav a.active { color: var(--brand); border-bottom-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 18px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; max-height: 18rem; overflow: auto;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); margin: 6px 0 18px; }
.check-grid label.check { margin: 0; font-size: 0.82rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form select, .inline-form input { display: inline-block; width: auto; margin: 0; padding: 5px 8px; font-size: 0.8rem; }
.inline-form input.wide { min-width: 14rem; }
pre.log { white-space: pre-wrap; margin: 0; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-soft); }
.stat-pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 0 0 8px; }
.notes-box { background: var(--surface-alt); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 10px; padding: 10px 14px; font-size: 0.85rem; color: var(--text-soft); margin-bottom: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 12px; }
.section-title h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0 24px; }
@media print {
  .topbar, .toolbar, .metric-tabs, .quick-links, .save-bar { display: none !important; }
  .kpi, .chart-card, .card { box-shadow: none; break-inside: avoid; }
}
.kpi-value { white-space: nowrap; }
.kpi-row .spark { min-width: 0; flex-shrink: 1; }
table.list td.num, table.list th.num { white-space: nowrap; }
table.list td.nowrap { white-space: nowrap; }
.chip { display: inline-block; margin: 1px 4px 1px 0; padding: 2px 9px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.chip.down { background: var(--error-bg); color: var(--error); }
.chip.up { background: var(--ok-bg); color: var(--ok); }

/* Rankings */
.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 640px) { .rank-grid { grid-template-columns: 1fr; } }
.rank-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rank-col > h2 { margin: 4px 0 0; display: flex; align-items: center; gap: 8px; }
.rank-col > h2 i { color: var(--brand); }
.chart-card .missing { margin: 8px 0 0; font-size: 0.72rem; color: var(--muted); }
.login-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: 0.75rem; color: var(--muted); }
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--border-soft); }
.login-wrap .login-sso { width: 100%; padding: 12px 16px; font-size: 1rem; line-height: 1.5rem; }
