/* ════════════════════════════════════════════════════════════════════
   Ops Admin Portal — Phase 1 styles
   Calm, dense, neutral palette. Matches the Ajax Dev visual language
   (navy + cream + subtle gold accents).
   ════════════════════════════════════════════════════════════════════ */

:root {
  --ops-navy: #0F1B3C;
  --ops-navy-soft: #1e2a52;
  --ops-cream: #fefdf8;
  --ops-paper: #ffffff;
  --ops-border: #e5e0d2;
  --ops-text: #1a1a1a;
  --ops-text-soft: #6b6658;
  --ops-gold: #d4af37;
  --ops-green: #15803d;
  --ops-amber: #b45309;
  --ops-red: #991b1b;
  --ops-bg: #f5f1e8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ops-bg);
  color: var(--ops-text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────── */
.ops-header {
  background: var(--ops-navy);
  color: white;
  padding: 14px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  position: sticky; top: 0; z-index: 10;
}
.ops-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.ops-brand { display: flex; align-items: baseline; gap: 10px; }
.ops-brand-mark { font-size: 22px; }
.ops-brand-text {
  font: 600 17px/1 "SF Pro Display", -apple-system, sans-serif;
  letter-spacing: -0.01em;
}
.ops-brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  margin-left: 4px;
  font-weight: 500;
}
.ops-header-actions { display: flex; gap: 8px; }
.ops-btn {
  padding: 7px 14px;
  font: 600 12px/1 inherit;
  background: white;
  color: var(--ops-text);
  border: 1px solid var(--ops-border);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.ops-btn:hover { background: var(--ops-cream); }
.ops-btn-ghost {
  background: transparent;
  color: white;
  border-color: rgba(255,255,255,0.20);
}
.ops-btn-ghost:hover { background: rgba(255,255,255,0.08); }
.ops-btn-primary {
  background: var(--ops-gold);
  color: var(--ops-navy);
  border-color: #b8902c;
  font-weight: 700;
}
.ops-btn-primary:hover { filter: brightness(1.05); }

/* ── Auth pane ─────────────────────────────────────────────────── */
/* 2026-06-03 — `.ops-auth-pane { display: flex }` overrides the [hidden]
   attribute's default `display: none` (class specificity wins). Add an
   explicit override so element.hidden=true actually hides the pane.
   Same pattern needed for .ops-main below. */
[hidden] { display: none !important; }

.ops-auth-pane {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.ops-auth-card {
  background: var(--ops-paper);
  border: 1px solid var(--ops-border);
  border-radius: 12px;
  padding: 32px 36px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(15,27,60,0.06);
}
.ops-auth-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: var(--ops-navy);
}
.ops-auth-help {
  font-size: 13px;
  color: var(--ops-text-soft);
  margin: 0 0 18px;
  line-height: 1.55;
}
.ops-auth-help code {
  background: var(--ops-cream);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--ops-navy);
}
.ops-auth-help a { color: var(--ops-navy); }
.ops-input {
  width: 100%;
  padding: 10px 12px;
  font: 13px/1 monospace;
  border: 1px solid var(--ops-border);
  border-radius: 6px;
  margin-bottom: 12px;
  background: white;
}
.ops-input:focus { outline: 2px solid var(--ops-gold); outline-offset: -1px; border-color: transparent; }
.ops-auth-card form { display: flex; flex-direction: column; gap: 8px; }
.ops-auth-foot {
  font-size: 11px;
  color: var(--ops-text-soft);
  margin: 14px 0 0;
  font-style: italic;
}

/* ── Main pane ─────────────────────────────────────────────────── */
.ops-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}
.ops-status-bar {
  font-size: 11px;
  color: var(--ops-text-soft);
  margin-bottom: 18px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ops-section { margin-bottom: 28px; }
.ops-section-hd {
  font: 600 14px/1 inherit;
  color: var(--ops-navy);
  margin: 0 0 12px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  letter-spacing: -0.01em;
}
.ops-link-btn {
  background: none;
  border: none;
  color: var(--ops-navy);
  font: 600 11px/1 inherit;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}
.ops-link-btn:hover { background: var(--ops-cream); }

/* ── Chip grid (top-line summary) ─────────────────────────────── */
.ops-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.ops-chip {
  background: var(--ops-paper);
  border: 1px solid var(--ops-border);
  border-radius: 10px;
  padding: 16px 18px;
}
.ops-chip-icon { font-size: 18px; line-height: 1; margin-bottom: 6px; }
.ops-chip-num {
  font: 700 26px/1 "SF Pro Display", -apple-system, sans-serif;
  color: var(--ops-navy);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.ops-chip-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ops-text-soft);
  font-weight: 600;
  margin-bottom: 6px;
}
.ops-chip-foot { font-size: 11px; color: var(--ops-text-soft); }

/* ── Balance grid (live provider) ─────────────────────────────── */
.ops-balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.ops-balance-card {
  background: var(--ops-paper);
  border: 1px solid var(--ops-border);
  border-left: 4px solid var(--ops-text-soft);
  border-radius: 10px;
  padding: 14px 18px;
}
.ops-balance-card[data-tone="ok"]       { border-left-color: var(--ops-green); }
.ops-balance-card[data-tone="low"]      { border-left-color: var(--ops-amber); }
.ops-balance-card[data-tone="critical"] { border-left-color: var(--ops-red); }
.ops-balance-card[data-tone="error"]    { border-left-color: var(--ops-text-soft); opacity: 0.6; }
.ops-bal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.ops-bal-name {
  font: 600 13px/1 inherit;
  color: var(--ops-navy);
}
.ops-bal-pill {
  font: 700 10px/1 inherit;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ops-bal-pill[data-tone="ok"]       { background: rgba(34, 197, 94, 0.14); color: var(--ops-green); }
.ops-bal-pill[data-tone="low"]      { background: rgba(245, 158, 11, 0.16); color: var(--ops-amber); }
.ops-bal-pill[data-tone="critical"] { background: rgba(239, 68, 68, 0.14); color: var(--ops-red); }
.ops-bal-pill[data-tone="error"]    { background: rgba(107, 102, 88, 0.12); color: var(--ops-text-soft); }
.ops-bal-big {
  font: 700 22px/1 "SF Pro Display", sans-serif;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.ops-bal-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--ops-text-soft);
}
.ops-bal-topup {
  font-size: 11px; color: var(--ops-navy); font-weight: 600;
  text-decoration: none;
  padding: 3px 9px;
  background: var(--ops-cream);
  border: 1px solid var(--ops-border);
  border-radius: 5px;
}
.ops-bal-topup:hover { background: var(--ops-gold); color: var(--ops-navy); }
.ops-bal-err {
  font-size: 11px; color: var(--ops-red);
  margin-top: 4px; font-style: italic;
}
.ops-balance-loading {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  font-style: italic;
  color: var(--ops-text-soft);
}

/* ── Link cards ───────────────────────────────────────────────── */
.ops-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.ops-link-card {
  background: var(--ops-paper);
  border: 1px solid var(--ops-border);
  border-radius: 10px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--ops-text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.ops-link-card:hover {
  border-color: var(--ops-gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(212, 175, 55, 0.10);
}
.ops-link-card-icon { font-size: 18px; line-height: 1; margin-bottom: 4px; }
.ops-link-card-title { font: 600 13px/1 inherit; color: var(--ops-navy); }
.ops-link-card-sub { font-size: 11px; color: var(--ops-text-soft); }

/* ── Roadmap ──────────────────────────────────────────────────── */
.ops-section-roadmap .ops-section-hd { color: var(--ops-text-soft); }
.ops-roadmap {
  list-style: disc;
  padding-left: 22px;
  margin: 0;
  color: var(--ops-text-soft);
  font-size: 12px;
  line-height: 1.7;
}
.ops-roadmap li::marker { color: var(--ops-gold); }

/* ── Project Costs (live from sheet via Apps Script bridge) ──── */
.ops-section-sub {
  font: 400 12px/1 inherit;
  color: var(--ops-text-soft);
  margin-left: 8px;
}
.ops-section-sub strong { color: var(--ops-navy); font-weight: 700; }

.ops-costs-loading {
  padding: 30px 20px;
  text-align: center;
  color: var(--ops-text-soft);
  font-size: 12px;
  font-style: italic;
}
.ops-costs-err {
  padding: 16px 20px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.20);
  border-radius: 8px;
  color: #991b1b;
  font-size: 13px;
}

/* First-time setup prompt (token paste) */
.ops-costs-auth {
  background: rgba(212, 175, 55, 0.06);
  border: 1px dashed rgba(212, 175, 55, 0.35);
  border-radius: 8px;
  padding: 16px 18px;
}
.ops-costs-auth-hd { font-size: 13px; color: var(--ops-text); margin-bottom: 10px; }
.ops-costs-auth-form { display: flex; gap: 8px; }
.ops-costs-auth-form .ops-input { flex: 1; }
.ops-costs-auth-foot {
  font-size: 11px;
  color: var(--ops-text-soft);
  margin-top: 8px;
}
.ops-costs-auth-foot code {
  background: rgba(15, 27, 60, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

/* Summary tiles per Category */
.ops-costs-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.ops-costs-tile {
  background: white;
  border: 1px solid var(--ops-border);
  border-radius: 8px;
  padding: 12px 14px;
}
.ops-costs-tile-cat {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ops-text-soft);
  font-weight: 700;
  margin-bottom: 6px;
}
.ops-costs-tile-mo {
  font: 700 22px/1 inherit;
  color: var(--ops-navy);
  margin-bottom: 4px;
}
.ops-costs-tile-mo-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--ops-text-soft);
  margin-left: 2px;
}
.ops-costs-tile-yr {
  font-size: 11px;
  color: var(--ops-text-soft);
}

/* Footer row (stamp + collapse toggle) */
.ops-costs-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--ops-text-soft);
  padding: 6px 2px;
}

/* Collapsible full-table detail */
.ops-costs-detail { margin-top: 10px; }
.ops-costs-table-wrap {
  overflow-x: auto;
  background: white;
  border: 1px solid var(--ops-border);
  border-radius: 8px;
  max-height: 600px;
  overflow-y: auto;
}
.ops-costs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.ops-costs-table th, .ops-costs-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #f0ebd6;
  vertical-align: top;
  white-space: nowrap;
}
.ops-costs-table td:last-child { white-space: normal; min-width: 200px; }
.ops-costs-hd-row {
  background: linear-gradient(180deg, rgba(212,175,55,0.05) 0%, transparent 100%);
}
.ops-costs-hd-row th {
  font: 700 10px/1 inherit;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ops-text-soft);
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.ops-costs-data-row:hover { background: rgba(212, 175, 55, 0.04); }
.ops-costs-tab-row td {
  font: 700 11px/1 inherit;
  background: rgba(15, 27, 60, 0.04);
  color: var(--ops-navy);
  padding: 8px 10px;
}
.ops-costs-total-row {
  background: rgba(212, 175, 55, 0.08);
  font-weight: 700;
}
.ops-costs-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
  color: var(--ops-navy);
}
