:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1d212b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --accent: #5b8cff;
  --green: #3fb96f;
  --red: #e5534b;
  --amber: #d9a03f;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.nav {
  display: flex; align-items: center; gap: 4px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.nav .brand { font-weight: 700; font-size: 18px; color: var(--text); margin-right: 16px; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 6px; }
.nav a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.nav .logout { margin-left: auto; }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 6px 12px; }
.linkbtn:hover { color: var(--text); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 24px; margin: 8px 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.inline { display: inline; margin-right: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card .num { font-size: 30px; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: 13px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
.wrapcell { max-width: 340px; word-break: break-word; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 5px 12px; border-radius: 20px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.tab.active { color: var(--text); border-color: var(--accent); }
.tab:hover { text-decoration: none; color: var(--text); }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
form.inline { display: inline; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.st-queued { background: #2a3550; color: #9db8ff; }
.st-sent { background: #173a29; color: #6fd598; }
.st-delivered { background: #0f3d5c; color: #7cc7ff; }
.st-failed { background: #3d1f1c; color: #ff9d95; }
.st-skipped, .st-cancelled { background: #33302a; color: #c9b98f; }
.st-scheduled, .st-in_progress { background: #2a2f3a; color: var(--muted); }
.st-completed { background: #173a29; color: #6fd598; }

.formgrid { display: grid; gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 11px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Checkboxes must not inherit the full-width text-input styling */
input[type='checkbox'] {
  width: auto; display: inline-block; margin: 2px 0 0; padding: 0;
  accent-color: var(--accent); cursor: pointer;
}
.check input[type='checkbox'] { margin: 0; flex: none; }
.check { line-height: 1.5; }

.formgrid > .panel { margin-bottom: 0; }
.panel { scroll-margin-top: 72px; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline-flex; }

.searchbar { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.searchbar input { flex: 1; max-width: 380px; margin-top: 0; }
.searchbar .btn { flex: none; }

.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.subnav a {
  padding: 4px 12px; border-radius: 20px; background: var(--panel);
  border: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.subnav a:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }

.quick { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }

@media (max-width: 700px) {
  .grid2 { grid-template-columns: 1fr; }
  table { font-size: 13px; }
  th, td { padding: 6px 8px; }
  .wrap { padding: 16px 12px 48px; }
  .loginbox { width: 100%; max-width: 340px; }
}
@media (max-width: 460px) {
  .nav { gap: 0; }
  .nav a { padding: 6px 8px; font-size: 14px; }
}
textarea.mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
pre.mono { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 6px 0 6px 26px; position: relative; color: var(--muted); }
.checklist li::before { content: "○"; position: absolute; left: 4px; }
.checklist li.done { color: var(--text); }
.checklist li.done::before { content: "●"; color: var(--green); }

.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.ok { background: #173a29; color: #6fd598; border: 1px solid #235c40; }
.alert.error { background: #3d1f1c; color: #ff9d95; border: 1px solid #5c2a26; }

.loginpage { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.loginbox { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 36px; width: 340px; }
.loginbox h1 { margin-top: 0; }
.loginbox .btn { width: 100%; margin-top: 8px; }
.actions { white-space: nowrap; }
.actions form { display: inline; }

/* multi-tenant nav + badges */
.bizswitch select { padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; max-width: 160px; }
.bizname { font-weight: 600; color: var(--muted); font-size: 13px; padding: 4px 0; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--panel2); border: 1px solid var(--border); }
.pill.ok { color: var(--green); border-color: var(--green); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.danger { border-color: var(--red); }

/* welcome modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; max-width: 480px; width: 100%; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.modal h2 { margin-top: 0; }
.modal .row { margin-top: 16px; }

/* analytics bar chart */
.barchart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.barcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; max-width: 42px; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .85; }
.barval { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.barlbl { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; }

.brandlogo { height: 22px; width: auto; display: inline-block; vertical-align: middle; }

/* ---------- dashboard v2 ---------- */
.hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  background: linear-gradient(135deg, rgba(91,140,255,.14), rgba(91,140,255,.03) 55%, transparent);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 26px 28px; margin-bottom: 22px; position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 200px at 85% -20%, rgba(91,140,255,.18), transparent 70%);
}
.hero-text, .hero-actions { position: relative; }
.hero-eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 4px; }
.hero h1 { margin: 0 0 6px; font-size: 28px; }
.hero p { margin: 0; max-width: 520px; }
.hero-actions { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.btn.big { padding: 11px 22px; font-size: 15px; border-radius: 10px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; position: relative; overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.kpi:hover { transform: translateY(-2px); border-color: #3a4152; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border); }
.kpi.accent::after { background: var(--accent); }
.kpi.green::after { background: var(--green); }
.kpi.gold::after { background: var(--amber); }
.kpi.gold .kpi-num { color: var(--amber); }
.kpi-ic { font-size: 18px; margin-bottom: 8px; }
.kpi-num { font-size: 30px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-lbl { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 6px; }

.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.nowrap { white-space: nowrap; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.frow { display: grid; grid-template-columns: 80px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.flbl { color: var(--muted); font-weight: 600; }
.ftrack { background: var(--panel2); border-radius: 6px; height: 14px; overflow: hidden; }
.fbar { height: 100%; border-radius: 6px; min-width: 4px; transition: width .4s ease; }
.fbar.queued { background: #5b8cff; }
.fbar.sent { background: #3fb96f; }
.fbar.deliv { background: #2f9e8f; }
.fbar.click { background: #d9a03f; }
.fnum { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.progress { background: var(--panel2); border-radius: 8px; height: 8px; overflow: hidden; margin-bottom: 14px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 8px; transition: width .4s ease; }

/* inline SVG icons */
.ic { width: 16px; height: 16px; vertical-align: -3px; flex: none; }
.btn .ic { margin-right: 2px; }
.kpi-ic { color: var(--muted); }
.kpi-ic .ic { width: 20px; height: 20px; }
.kpi.accent .kpi-ic { color: var(--accent); }
.kpi.green .kpi-ic { color: var(--green); }
.check-ic { width: 13px; height: 13px; vertical-align: -2px; color: var(--green); }
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars svg { width: 14px; height: 14px; display: block; }
.stars .on { fill: var(--amber); }
.stars .off { fill: none; stroke: var(--border); stroke-width: 2; }

/* ---------- inbox threads ---------- */
.thread { padding: 0; }
.thread > summary {
  list-style: none; cursor: pointer; padding: 14px 18px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center;
}
.thread > summary::-webkit-details-marker { display: none; }
.thread > summary::after { content: "▾"; color: var(--muted); grid-column: 2; grid-row: 1 / span 2; align-self: center; transition: transform .15s; }
.thread[open] > summary::after { transform: rotate(180deg); }
.thread-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.thread-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.thread-msgs { border-top: 1px solid var(--border); padding: 12px 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 78%; padding: 9px 13px; border-radius: 12px; font-size: 14px; }
.msg.out { align-self: flex-end; background: rgba(91,140,255,.14); border: 1px solid rgba(91,140,255,.3); border-bottom-right-radius: 4px; }
.msg.in { align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.msg-body { white-space: pre-wrap; word-break: break-word; }

/* ---------- private feedback list ---------- */
.fb-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.fb-item:last-child { border-bottom: none; }
.fb-stars { color: var(--amber); font-weight: 700; white-space: nowrap; padding-top: 2px; }
.fb-comment { flex: 1; }
.fb-who { color: var(--muted); font-size: 12px; margin-top: 3px; }

@media (max-width: 800px) {
  .hero { flex-direction: column; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1; text-align: center; }
  .frow { grid-template-columns: 64px 1fr 36px; }
}
