:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06);
  --radius: 8px;
  --sidebar: 240px;
  --sidebar-min: 64px;
  --header: 48px;
  --font: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 13px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 18px; }
h2 { font-size: 14px; }
p { margin: 0; }

/* layout */
.app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
body.nav-collapsed .sidebar { width: var(--sidebar-min); }
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header);
  padding: 0 14px;
  border-bottom: 1px solid #1f2937;
  font-weight: 650;
  color: #fff;
  letter-spacing: -0.02em;
}
.side-brand small {
  display: block;
  font-weight: 400;
  font-size: 10px;
  color: #9ca3af;
  letter-spacing: 0;
}
.side-brand svg { flex-shrink: 0; }
body.nav-collapsed .side-brand span { display: none; }
.side-nav { padding: 8px; flex: 1; overflow: auto; }
.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  padding: 10px 10px 4px;
}
body.nav-collapsed .nav-section { display: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #d1d5db;
  text-decoration: none;
}
.nav-link:hover { background: #1f2937; text-decoration: none; color: #fff; }
.nav-link.active { background: #1d4ed8; color: #fff; }
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
body.nav-collapsed .nav-link span { display: none; }
body.nav-collapsed .nav-link { justify-content: center; padding: 10px; }
.side-foot {
  padding: 8px;
  border-top: 1px solid #1f2937;
}
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.crumbs { color: var(--muted); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.crumbs a { color: var(--muted); }
.crumbs strong { color: var(--text); font-weight: 600; }
.grow { flex: 1; }
.page { padding: 16px 20px 32px; }

/* controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { border-color: var(--border); }
.btn.ghost { background: transparent; }
.btn.destructive { background: var(--danger); color: #fff; }
.btn.icon {
  width: 32px;
  padding: 0;
  border-color: var(--border);
}
.btn.sm { height: 28px; padding: 0 8px; font-size: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 550; }
.req::after { content: " *"; color: var(--danger); }
.help { color: var(--muted); font-size: 12px; }
.err { color: var(--danger); font-size: 12px; }
input[type="text"], input[type="search"], input[type="email"], input[type="date"],
input[type="time"], input[type="datetime-local"], input[type="password"],
select, textarea {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface);
  outline: none;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #2563eb22; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
  height: 32px;
  background: var(--surface);
  min-width: 220px;
}
.search input { border: 0; height: 30px; padding: 0; box-shadow: none; flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* badges / tabs */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #f3f4f6;
  color: #374151;
}
.badge.draft, .badge.archived, .badge.viewer { background: #f3f4f6; }
.badge.scheduled, .badge.editor { background: var(--accent-soft); color: var(--accent); }
.badge.sending { background: var(--warn-soft); color: var(--warn); }
.badge.sent, .badge.active, .badge.administrator { background: var(--ok-soft); color: var(--ok); }
.badge.paused, .badge.manager { background: #eef2ff; color: #4338ca; }
.badge.failed, .badge.bounced, .badge.unsubscribed { background: var(--danger-soft); color: var(--danger); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  background: none;
  border: 0;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* cards / kpi */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-b { padding: 12px; }
.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.kpi { padding: 12px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .val { font-size: 20px; font-weight: 650; letter-spacing: -0.03em; margin: 4px 0; }
.kpi .delta { font-size: 11px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.split-3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }

/* table */
.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.data th, table.data td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  background: #fafafa;
  cursor: pointer;
  user-select: none;
}
table.data tbody tr:hover { background: #f9fafb; }
table.data tbody tr.click { cursor: pointer; }
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  color: var(--muted);
}

/* overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgb(17 24 39 / 0.4);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}
.overlay.center { justify-content: center; align-items: center; }
.dialog {
  background: var(--surface);
  border-radius: 10px;
  width: min(440px, calc(100% - 32px));
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.15);
  max-height: 90vh;
  overflow: auto;
}
.drawer {
  width: min(460px, 100%);
  background: var(--surface);
  height: 100%;
  box-shadow: -8px 0 24px rgb(0 0 0 / 0.08);
  display: flex;
  flex-direction: column;
}
.drawer-h, .dialog-h {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-b, .dialog-b { padding: 16px; overflow: auto; flex: 1; }
.drawer-f, .dialog-f {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #111827;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  min-width: 240px;
  box-shadow: var(--shadow);
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
.menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
  min-width: 160px;
  z-index: 40;
  padding: 4px;
}
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.menu button:hover { background: #f3f4f6; }
.menu button.d { color: var(--danger); }
.popover {
  position: absolute;
  top: 44px;
  right: 8px;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
  z-index: 40;
  display: none;
}
.popover.open { display: block; }
.search-hits { position: relative; }
.search-panel {
  position: absolute;
  top: 36px;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
  z-index: 40;
  display: none;
  max-height: 320px;
  overflow: auto;
}
.search-panel.open { display: block; }
.search-panel a, .note {
  display: block;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
}
.search-panel a:hover { background: #f3f4f6; }
.note { color: var(--muted); }

.skel {
  background: linear-gradient(90deg, #eee, #f7f7f7, #eee);
  background-size: 200% 100%;
  animation: sk 1.1s ease infinite;
  border-radius: 4px;
  height: 12px;
}
@keyframes sk { to { background-position: -200% 0; } }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.attn { padding: 8px 0; border-bottom: 1px solid var(--border); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.stepper { display: flex; gap: 16px; margin-bottom: 16px; }
.step { color: var(--muted); }
.step.on { color: var(--accent); font-weight: 600; }
.preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 220px;
  background: #fafafa;
  padding: 16px;
}
.toggle { display: flex; align-items: center; gap: 8px; }
.userchip { display: flex; align-items: center; gap: 8px; cursor: pointer; border: 0; background: none; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #1d4ed8; color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}

/* marketing */
.mkt { background: #fff; color: var(--text); }
.mkt-nav {
  max-width: 1080px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}
.mkt-brand { font-weight: 700; color: var(--text); letter-spacing: -0.03em; }
.mkt-brand:hover { text-decoration: none; }
.mkt-nav nav { display: flex; gap: 16px; }
.mkt-nav nav a { color: var(--muted); }
.mkt-hero, .mkt-body, .mkt-foot {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px;
}
.mkt-hero h1 { font-size: 28px; letter-spacing: -0.04em; margin: 8px 0 10px; }
.mkt-hero p { color: var(--muted); max-width: 560px; }
.meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin: 16px 0; }
.meta strong { color: var(--text); }
.files {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  margin: 12px 0;
}
.files code { background: #f3f4f6; padding: 6px 8px; border-radius: 6px; }
.host-note {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}
.auth-wrap {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-card { width: min(400px, 100%); }

.mkt-foot { border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.prose h2 { margin: 22px 0 8px; }
.prose p, .prose ul { margin: 0 0 10px; }
.prose ul { padding-left: 18px; }
.prose li { margin: 4px 0; }
.code {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 10px 12px;
  overflow: auto;
  font: 12px/1.5 ui-monospace, Consolas, monospace;
}

.empty { padding: 32px; text-align: center; color: var(--muted); }
.banner-err {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .split, .split-3, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-collapsed .sidebar { transform: translateX(-100%); width: var(--sidebar); }
  .kpis, .grid-2 { grid-template-columns: 1fr 1fr; }
  .search { min-width: 0; flex: 1; }
}
