:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #f8f4ec;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e5ddd0;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #ccfbf1;
  --accent: #b45309;
  --danger: #b91c1c;
  --warning: #92400e;
  --success: #166534;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.1; letter-spacing: -0.03em; }
h2 { font-size: 1.2rem; letter-spacing: -0.02em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.muted { color: var(--muted); }
.eyebrow { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); margin-bottom: 0.5rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.is-primary { font-weight: 800; color: var(--primary-dark); }

/* Public shell */
.site-header { background: rgba(255, 253, 248, 0.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 0; }
.brand { display: inline-flex; align-items: center; gap: 0.65rem; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--primary); color: white; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }
.brand strong { display: block; font-size: 0.98rem; letter-spacing: 0.02em; }
.brand small { display: block; color: var(--muted); font-size: 0.72rem; }
.public-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.public-nav a { color: var(--ink); font-weight: 600; font-size: 0.9rem; }
.public-nav a:hover { color: var(--primary); }
.public-nav .nav-admin { border: 1px solid var(--line); padding: 0.35rem 0.7rem; border-radius: 999px; }
.main-content { padding: 2.2rem 0 3rem; min-height: 70vh; }
.site-footer { border-top: 1px solid var(--line); padding: 1.2rem 0; color: var(--muted); font-size: 0.8rem; }
.site-footer .container { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.alerts { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }
.alert-success { border-color: #bbf7d0; background: #f0fdf4; color: var(--success); }
.alert-danger { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.alert-warning { border-color: #fde68a; background: #fffbeb; color: var(--warning); }
.alert-info { border-color: #bae6fd; background: #f0f9ff; color: #075985; }

/* Hero */
.hero { display: grid; grid-template-columns: 1.5fr 1fr; gap: 2rem; align-items: center; padding: 2rem; border-radius: calc(var(--radius) + 6px); background: linear-gradient(135deg, #fffdf8, #f0fdfa 60%, #fef3c7); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero h1 { max-width: 13ch; }
.hero p { max-width: 58ch; color: #374151; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.2rem; }
.hero-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.hero-card h2 { margin-bottom: 0.2rem; }
.hero-campaign-name { font-weight: 700; margin-bottom: 0.35rem; }

.section-head, .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 2.2rem 0 1rem; flex-wrap: wrap; }
.page-head { margin-top: 0; }
.page-head h1 { margin-bottom: 0.35rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.campaign-card { display: flex; flex-direction: column; gap: 0.45rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; color: var(--ink); box-shadow: 0 6px 18px rgba(31, 41, 51, 0.04); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.campaign-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.campaign-card small { color: var(--muted); }

/* Panels and stats */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: 0 6px 18px rgba(31, 41, 51, 0.04); margin-top: 1rem; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.panel-head h2 { margin-bottom: 0.15rem; }
.panel-head p { margin-bottom: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; margin: 1rem 0; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.2rem; }
.stat-card span { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.stat-card strong { font-size: 1.55rem; letter-spacing: -0.03em; }
.stat-card small { color: var(--muted); }
.stat-card.highlight { background: linear-gradient(135deg, #0f766e, #115e59); color: white; border-color: transparent; }
.stat-card.highlight span, .stat-card.highlight small { color: #ccfbf1; }
.two-col { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1rem; align-items: start; }
.metric-toggle { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin: 0.7rem 0; color: var(--muted); font-size: 0.85rem; }
.metric-toggle a { padding: 0.25rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; }
.metric-toggle a.active { background: var(--primary); color: white; border-color: var(--primary); }
.metric-toggle a:hover { text-decoration: none; }

/* Forms and filters */
.filter-form { display: flex; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem; }
.filter-form.wide { width: 100%; }
.filter-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); font-weight: 700; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.55rem 0.65rem; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; border-radius: 999px; padding: 0.6rem 1rem; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #991b1b; }
.extra-actions { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.2rem; }
.btn-small { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
.btn-tiny { padding: 0.25rem 0.5rem; font-size: 0.76rem; }
.inline-form { display: inline; }
.form-actions { display: flex; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }
.stack { display: grid; gap: 0.85rem; }
.field { display: grid; gap: 0.3rem; font-size: 0.85rem; font-weight: 700; }
.field .help, .help { color: var(--muted); font-weight: 400; font-size: 0.78rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.checkbox-row input { width: auto; }
.form-panel { max-width: 780px; }
.form-panel.narrow { max-width: 520px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th { text-align: left; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 0.65rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.rank-col { width: 42px; color: var(--muted); font-weight: 700; }
.actions-col { text-align: right; white-space: nowrap; }
.group-cell .tree-prefix { color: #9ca3af; }
.group-cell small { display: block; }
.badge { display: inline-block; padding: 0.12rem 0.45rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.link-code { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0.15rem 0.35rem; }
.empty { color: var(--muted); padding: 1rem 0; }
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state h1 { margin-bottom: 0.6rem; }

/* Hour bars */
.hour-list { display: grid; gap: 0.35rem; }
.hour-row { display: grid; grid-template-columns: 110px 1fr 60px 90px; gap: 0.6rem; align-items: center; font-size: 0.8rem; }
.hour-bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.hour-bar i { display: block; height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e); }
.hour-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.hour-row small { color: var(--muted); }

/* Admin */
.admin-body { background: #f1f5f4; }
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.admin-sidebar { background: #0f172a; color: #e2e8f0; padding: 1.2rem 1rem; display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand-light { color: white; }
.brand-light small { color: #94a3b8; }
.admin-nav { display: flex; flex-direction: column; gap: 0.2rem; }
.admin-nav a { color: #cbd5e1; padding: 0.55rem 0.7rem; border-radius: 8px; font-size: 0.9rem; font-weight: 600; }
.admin-nav a:hover { background: rgba(255, 255, 255, 0.08); color: white; text-decoration: none; }
.admin-user { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.12); padding-top: 0.9rem; display: grid; gap: 0.4rem; font-size: 0.82rem; }
.admin-user strong { display: block; word-break: break-all; }
.admin-user small { color: #94a3b8; display: block; }
.admin-user a { color: #99f6e4; }
.admin-user form { margin-top: 0.2rem; }
.admin-main { padding: 1.5rem 2rem 3rem; min-width: 0; }
.admin-topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-topbar h1 { margin: 0; font-size: 1.8rem; }
.timeline-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.8rem; }
.timeline-list li { display: flex; gap: 0.7rem; align-items: flex-start; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 0.4rem; flex: 0 0 auto; }
.timeline-list small { color: var(--muted); display: block; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #ccfbf1, transparent 35%), radial-gradient(circle at 90% 20%, #fef3c7, transparent 30%), var(--bg); padding: 1rem; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow); }
.login-card h1 { margin: 1rem 0 0.2rem; }
.login-card .btn { margin-top: 0.4rem; }

@media (max-width: 900px) {
  .hero, .two-col { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-main { padding: 1rem; }
}
@media (max-width: 600px) {
  .container { width: min(100% - 20px, 1180px); }
  .hero { padding: 1.2rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .hour-row { grid-template-columns: 82px 1fr 44px; }
  .hour-row small { display: none; }
  .public-nav { gap: 0.6rem; }
  .public-nav a { font-size: 0.82rem; }
  .table { font-size: 0.8rem; }
}
