/* Zefiro admin — Your message, everywhere. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f1b2d;
  --muted: #5b6b80;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #e8f0fe;
  --accent: #14b8a6;
  --success: #0f8a5f;
  --success-soft: #e3f6ee;
  --warning: #a16207;
  --warning-soft: #fdf3dc;
  --danger: #c53030;
  --danger-soft: #fdeaea;
  --sidebar: #0e1a2b;
  --sidebar-ink: #c9d6e8;
  --sidebar-active: #1c2c44;
  --chart: #2563eb;
  --chart-2: #14b8a6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 1px 3px rgba(15, 27, 45, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1320;
    --surface: #111c2d;
    --surface-2: #0f1828;
    --border: #22324a;
    --text: #e6edf7;
    --muted: #93a3b8;
    --primary: #4f8ff7;
    --primary-soft: #16294a;
    --success: #34c38f;
    --success-soft: #0f2e25;
    --warning: #e0a83a;
    --warning-soft: #33280f;
    --danger: #f06464;
    --danger-soft: #3a1717;
    --sidebar: #08101b;
    --sidebar-active: #15233a;
    --chart: #4f8ff7;
    --chart-2: #2dd4bf;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-ink);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand img { width: 34px; height: 34px; }
.brand b { display: block; font-size: 17px; letter-spacing: .01em; }
.brand span { display: block; font-size: 11px; color: var(--sidebar-ink); opacity: .75; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-ink); font-weight: 500;
}
.nav a:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.nav a[aria-current="page"] { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 8px; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar .who { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar .who b { color: #fff; display: block; }
.sidebar .who form { margin-top: 8px; }
.sidebar .who button { background: none; border: 1px solid rgba(255,255,255,.18); color: var(--sidebar-ink); padding: 5px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
.sidebar .who button:hover { color: #fff; border-color: rgba(255,255,255,.35); }

main { padding: 28px 32px 48px; min-width: 0; }
.page { max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .brand { padding: 0 8px 0 0; }
  .brand span { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 7px 10px; }
  .nav a span { display: none; }
  .nav .sep { display: none; }
  .sidebar .who { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; }
  .sidebar .who b, .sidebar .who .role { display: none; }
  .sidebar .who form { margin: 0; }
  main { padding: 20px 16px 40px; }
}

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card > .card-body { padding: 18px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid > .card { margin-top: 0; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-main, .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .cols-2, .cols-4 { grid-template-columns: 1fr; } }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .value.small-value { font-size: 20px; padding: 5px 0 3px; }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---- flash ---- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid; }
.flash.ok { background: var(--success-soft); border-color: transparent; color: var(--success); }
.flash.err { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.secret-once { background: var(--warning-soft); color: var(--text); border: 1px solid var(--warning); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; }
.secret-once code { display: block; margin-top: 8px; padding: 10px; font-size: 14px; user-select: all; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
.title-cell { max-width: 420px; }
.title-cell a { color: var(--text); font-weight: 550; }
.title-cell .muted { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.sent, .badge.active { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.sending { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.badge.scheduled { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.canceled, .badge.paused, .badge.revoked { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); font-size: 12.5px; font-weight: 550; margin: 2px 2px 2px 0; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 1px; }
.linkbtn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

/* ---- forms ---- */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.field .help { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.field .error { color: var(--danger); font-size: 13px; margin-top: 5px; font-weight: 500; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 80px; }
.counter { float: right; color: var(--muted); font-weight: 400; font-size: 12px; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice label {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-weight: 500; background: var(--surface);
}
.choice label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.filters input, .filters select { width: auto; min-width: 180px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 180px; }
details > summary { cursor: pointer; font-weight: 600; color: var(--primary); }
details[open] > summary { margin-bottom: 12px; }
.estimate { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 550; }
.estimate b { font-size: 20px; font-variant-numeric: tabular-nums; }

/* ---- composer ---- */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.compose .preview-col { position: sticky; top: 20px; }
@media (max-width: 1000px) { .compose { grid-template-columns: 1fr; } .compose .preview-col { position: static; } }
.picker { margin-top: 8px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.picker button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.picker button:hover { background: var(--primary-soft); }
.picker button small { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }

/* notification preview (browser style) */
.notif { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(15,27,45,.12); overflow: hidden; }
.notif .n-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px 0; font-size: 12px; color: var(--muted); }
.notif .n-head img { width: 14px; height: 14px; border-radius: 3px; }
.notif .n-main { display: flex; gap: 12px; padding: 8px 12px 12px; }
.notif .n-text { flex: 1; min-width: 0; }
.notif .n-title { font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.notif .n-body { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.notif .n-icon { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.notif .n-image { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; background: var(--surface-2); }
.preview-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }

/* ---- chart ---- */
.chart svg { width: 100%; height: 140px; display: block; }
.chart .bar { fill: var(--chart); }
.chart .bar:hover { fill: var(--chart-2); }
.chart .axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--chart); margin-right: 6px; vertical-align: -1px; }

progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--primary), var(--accent)); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--primary), var(--accent)); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent),
  radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.login { width: 100%; max-width: 380px; }
.login .card-body { padding: 28px; }
.login .brand-big { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.login .brand-big img { width: 56px; height: 56px; }
.login .brand-big b { font-size: 22px; }
.login .brand-big span { color: var(--muted); font-size: 13.5px; }
.login .btn { width: 100%; padding: 11px; }

/* channel tree */
.tree li.depth-1 { padding-left: 18px; }
.tree li.depth-2 { padding-left: 36px; }
.tree li.depth-3 { padding-left: 54px; }
.tree li[class^="depth-"]:not(.depth-0) b { font-weight: 500; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 8px 0 18px; }
