:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #101828;
  --muted: #5b6472;
  --border: #e2e6ec;
  --brand: #0a5fa4;
  --brand-dark: #084a80;
  --good: #1a7f4e;
  --bad: #b3261e;
  --warn: #b06a00;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --ink: #e6edf3;
    --muted: #9aa4b2;
    --border: #2a323d;
    --brand: #4da3ff;
    --brand-dark: #1f78d1;
    --good: #3fb977;
    --bad: #ff6b64;
    --warn: #e0a53a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

header.site {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 0; border-bottom: 1px solid var(--border);
}
header.site .brand { font-weight: 700; font-size: 1.15rem; }
header.site .brand span { color: var(--brand); }
header.site nav a { color: var(--muted); text-decoration: none; margin-left: 24px; font-size: 0.95rem; }

.hero { padding: 72px 0 48px; text-align: center; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 0 0 16px; }
.hero p.lede { color: var(--muted); font-size: 1.15rem; max-width: 700px; margin: 0 auto 28px; }
.badge-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.badge {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; font-size: 0.85rem; color: var(--muted);
}

section { padding: 48px 0; }
section h2 { font-size: 1.6rem; margin-bottom: 8px; }
section p.section-lede { color: var(--muted); margin-top: 0; margin-bottom: 28px; }

.rules-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.rules-table th, .rules-table td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.rules-table th { color: var(--muted); font-weight: 600; background: transparent; }
.rules-table tr:last-child td { border-bottom: none; }
.rules-table td.num { color: var(--brand); font-weight: 700; width: 40px; }

.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.price-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.price-card.featured { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.price-card h3 { margin: 0; font-size: 1.1rem; }
.price-card .price { font-size: 2rem; font-weight: 700; }
.price-card .price small { font-size: 0.9rem; font-weight: 400; color: var(--muted); }
.price-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.92rem; }
.price-card .cta { margin-top: auto; }

button, .btn {
  border: none; border-radius: 8px; padding: 11px 18px; font-weight: 600; cursor: pointer;
  font-size: 0.95rem; transition: opacity .15s ease;
}
.btn-primary { background: var(--brand); color: white; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--ink); }
.btn-success { background: var(--good); color: white; }
.btn-danger { background: var(--bad); color: white; }
button:hover, .btn:hover { opacity: 0.85; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, textarea, select {
  font-family: inherit; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 0.92rem; width: 100%;
}

footer.site { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: 0.85rem; text-align: center; }

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .stat-number { font-size: 1.9rem; font-weight: 700; color: var(--brand); }
.stat-card .stat-label { color: var(--muted); font-size: 0.85rem; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.toolbar select, .toolbar input { width: auto; }

.record-card {
  background: var(--surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.record-card.status-pending { border-left-color: var(--warn); }
.record-card.status-approved { border-left-color: var(--good); }
.record-card.status-rejected { border-left-color: var(--bad); }

.record-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.record-title { font-weight: 700; }
.record-meta { color: var(--muted); font-size: 0.82rem; }
.record-summary { color: var(--muted); font-size: 0.9rem; margin: 10px 0; }

.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin: 12px 0; }
.rule-item {
  display: flex; justify-content: space-between; gap: 8px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 0.82rem;
}
.rule-item .pass { color: var(--good); font-weight: 700; }
.rule-item .fail { color: var(--bad); font-weight: 700; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.pill-grade-A, .pill-grade-B { background: rgba(26,127,78,0.15); color: var(--good); }
.pill-grade-C { background: rgba(176,106,0,0.15); color: var(--warn); }
.pill-grade-D, .pill-grade-F { background: rgba(179,38,30,0.15); color: var(--bad); }
.pill-stat { background: rgba(179,38,30,0.15); color: var(--bad); }
.pill-routine { background: rgba(176,106,0,0.15); color: var(--warn); }

.record-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }

.auth-gate { max-width: 420px; margin: 96px auto; text-align: center; }
.auth-gate .btn-primary { margin-top: 12px; }
