/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --ink-950: #04060c;
  --ink-900: #0b1220;
  --ink-850: #0f172a;
  --ink-800: #131c2e;
  --ink-700: #1e293b;

  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-900: #0f172a;

  --green-100: #dcfce7;
  --green-700: #15803d;
  --red-100: #fee2e2;
  --red-700: #b91c1c;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 264px;

  --shadow-card: 0 1px 2px rgba(15, 23, 42, .05), 0 16px 40px -16px rgba(15, 23, 42, .22);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .08);
  --shadow-nav: 0 8px 24px -12px rgba(4, 6, 12, .55);
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--slate-50) 0%, var(--blue-50) 55%, var(--slate-50) 100%);
  background-attachment: fixed;
  color: var(--slate-900);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); }

code {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .9em;
  color: var(--blue-700);
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
}

/* ============================================================
   Sidebar navigation
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--ink-950) 0%, var(--ink-800) 100%);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: -2px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent 0%, var(--blue-500) 50%, transparent 100%);
  opacity: .55;
  pointer-events: none;
}

.sidebar-brand,
.sidebar-brand:link,
.sidebar-brand:visited,
.sidebar-brand:hover {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 26px 22px 20px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.sidebar-brand .brand {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.01em;
  color: #fff;
}

.brand-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 4px;
  margin-right: 9px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  box-shadow: 0 0 14px rgba(59, 130, 246, .75);
  flex-shrink: 0;
}

.sidebar-brand .tagline {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--slate-500);
  padding-left: 19px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 14px;
  flex: 1;
}

.sidebar-nav .nav-link,
.sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--slate-300);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}

.sidebar-nav .nav-link svg,
.sidebar-footer .nav-link svg { flex-shrink: 0; opacity: .8; }

.sidebar-nav .nav-link:hover,
.sidebar-footer .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .07); }

.sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(59, 130, 246, .2);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, .4);
}
.sidebar-nav .nav-link.active svg { opacity: 1; color: var(--blue-400); }

.sidebar-footer {
  flex-shrink: 0;
  padding: 14px;
  border-top: 1px solid rgba(148, 163, 184, .12);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-user {
  padding: 4px 12px 2px;
  font-size: 11.5px;
  color: var(--slate-500);
}
.sidebar-user strong { display: block; margin-top: 2px; color: #fff; font-size: 13.5px; font-weight: 600; }

.sidebar-footer .logout-link:hover { color: #fca5a5; background: rgba(220, 38, 38, .14); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, .6);
  z-index: 150;
}

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 120;
  background: linear-gradient(135deg, var(--ink-950) 0%, var(--ink-800) 100%);
  padding: 12px 16px;
  box-shadow: var(--shadow-nav);
}

.mobile-topbar-brand,
.mobile-topbar-brand:link,
.mobile-topbar-brand:visited,
.mobile-topbar-brand:hover {
  display: inline-flex;
  align-items: center;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, .08);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, .16); }

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 48px rgba(0, 0, 0, .45);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .mobile-topbar { display: flex; }
  .sidebar-toggle { display: inline-flex; }
  .main-wrap { margin-left: 0 !important; }
}

/* ============================================================
   Layout / cards
   ============================================================ */
.main-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.has-sidebar .main-wrap { margin-left: var(--sidebar-w); }
.main-wrap .app-footer { margin-top: auto; }

.container {
  max-width: 760px;
  margin: 40px auto;
  padding: 34px 40px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(15, 23, 42, .04);
  width: 100%;
}
.container.wide { max-width: 1140px; }

/* ============================================================
   Auth pages (login / register split layout)
   ============================================================ */
body.auth-body .container {
  max-width: 940px;
  padding: 0;
  overflow: hidden;
  margin-top: 60px;
}

.auth-shell { display: flex; align-items: stretch; min-height: 560px; }

.auth-side {
  position: relative;
  flex: 0 0 42%;
  background: linear-gradient(160deg, var(--ink-950) 0%, var(--ink-800) 55%, var(--blue-700) 165%);
  color: #fff;
  padding: 44px 38px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.auth-side-glow {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 165, 250, .35), transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  margin-bottom: auto;
  position: relative;
  z-index: 1;
}

.auth-side-title {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -.01em;
  margin: 30px 0 12px;
  position: relative;
  z-index: 1;
}

.auth-side-text {
  font-size: 13.5px;
  color: var(--slate-300);
  line-height: 1.65;
  margin: 0 0 26px;
  position: relative;
  z-index: 1;
}

.auth-side-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.auth-side-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--slate-200);
  line-height: 1.55;
}

.auth-side-list svg { flex-shrink: 0; margin-top: 3px; color: var(--blue-400); }

.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 44px;
  background: #fff;
  min-width: 0;
}

.auth-form-inner { width: 100%; max-width: 340px; }
.auth-form-inner h1 { margin-bottom: 6px; }
.auth-subtitle { color: var(--slate-500); font-size: 13.5px; margin: 0 0 24px; }

.field-icon-group { position: relative; }

.field-icon-group > svg:first-child {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  pointer-events: none;
}

.field-icon-group input[type="email"],
.field-icon-group input[type="password"],
.field-icon-group input[type="text"] {
  padding-left: 38px;
}
.field-icon-group input#password { padding-right: 40px; }

.field-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 7px;
  margin: 0;
  color: var(--slate-400);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  border-radius: 6px;
}
.field-toggle:hover { color: var(--blue-600); background: var(--slate-100); }
.field-toggle:active { transform: translateY(-50%); }

.btn-block { width: 100%; margin-top: 6px; }
.btn-block:disabled { opacity: .7; cursor: not-allowed; }

.auth-footnote { margin-top: 22px; font-size: 13px; color: var(--slate-600); text-align: center; }

@media (max-width: 760px) {
  .auth-side { display: none; }
  body.auth-body .container { max-width: 420px; margin-top: 32px; }
  .auth-form-panel { padding: 38px 28px; }
}

h1 { font-size: 25px; font-weight: 700; color: var(--ink-900); margin: 0 0 10px; letter-spacing: -.01em; }
h2 { font-size: 19px; font-weight: 700; color: var(--blue-700); margin: 32px 0 14px; }
h3 {
  margin: 28px 0 14px;
  color: var(--ink-800);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--slate-200);
  padding-bottom: 10px;
}

p { color: var(--slate-700); line-height: 1.6; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  height: 100px;
  padding: 10px 12px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--slate-900);
  resize: vertical;
  box-sizing: border-box;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="url"], input[type="number"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--slate-900);
  background: #fff;
  margin-bottom: 4px;
  box-sizing: border-box;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .16);
}

.hint { font-size: 12.5px; color: var(--slate-500); margin: 2px 0 12px; }

.filter-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 22px; }
.filter-bar .grow { flex: 2; min-width: 220px; }
.filter-bar .grow-sm { flex: 1; min-width: 140px; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input[type="number"] { width: 72px; margin-bottom: 0; }

/* ============================================================
   Buttons
   ============================================================ */
button, .btn {
  display: inline-block;
  padding: 11px 20px;
  background-color: var(--blue-600);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: background-color .15s ease, transform .05s ease;
}
button:hover, .btn:hover { background-color: var(--blue-700); }
button:active, .btn:active { transform: translateY(1px); }

.btn-danger { background-color: #dc2626; }
.btn-danger:hover { background-color: var(--red-700); }
.btn-muted { background-color: var(--slate-600); }
.btn-muted:hover { background-color: var(--slate-700); }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }

/* ============================================================
   Survey rating chips
   ============================================================ */
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--slate-300);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-600);
  background: #fff;
  cursor: pointer;
  transition: all .15s ease;
}
.radio-group label:hover { border-color: var(--blue-400); background: var(--blue-50); color: var(--blue-700); }
.radio-group input[type="radio"] { accent-color: var(--blue-600); margin: 0; }

/* Progressive enhancement: fills the chip when its radio is checked.
   Falls back to a plain radio + label in browsers without :has(). */
.radio-group label:has(input:checked) {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Progress bar
   ============================================================ */
.progress-bar { width: 100%; background: var(--slate-200); border-radius: 999px; margin-bottom: 20px; height: 10px; overflow: hidden; }
.progress { height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--blue-600)); width: 0%; transition: width .3s ease; }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.alert-success { background: var(--green-100); color: var(--green-700); border-left-color: var(--green-700); }
.alert-error { background: var(--red-100); color: var(--red-700); border-left-color: var(--red-700); }

/* ============================================================
   Tables
   ============================================================ */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 28px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}
th, td {
  border-bottom: 1px solid var(--slate-200);
  padding: 10px 12px;
  text-align: left;
  font-size: 13.5px;
}
th { background: var(--ink-900); color: #fff; font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--slate-50); }
tbody tr:hover { background: var(--blue-50); }

tr.category-row th, th.category-row {
  background: var(--blue-700);
  color: #fff;
  font-size: 12.5px;
  letter-spacing: .03em;
}

.formula { font-weight: 400; font-size: .88em; color: var(--slate-400); }

@media (max-width: 640px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ============================================================
   Stat cards
   ============================================================ */
.stat-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 28px; }
.stat-card {
  flex: 1;
  min-width: 160px;
  background: linear-gradient(160deg, var(--blue-50) 0%, #fff 65%);
  border: 1px solid var(--slate-200);
  border-left: 3px solid var(--blue-600);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--ink-900); letter-spacing: -.02em; }
.stat-card .label { font-size: 12.5px; color: var(--slate-500); margin-top: 4px; font-weight: 500; }

/* ============================================================
   Status pills
   ============================================================ */
.status-pill { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; }
.status-active { background: var(--green-100); color: var(--green-700); }
.status-suspended { background: var(--red-100); color: var(--red-700); }

/* ============================================================
   Misc
   ============================================================ */
.link-box { display: flex; gap: 8px; align-items: center; margin: 10px 0 18px; }
.link-box input { flex: 1; font-family: 'SFMono-Regular', Consolas, Menlo, monospace; margin-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
  margin-top: auto;
  position: relative;
  background: linear-gradient(180deg, var(--ink-900) 0%, var(--ink-950) 100%);
  color: var(--slate-400);
}

.app-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--blue-500) 50%, transparent 100%);
  opacity: .6;
}

.app-footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 40px 28px 28px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 28px;
}

.app-footer-col {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.app-footer-col:not(.app-footer-col-brand) {
  border-left: 1px solid rgba(148, 163, 184, .14);
  padding-left: 28px;
}

.app-footer-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate-500);
  margin-bottom: 3px;
}

.app-footer-brand {
  display: inline-flex;
  align-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
}

.app-footer-brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 3px;
  margin-right: 8px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
  box-shadow: 0 0 10px rgba(59, 130, 246, .6);
}

.app-footer-tagline { font-size: 12.5px; color: var(--slate-300); margin: 0; }
.app-footer-blurb { font-size: 12px; color: var(--slate-500); line-height: 1.6; margin: 2px 0 0; max-width: 320px; }

.app-footer-col a {
  font-size: 12.5px;
  color: var(--slate-400);
  text-decoration: none;
  transition: color .15s ease;
  width: fit-content;
}
.app-footer-col a:hover { color: #fff; }

.app-footer-dev { font-size: 12.5px; color: var(--slate-400); }
.app-footer-dev strong { color: var(--slate-200); font-weight: 600; }

.app-footer-contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--blue-400) !important;
  text-decoration: none;
  transition: color .15s ease;
}
.app-footer-contact:hover { color: #fff !important; text-decoration: underline; }

.app-footer-bottom {
  max-width: 1140px;
  margin: 0 auto;
  padding: 16px 28px 22px;
  border-top: 1px solid rgba(148, 163, 184, .12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11.5px;
  color: var(--slate-600);
}

.app-footer-top {
  color: var(--slate-500);
  text-decoration: none;
  font-size: 11.5px;
  transition: color .15s ease;
}
.app-footer-top:hover { color: var(--blue-400); }

@media (max-width: 760px) {
  .app-footer-inner { grid-template-columns: 1fr; gap: 22px; }
  .app-footer-col:not(.app-footer-col-brand) { border-left: none; padding-left: 0; border-top: 1px solid rgba(148, 163, 184, .14); padding-top: 18px; }
  .app-footer-bottom { justify-content: center; text-align: center; }
}

@media (max-width: 600px) {
  .container { padding: 24px 20px; margin: 20px 12px; }
  .mobile-topbar { padding: 10px 14px; }
}