:root {
  --bg-canvas: #0a0a0a;
  --bg-panel: #121212;
  --bg-panel-inset: #0e0e0e;
  --bg-elevated: #1a1a1a;
  --border-subtle: #2a2a2a;
  --border-quiet: #2e2e2e;
  --gold: #c9a96e;
  --gold-muted: rgba(201, 169, 110, 0.4);
  --cream: #f5f0e6;
  --text-primary: #f0f0f0;
  --text-secondary: #8a8a8a;
  --text-tertiary: #5c5c5c;
  --text-inverse: #0a0a0a;
  --status-ok: #a8b5a0;
  --status-warn: #c4a574;
  --status-bad: #b87a7a;
  --radius-panel: 12px;
  --radius-control: 8px;
  --radius-chip: 999px;
  --focus-ring: 0 0 0 2px #0a0a0a, 0 0 0 4px #c9a96e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: Inter, "SF Pro Text", "Segoe UI", system-ui, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button, a, input {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.hidden { display: none !important; }

/* —— Auth gate —— */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg-canvas);
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  padding: 28px 24px;
  animation: fade-in 160ms ease-out;
}

.gate-card h1 {
  margin: 0 0 8px;
  color: var(--gold);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.gate-card p {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.gate-banner {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--gold-muted);
  background: var(--bg-panel-inset);
  color: var(--cream);
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--gold);
  color: var(--text-inverse);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

.btn-ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-muted);
}

.btn-ghost:hover { border-color: var(--gold); filter: none; }

.btn-inline {
  width: auto;
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13px;
}

/* —— Chrome —— */
.chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.wordmark {
  color: var(--gold);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.chrome-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.stage-chip {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-chip);
  padding: 3px 8px;
}

/* —— Canvas —— */
.canvas {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 767px) {
  .chrome { padding: 14px 16px; }
  .canvas { padding: 16px; }
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 1440px) {
  .canvas { max-width: 1440px; }
  .row-2.wide-up { grid-template-columns: 1fr 1fr; }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  padding: 22px 24px;
  animation: fade-up 160ms ease-out both;
}

.panel.spend {
  border-color: rgba(201, 169, 110, 0.22);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.panel-title {
  color: var(--gold);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 18px;
}

.panel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.panel-header-row .panel-title { margin-bottom: 0; }

/* —— Spend —— */
.seg {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-chip);
  padding: 3px;
  margin-bottom: 18px;
  gap: 2px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-chip);
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: rgba(201, 169, 110, 0.18);
  color: var(--cream);
}

.seg button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hero {
  font-size: 32px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--cream);
  margin: 0 0 8px;
  line-height: 1.2;
}

@media (min-width: 1024px) {
  .hero { font-size: 34px; }
}

.narrative {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 20px;
  max-width: 42em;
}

.breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
}

.breakdown li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border-quiet);
  font-size: 13px;
}

.bar {
  grid-column: 1 / -1;
  height: 3px;
  background: var(--bg-panel-inset);
  border-radius: 2px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--gold-muted);
}

.meta {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* —— Lists / chips —— */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border-quiet);
  font-size: 13px;
}

.list li:first-child { border-top: 0; }

.list a {
  color: var(--text-primary);
  text-decoration: none;
}

.list a:hover { color: var(--cream); }

.chip {
  flex-shrink: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-chip);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.chip.ok { color: var(--status-ok); border-color: rgba(168, 181, 160, 0.35); }
.chip.warn { color: var(--status-warn); border-color: rgba(196, 165, 116, 0.4); }
.chip.bad { color: var(--status-bad); border-color: rgba(184, 122, 122, 0.4); }

.who-name { color: var(--cream); }
.who-focus { color: var(--text-secondary); }

/* —— Health —— */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.health-item {
  background: var(--bg-panel-inset);
  border: 1px solid var(--border-quiet);
  border-radius: var(--radius-control);
  padding: 14px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.dot.ok { background: var(--status-ok); }
.dot.warn {
  background: var(--status-warn);
  animation: pulse 2.4s ease-in-out infinite;
}
.dot.bad {
  background: var(--status-bad);
  animation: pulse 2.4s ease-in-out infinite;
}
.dot.unknown { background: var(--text-tertiary); }

/* —— Architecture —— */
.arch-frame {
  background: var(--bg-panel-inset);
  border: 1px solid rgba(201, 169, 110, 0.22);
  border-radius: var(--radius-control);
  overflow: auto;
  line-height: 0;
}

.arch-frame img {
  display: block;
  width: 100%;
  height: auto;
  min-width: 720px;
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.arch-frame img.loaded { opacity: 1; }

.arch-missing {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  padding: 24px;
  line-height: 1.5;
}

/* —— Empty / error / skeleton —— */
.state-msg {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 8px 0 0;
}

.state-msg.error { color: var(--status-bad); }

.skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skel {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(201, 169, 110, 0.08),
    rgba(201, 169, 110, 0.22),
    rgba(201, 169, 110, 0.08)
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}

.skel.hero { height: 36px; width: 55%; }
.skel.row { height: 12px; }
.skel.wide { width: 100%; }
.skel.mid { width: 72%; }
.skel.short { width: 40%; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .gate-card, .arch-frame img { animation: none !important; transition: none !important; }
  .skel { animation: none !important; background: rgba(201, 169, 110, 0.15); }
  .dot.warn, .dot.bad { animation: none !important; }
  .arch-frame img { opacity: 1; }
}
