:root {
  color-scheme: dark;
  --bg: #1e1e1e;
  --panel: #252526;
  --border: #3c3c3c;
  --text: #cccccc;
  --muted: #858585;
  --accent: #3794ff;
  --gold: #c9a227;
  --ok: #89d185;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.billing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.billing-nav {
  display: flex;
  gap: 1rem;
}
.billing-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.billing-nav a:hover { color: var(--text); }

.billing-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
.billing-hero h1 { margin: 0 0 0.35rem; }
.muted { color: var(--muted); }

.current-plan { margin: 1.5rem 0 2rem; }
.current-plan-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.55rem;
}
.current-plan-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.plans-section { margin-top: 2rem; }
.plans-section h2 { margin: 0 0 0.35rem; }
.section-lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  align-items: stretch;
}
.plan-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem 1.25rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.plan-card:hover {
  border-color: #4a4a4a;
}
.plan-card.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(55, 148, 255, 0.28);
}
.plan-card.featured {
  border-color: rgba(201, 162, 39, 0.55);
}
.plan-ribbon {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1a1408;
  background: var(--gold);
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}
.plan-card h3 {
  margin: 0;
  font-size: 1.15rem;
  padding-right: 4.5rem;
}
.plan-price {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
}
.plan-price small {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 0.15rem;
}
.plan-desc {
  margin: 0;
  min-height: 2.4em;
  font-size: 0.88rem;
  line-height: 1.35;
}
.plan-highlights {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.plan-highlights li {
  display: grid;
  grid-template-columns: 1.1rem 1fr;
  gap: 0.4rem;
  align-items: start;
  margin: 0;
  line-height: 1.35;
}
.plan-highlights li .hl-mark {
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
}
.plan-highlights li.on {
  color: var(--text);
}
.plan-highlights li.on .hl-mark {
  color: var(--ok);
}
.plan-highlights li.off {
  opacity: 0.45;
}
.plan-highlights li.off .hl-mark {
  color: var(--muted);
}
.plan-card > .btn {
  margin-top: auto;
  width: 100%;
}

/* Comparison matrix */
.compare-section {
  margin-top: 2.5rem;
}
.compare-section h2 {
  margin: 0 0 0.35rem;
}
.matrix-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.plans-matrix {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-size: 0.88rem;
}
.plans-matrix th,
.plans-matrix td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid rgba(60, 60, 60, 0.7);
  text-align: center;
  vertical-align: middle;
}
.plans-matrix thead th {
  background: rgba(0, 0, 0, 0.2);
  font-weight: 600;
}
.plans-matrix .matrix-feature-col,
.plans-matrix tbody th {
  text-align: left;
  font-weight: 500;
  color: var(--text);
  min-width: 180px;
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 1;
  box-shadow: 4px 0 8px rgba(0, 0, 0, 0.12);
}
.plans-matrix thead .matrix-feature-col {
  background: #1f1f20;
  z-index: 2;
}
.matrix-plan-name {
  font-size: 0.95rem;
}
.matrix-plan-price {
  margin-top: 0.2rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}
.matrix-plan-price small {
  font-weight: 400;
  font-size: 0.75rem;
}
.plans-matrix td.is-current,
.plans-matrix th.is-current {
  background: rgba(55, 148, 255, 0.08);
}
.plans-matrix .cell-on {
  color: var(--ok);
  font-weight: 700;
  font-size: 1.05rem;
}
.plans-matrix .cell-limit {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.plans-matrix .cell-off {
  color: var(--muted);
  opacity: 0.55;
}
.plans-matrix tr.matrix-actions th,
.plans-matrix tr.matrix-actions td {
  border-bottom: none;
  padding-top: 0.9rem;
  padding-bottom: 0.95rem;
  background: rgba(0, 0, 0, 0.12);
}
.plans-matrix tr.matrix-actions .matrix-cta {
  width: 100%;
  max-width: 160px;
}

.btn {
  border: 1px solid var(--border);
  background: #333;
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1408;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.billing-message {
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: #3a2f1a;
  color: #f0d9a8;
}
.billing-message.error {
  background: #3a2220;
  color: #f48771;
}
.hidden { display: none !important; }

@media (max-width: 640px) {
  .plan-card h3 { padding-right: 0; }
  .plan-ribbon {
    position: static;
    align-self: flex-start;
  }
}
