:root {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #eaf1fb;
  --ink: #101828;
  --ink-soft: #4b5768;
  --ink-faint: #8894a6;
  --rule: #dbe4f3;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-ink: #ffffff;
  --success: #15803d;
  --success-bg: #ecfdf3;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121b2e;
  --surface-2: #182338;
  --ink: #e8edf7;
  --ink-soft: #b1bdd1;
  --ink-faint: #7c8aa3;
  --rule: #24314a;
  --accent: #3b82f6;
  --accent-strong: #60a5fa;
  --accent-ink: #08101f;
  --success: #4ade80;
  --success-bg: #0d2818;
  --danger: #f87171;
  --danger-bg: #2a1111;
  --warn: #fbbf24;
  --warn-bg: #2a2008;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6rem; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.8rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

small, .text-small { font-size: 0.85rem; color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }

code, .mono {
  font-family: Consolas, "SF Mono", ui-monospace, monospace;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.92em;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem; }

/* ---- header / nav ---- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-size: 1.3rem; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-dot { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 1.4rem; font-size: 0.95rem; }

.btn-pill, .btn-pill-secondary, .btn-pill-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.55rem 1.2rem;
  border: none;
  cursor: pointer;
}
.btn-pill { background: var(--accent); color: var(--accent-ink); }
.btn-pill:hover { background: var(--accent-strong); text-decoration: none; }
.btn-pill-secondary { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn-pill-secondary:hover { background: var(--surface-2); text-decoration: none; }
.btn-pill-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-pill-danger:hover { background: var(--danger-bg); text-decoration: none; }
.btn-pill[disabled], .btn-pill-secondary[disabled] { opacity: 0.5; cursor: not-allowed; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink-soft);
  cursor: pointer; padding: 0;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--ink); }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }

.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--ink-soft); font: inherit; cursor: pointer; text-decoration: underline;
}
.link-button:hover { color: var(--ink); }

/* ---- main / footer ---- */
.site-main { flex: 1; padding: 2.5rem 0 3rem; }
.site-footer { border-top: 1px solid var(--rule); background: var(--surface); padding: 1.5rem 0; margin-top: auto; }
.site-footer p { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--ink-faint); }
.site-footer p:last-child { margin-bottom: 0; }

/* ---- alerts ---- */
.alert { border-radius: var(--radius); padding: 0.85rem 1.1rem; margin-bottom: 1.25rem; font-size: 0.92rem; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }

/* ---- forms ---- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.field .hint { display: block; font-size: 0.82rem; color: var(--ink-faint); margin-top: 0.3rem; }
.field .field-error { display: block; font-size: 0.82rem; color: var(--danger); margin-top: 0.3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.slug-input-row { display: flex; align-items: center; gap: 0.4rem; }
.slug-input-row .slug-domain { color: var(--ink-faint); white-space: nowrap; }
.slug-check-status { font-size: 0.85rem; margin-top: 0.4rem; min-height: 1.2em; }
.slug-check-status.ok { color: var(--success); }
.slug-check-status.bad { color: var(--danger); }

/* ---- form-page (auth, errors) ---- */
.form-page { max-width: 440px; margin: 2rem auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.form-page-narrow { max-width: 400px; text-align: center; }

/* ---- panels / cards ---- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.3rem; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; color: var(--accent); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--ink-soft); }

/* ---- tables ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--rule); }
.data-table th { color: var(--ink-soft); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }
.actions-cell { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- chips ---- */
.chip { display: inline-block; padding: 0.2rem 0.65rem; border-radius: 9999px; font-size: 0.78rem; font-weight: 600; }
.chip-active { background: var(--success-bg); color: var(--success); }
.chip-pending_review { background: var(--warn-bg); color: var(--warn); }
.chip-rejected, .chip-disabled { background: var(--danger-bg); color: var(--danger); }
.chip-expired { background: var(--surface-2); color: var(--ink-faint); }

/* ---- home hero + check-slug ---- */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2.4rem; margin-bottom: 0.6rem; }
.hero p { font-size: 1.1rem; color: var(--ink-soft); max-width: 620px; margin: 0 auto 1.5rem; }
.checker-panel { max-width: 480px; margin: 0 auto 2.5rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; }
.disclaimer-banner { background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.25rem; font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 2rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; margin: 2.5rem 0; }
.feature-card { text-align: center; padding: 1rem; }
.feature-card .feature-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }

/* ---- app shell (dashboard/admin) ---- */
.app-body { background: var(--bg); }
.app-shell { display: flex; max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; gap: 2rem; align-items: flex-start; }
.app-sidebar { width: 200px; flex-shrink: 0; position: sticky; top: 1.5rem; }
.app-sidebar-title { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: 0.75rem; }
.app-sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.app-sidebar-nav a { padding: 0.5rem 0.7rem; border-radius: 8px; color: var(--ink-soft); font-size: 0.92rem; }
.app-sidebar-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.app-main { flex: 1; min-width: 0; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; position: static; }
  .app-sidebar-nav { flex-direction: row; flex-wrap: wrap; }
}

/* ---- QR + link detail ---- */
.qr-box { display: inline-flex; flex-direction: column; align-items: center; gap: 0.6rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem; }
.qr-box img { width: 160px; height: 160px; image-rendering: pixelated; background: #fff; border-radius: 6px; }
.short-url-box { display: flex; align-items: center; gap: 0.5rem; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 8px; padding: 0.6rem 0.9rem; font-family: Consolas, "SF Mono", ui-monospace, monospace; }

/* ---- simple bar chart (click analytics) ---- */
.bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin: 1rem 0; }
.bar-chart .bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.bar-chart .bar-empty { background: var(--rule); }

/* ---- interstitial redirect page ---- */
.interstitial { max-width: 480px; margin: 3.5rem auto; text-align: center; }
.interstitial .spinner { width: 36px; height: 36px; border: 3px solid var(--rule); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 1.25rem; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
