/* ==========================================================================
   Sender — admin UI
   ========================================================================== */

:root {
  --ink: #101623;
  --ink-2: #3d4757;
  --muted: #6b7688;
  --line: #e4e8ef;
  --line-2: #eef1f6;
  --bg: #f5f7fa;
  --card: #ffffff;
  --brand: #2b5cff;
  --brand-dark: #1c3fd1;
  --brand-soft: #edf1ff;
  --ok: #0d7a52;
  --ok-soft: #e6f6ee;
  --warn: #96590a;
  --warn-soft: #fdf3e0;
  --bad: #ae2620;
  --bad-soft: #fdeceb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 22, 35, .04), 0 8px 24px rgba(16, 22, 35, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; letter-spacing: -.015em; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; }

/* ------------------------------------------------------------- layout ---- */

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #0d1424;
  color: #c3cddf;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, #2b5cff, #6d8cff);
  color: #fff;
  display: grid;
  place-items: center;
}

.brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: -.01em; }
.brand small { color: #7f8da5; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #b3bfd2;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
}

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }

.nav-link.is-active {
  background: rgba(43, 92, 255, .22);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(110, 143, 255, .4);
}

.nav-logout { margin-top: auto; color: #8f9db3; }

.side-card {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 14px 15px;
}

.side-card-title {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #7f8da5;
  margin-bottom: 8px;
}

.side-stat { display: flex; align-items: baseline; gap: 6px; }
.side-stat b { color: #fff; font-size: 23px; letter-spacing: -.02em; }
.side-stat span { color: #8f9db3; font-size: 12.5px; }

.meter {
  height: 5px;
  background: rgba(255, 255, 255, .12);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 7px;
}

.meter i { display: block; height: 100%; background: linear-gradient(90deg, #2b5cff, #7ee0b8); border-radius: 999px; }
.side-meta { font-size: 11.5px; color: #7f8da5; }

.main { padding: 30px 34px 72px; max-width: 1180px; width: 100%; }

.topbar { margin-bottom: 22px; }
.topbar h1 { font-size: 27px; font-weight: 650; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 14.5px; }

/* --------------------------------------------------------------- cards ---- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}

.card + .card { margin-top: 18px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-head h2 { font-size: 17px; font-weight: 620; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

/* ---------------------------------------------------------------- kpis ---- */

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 11.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.025em; margin-top: 5px; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .06s ease;
  text-decoration: none;
}

.btn:hover { background: #fafbfd; border-color: #d3d9e3; text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(43, 92, 255, .35);
}

.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-danger { color: var(--bad); border-color: #f0cdca; background: var(--bad-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------- forms ---- */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 580;
  margin-bottom: 6px;
  color: var(--ink-2);
}

.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #a9bcff;
  box-shadow: 0 0 0 3px rgba(43, 92, 255, .13);
}

textarea { resize: vertical; min-height: 110px; font-family: var(--mono); font-size: 13px; }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* -------------------------------------------------------------- tables ---- */

.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }

table.data th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfe; }
table.data .num { font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- badges ---- */

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .03em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-pending  { background: #eef1f7; color: #4b5566; }
.badge-sent     { background: var(--ok-soft); color: var(--ok); }
.badge-unsub    { background: var(--warn-soft); color: var(--warn); }
.badge-invalid  { background: var(--bad-soft); color: var(--bad); }
.badge-bounced  { background: #fdeee0; color: #96590a; }

/* -------------------------------------------------------------- alerts ---- */

.flash, .note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
}

.flash-ok, .note-ok { background: var(--ok-soft); color: #0a5b3e; border: 1px solid #bfe6d3; }
.flash-alert, .note-bad { background: var(--bad-soft); color: #8d1f1a; border: 1px solid #f3c9c6; }
.note-warn { background: var(--warn-soft); color: #7a4a08; border: 1px solid #f0d9b0; }

.note { display: block; }
.note code, .hint code, td code, p code, li code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: #eef1f6;
  padding: 1.5px 5px;
  border-radius: 5px;
  color: #1c2b45;
}

.note p { margin: 0 0 8px; }
.note p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------- compose ---- */

.compose-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }

.preview-frame {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  height: 620px;
}

.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

.preview-meta {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}

.preview-meta div { display: flex; gap: 8px; padding: 3px 0; }
.preview-meta span { color: var(--muted); width: 62px; flex: 0 0 auto; }
.preview-meta strong { font-weight: 550; word-break: break-all; }

/* --------------------------------------------------------------- login ---- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 15% -10%, #dfe7ff 0%, transparent 60%),
    radial-gradient(700px 400px at 95% 110%, #e0f6ee 0%, transparent 55%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(16, 22, 35, .1);
  padding: 30px 30px 26px;
}

.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 38px; height: 38px; }
.login-brand h1 { font-size: 19px; font-weight: 650; }
.login-brand p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- misc ---- */

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { width: 34px; height: 34px; margin-bottom: 10px; color: #b7c0cf; }
.empty h3 { font-size: 16px; color: var(--ink); margin-bottom: 6px; }

.section-title {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  margin: 24px 0 10px;
}

.kv { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 0; font-size: 14px; }
.kv dt { color: var(--muted); padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.kv dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line-2); word-break: break-word; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef1f7;
  color: #4b5566;
  border: 1px solid var(--line);
}
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe6d3; }
.pill-bad { background: var(--bad-soft); color: var(--bad); border-color: #f3c9c6; }

.prose { font-size: 14.5px; color: var(--ink-2); }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 20px; }
.prose li { margin: 5px 0; }
.prose h4 { font-size: 14.5px; margin: 18px 0 7px; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=text] { width: 230px; }
.toolbar select { width: auto; min-width: 150px; }

/* --------------------------------------------------------------- chart ---- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 220px;
  padding: 8px 4px 0;
}

.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: calc(100% - 26px);
  width: 100%;
  justify-content: center;
}

.chart-bar {
  width: 8px;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: height .4s cubic-bezier(.2,.8,.3,1);
}

.chart-label {
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  padding-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.legend-item i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* -------------------------------------------------------------- funnel ---- */

.funnel { display: flex; flex-direction: column; gap: 14px; }
.funnel-row { display: grid; grid-template-columns: 82px minmax(0,1fr) 110px; gap: 14px; align-items: center; }
.funnel-label { font-size: 13px; font-weight: 580; color: var(--ink-2); }
.funnel-track { height: 22px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.3,1); }
.funnel-value { font-size: 14px; font-weight: 620; text-align: right; white-space: nowrap; }
.funnel-value small { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* ------------------------------------------------------------ progress ---- */

.send-progress { margin-top: 16px; }
.send-progress .meter.big { height: 8px; margin: 0 0 8px; }
.send-progress-label { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 14px; }
  .brand { border-bottom: none; padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-card { display: none; }
  .nav-logout { margin-top: 0; }
  .main { padding: 22px 18px 60px; }
  .compose-grid, .grid-2, .grid-4, .form-row { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
}
