:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --bg-elevated: rgba(255,255,255,.82);
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --surface-3: #eef4ff;
  --text: #0f172a;
  --text-soft: #475569;
  --text-faint: #64748b;
  --border: rgba(148,163,184,.18);
  --border-strong: rgba(148,163,184,.28);
  --primary: #2563eb;
  --primary-2: #3b82f6;
  --primary-soft: rgba(37,99,235,.12);
  --primary-glow: rgba(59,130,246,.18);
  --success: #059669;
  --success-soft: rgba(5,150,105,.12);
  --warning: #d97706;
  --warning-soft: rgba(217,119,6,.12);
  --danger: #dc2626;
  --danger-soft: rgba(220,38,38,.10);
  --violet: #7c3aed;
  --violet-soft: rgba(124,58,237,.12);
  --shadow-lg: 0 24px 70px rgba(15, 23, 42, .10);
  --shadow-md: 0 16px 40px rgba(15, 23, 42, .08);
  --shadow-sm: 0 10px 24px rgba(15, 23, 42, .06);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --sidebar-width: 292px;
  --mobile-bottom-nav: 84px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --bg-elevated: rgba(10,20,35,.76);
  --surface: #0e1a2d;
  --surface-2: #101f36;
  --surface-3: #142641;
  --text: #e8efff;
  --text-soft: #b3c1da;
  --text-faint: #8ea1c0;
  --border: rgba(148,163,184,.16);
  --border-strong: rgba(148,163,184,.26);
  --primary: #60a5fa;
  --primary-2: #3b82f6;
  --primary-soft: rgba(96,165,250,.14);
  --primary-glow: rgba(96,165,250,.18);
  --success: #34d399;
  --success-soft: rgba(52,211,153,.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245,158,11,.14);
  --danger: #fb7185;
  --danger-soft: rgba(251,113,133,.14);
  --violet: #a78bfa;
  --violet-soft: rgba(167,139,250,.14);
  --shadow-lg: 0 26px 80px rgba(0, 0, 0, .38);
  --shadow-md: 0 16px 48px rgba(0, 0, 0, .28);
  --shadow-sm: 0 10px 28px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59,130,246,.16), transparent 28%),
    radial-gradient(circle at top right, rgba(14,165,233,.10), transparent 26%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 88%, #ffffff 12%) 100%);
  transition: background .25s ease, color .25s ease;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

.page-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0,1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
  overflow: auto;
}

.sidebar-card,
.panel,
.metric-card,
.table-card,
.form-card,
.section-card,
.stat-card,
.list-card,
.glass-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  margin-bottom: 18px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 14px 28px var(--primary-glow);
}

.brand-copy strong { display: block; font-size: 1rem; letter-spacing: -.03em; }
.brand-copy span { display: block; margin-top: 4px; color: var(--text-faint); font-size: .88rem; }

.sidebar-nav {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.sidebar-link,
.mobile-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 16px;
  color: var(--text-soft);
  font-weight: 700;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.sidebar-link:hover,
.mobile-nav-link:hover,
.sidebar-link.is-active,
.mobile-nav-link.is-active {
  background: var(--primary-soft);
  color: var(--text);
  transform: translateY(-1px);
}

.sidebar-link .meta,
.mobile-nav-link .meta {
  color: var(--text-faint);
  font-size: .82rem;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: 18px;
  padding: 16px;
}

.sidebar-footer p {
  margin: 10px 0 0;
  color: var(--text-faint);
  line-height: 1.55;
  font-size: .9rem;
}

.content-wrap {
  min-width: 0;
  padding: 18px 18px 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
  margin-bottom: 18px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-sm);
}

.topbar-title h1,
.topbar-title h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.8vw, 2.25rem);
  line-height: 1.06;
  letter-spacing: -.05em;
}
.topbar-title p { margin: 8px 0 0; color: var(--text-faint); }
.topbar-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.icon-btn,
.theme-toggle,
.mobile-menu-toggle {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.icon-btn:hover,
.theme-toggle:hover,
.mobile-menu-toggle:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.mobile-menu-toggle { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: .96rem;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 16px 32px var(--primary-glow);
}
.btn.secondary { color: var(--text); background: var(--bg-elevated); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn.ghost { color: var(--primary); background: var(--primary-soft); }
.btn.full { width: 100%; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 800;
  border: 1px solid transparent;
}
.b-blue { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 18%, transparent); }
.b-green { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 18%, transparent); }
.b-amber { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 18%, transparent); }
.b-red { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 18%, transparent); }
.b-violet { background: var(--violet-soft); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 18%, transparent); }

.page-grid,
.grid-2,
.grid-3,
.grid-4,
.stats-grid,
.content-grid,
.dashboard-grid,
.send-grid,
.recipients-grid,
.history-grid,
.detail-grid {
  display: grid;
  gap: 16px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3, .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.dashboard-grid { grid-template-columns: 1.15fr .85fr; }
.send-grid { grid-template-columns: 1.05fr .95fr; }
.history-grid, .detail-grid { grid-template-columns: 1fr; }

.metric-card,
.stat-card {
  padding: 20px;
  min-height: 142px;
}
.metric-card .label,
.stat-card .label { color: var(--text-faint); font-weight: 700; font-size: .9rem; }
.metric-card .value,
.stat-card .value { display: block; margin-top: 10px; font-size: clamp(1.6rem, 3vw, 2.25rem); letter-spacing: -.05em; }
.metric-card .sub,
.stat-card .sub { display: block; margin-top: 10px; color: var(--text-soft); line-height: 1.55; font-size: .93rem; }

.section-card,
.form-card,
.table-card,
.list-card,
.panel {
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.section-head h2,
.section-head h3 { margin: 0; font-size: 1.25rem; letter-spacing: -.03em; }
.section-head p { margin: 8px 0 0; color: var(--text-faint); line-height: 1.6; }

.field-group { display: grid; gap: 8px; }
.field-grid { display: grid; gap: 14px; }
.label { color: var(--text-soft); font-weight: 700; font-size: .92rem; }
.field,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
textarea { min-height: 120px; resize: vertical; }
.field:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 14%, transparent);
}

.kpi-row,
.summary-row,
.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.kpi-row:last-child,
.summary-row:last-child,
.detail-row:last-child { border-bottom: 0; }
.kpi-row span,
.summary-row span,
.detail-row span { color: var(--text-faint); }
.kpi-row strong,
.summary-row strong,
.detail-row strong { text-align: right; letter-spacing: -.02em; }

.table-wrap { width: 100%; overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
thead th {
  text-align: left;
  color: var(--text-faint);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }

.list-stack { display: grid; gap: 12px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
}
.list-item .title { font-weight: 800; letter-spacing: -.02em; }
.list-item .meta { color: var(--text-faint); font-size: .9rem; margin-top: 6px; }

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 260px;
  padding: 30px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 24px;
  color: var(--text-faint);
}
.empty-state strong { color: var(--text); font-size: 1.1rem; }

.mobile-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(88vw, 340px);
  transform: translateX(-104%);
  transition: transform .25s ease;
  z-index: 60;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
}
.mobile-drawer.is-open { transform: translateX(0); }
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 55;
}
.mobile-overlay.is-open { opacity: 1; pointer-events: auto; }
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 45;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
}
.mobile-bottom-nav .nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.mobile-bottom-nav a {
  min-height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: .82rem;
  font-weight: 700;
}
.mobile-bottom-nav a.is-active { color: var(--primary); background: var(--primary-soft); }

.page-title {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -.05em;
}
.page-subtitle { margin: 10px 0 0; color: var(--text-faint); line-height: 1.7; }

.helper-text { color: var(--text-faint); font-size: .9rem; line-height: 1.6; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 20px; }
.mt-5 { margin-top: 24px; }
.w-full { width: 100%; }

@media (max-width: 1180px) {
  .dashboard-grid,
  .send-grid,
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 980px) {
  .page-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-menu-toggle { display: inline-grid; }
  .content-wrap { padding-bottom: calc(var(--mobile-bottom-nav) + 20px); }
  .mobile-bottom-nav { display: block; }
  .grid-3, .stats-grid, .dashboard-grid, .send-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .content-wrap { padding: 12px 12px calc(var(--mobile-bottom-nav) + 18px); }
  .topbar { padding: 12px 14px; min-height: 74px; border-radius: 20px; }
  .topbar-actions .btn.secondary { display: none; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .section-card, .form-card, .table-card, .list-card, .panel, .metric-card, .stat-card { padding: 18px; }
  table { min-width: 620px; }
}
