:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #17203a;
  --muted: #6b7590;
  --line: #e4e7ef;
  --brand: #2b5bd7;
  --brand-dark: #1f45a8;
  --brand-soft: #eaf0ff;
  --ok: #128a4d;
  --ok-soft: #e6f6ed;
  --warn: #b06a00;
  --warn-soft: #fff4e0;
  --bad: #c02626;
  --bad-soft: #fdeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 20px rgba(20, 30, 60, .05);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .35em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 .8em; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 224px; flex: 0 0 224px; background: #101a33; color: #c8d2ea;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; font-size: 16px; margin-bottom: 22px; padding: 0 6px; }
.brand span.dot { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); display: grid; place-items: center; font-size: 12px; }
.side nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: #c8d2ea; font-size: 14px; margin-bottom: 2px;
}
.side nav a:hover { background: #1b294a; color: #fff; text-decoration: none; }
.side nav a.active { background: var(--brand); color: #fff; }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #718099; margin: 18px 0 6px 10px; }
.side .foot { margin-top: 24px; border-top: 1px solid #22304f; padding-top: 12px; font-size: 12.5px; color: #8494b5; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card .hd { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card .bd { padding: 16px; }
.card .bd.tight { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.side-main { grid-template-columns: 340px 1fr; align-items: start; }
@media (max-width: 1000px) { .grid.two, .grid.side-main { grid-template-columns: 1fr; } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 25px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }

/* forms */
label, .lbl { display: block; font-size: 13px; font-weight: 600; color: #3a4667; margin-bottom: 5px; }
.w-input, input[type=text], input[type=email], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d3d9e6; border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff;
}
.w-input:focus, input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field { margin-bottom: 14px; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.errorlist { color: var(--bad); font-size: 13px; margin: 4px 0 0; padding-left: 16px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid transparent; background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; border-color: #d3d9e6; color: var(--ink); }
.btn.ghost:hover { background: #f2f4fa; color: var(--ink); }
.btn.danger { background: var(--bad); } .btn.danger:hover { background: #9c1d1d; }
.btn.warn { background: var(--warn); } .btn.warn:hover { background: #8a5300; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfe; }
td { padding: 10px 14px; border-bottom: 1px solid #eef0f6; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }
.mono { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.sent, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.failed, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.pending, .pill.draft { background: #eef1f7; color: #5a678a; }
.pill.sending, .pill.queued { background: var(--brand-soft); color: var(--brand); }
.pill.paused { background: var(--warn-soft); color: var(--warn); }
.pill.new { background: var(--brand); color: #fff; }

/* progress */
.bar { height: 12px; border-radius: 999px; background: #e9edf6; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #2b5bd7, #4f80ff); transition: width .4s ease; }
.bar.done > i { background: linear-gradient(90deg, #128a4d, #2fb571); }
.progress-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 13.5px; }
.progress-legend b { font-size: 17px; display: block; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* messages */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.flash.success { background: var(--ok-soft); border-color: #b6e2c9; color: #0d6b3c; }
.flash.error { background: var(--bad-soft); border-color: #f3c2c2; color: #96201f; }
.flash.info, .flash.warning { background: var(--brand-soft); border-color: #c6d6ff; color: #23479f; }

/* email preview */
.mail-frame { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.mail-head { padding: 12px 16px; background: #fafbfe; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.mail-head .k { color: var(--muted); display: inline-block; min-width: 62px; }
.mail-body { padding: 18px 16px; }
.mail-body img { max-width: 100%; }
.mail-body table { width: auto; }

/* misc */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tag-key { background: var(--brand-soft); color: var(--brand-dark); padding: 1px 6px; border-radius: 5px; font-family: monospace; font-size: 12.5px; cursor: pointer; }
.scroll-y { max-height: 460px; overflow-y: auto; }
.err-text { color: var(--bad); font-size: 12.5px; word-break: break-word; }
.ck-editor__editable_inline { min-height: 300px; }
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
