:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d2320;
  --muted: #68716c;
  --line: #e3e0d9;
  --accent: #0f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0ea;
  --warn: #a15c00;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --info: #24589c;
  --info-soft: #e3ecf8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; background: linear-gradient(to right, #16201c 220px, transparent 220px); }
.side { background: #16201c; color: #cfd8d3; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 17px; margin: 0 8px 22px; display: flex; gap: 8px; align-items: center; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: #3ccf91; }
.nav a { display: block; color: inherit; text-decoration: none; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.06); }
.nav a.on { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.side-foot { position: absolute; bottom: 16px; left: 14px; right: 14px; }
.side-foot button { width: 100%; background: transparent; color: #cfd8d3; border: 1px solid rgba(255,255,255,.18); }
main { padding: 26px 30px 60px; max-width: 1180px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* status strip */
.strip { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.pill.ok i { background: #1f9d6b; } .pill.warn i { background: #d68a00; } .pill.bad i { background: var(--bad); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2 { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: default; }
.tile.click { cursor: pointer; }
.tile.click:hover { border-color: var(--accent); }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .p { font-size: 12px; color: var(--muted); }
.tile.bad .v { color: var(--bad); }
.tile.good .v { color: var(--accent); }

/* funnel */
.funnel { display: grid; gap: 8px; }
.frow { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.fbar { height: 14px; background: #eeebe5; border-radius: 4px; overflow: hidden; }
.fbar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; min-width: 2px; }
.fbar.c span { background: #24589c; } .fbar.r span { background: #8a5cc2; } .fbar.f span { background: var(--bad); }
.frow .n { text-align: right; font-variant-numeric: tabular-nums; }

/* forms */
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 5px; }
label .muted { font-weight: 400; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 150px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.row > .auto { flex: 0 0 auto; }
button, .btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #c8c3b8; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint { background: var(--info-soft); color: #193f70; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.hint code { background: rgba(255,255,255,.7); padding: 1px 5px; border-radius: 4px; }
.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.alert.warn { background: var(--warn-soft); color: #6b3d00; }
.alert.bad { background: var(--bad-soft); color: #7a1912; }
.alert.ok { background: var(--accent-soft); color: #0b4a37; }

/* table */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid #f0ede7; vertical-align: top; }
tr:hover td { background: #faf9f6; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b-queued { background: #eeebe5; color: #5b5f5c; }
.b-sent { background: var(--info-soft); color: var(--info); }
.b-delivered { background: #dff0f4; color: #1d6577; }
.b-read { background: var(--accent-soft); color: var(--accent); }
.b-failed { background: var(--bad-soft); color: var(--bad); }
.b-skipped { background: var(--warn-soft); color: var(--warn); }
.b-draft { background: #eeebe5; color: #5b5f5c; }
.b-running { background: var(--accent-soft); color: var(--accent); }
.b-paused { background: var(--warn-soft); color: var(--warn); }
.b-done { background: var(--info-soft); color: var(--info); }
.b-stopped { background: var(--bad-soft); color: var(--bad); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button { font-weight: 500; padding: 6px 12px; border-radius: 999px; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.reply { background: #f3f8f5; border-left: 3px solid var(--accent); padding: 4px 8px; border-radius: 4px; margin-top: 4px; white-space: pre-wrap; max-width: 360px; }
.clist { display: grid; gap: 10px; }
.citem { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; }
.citem:hover { border-color: var(--accent); }
.mini { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.mini b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* bubble preview */
.phone { background: #e9e3d8; border-radius: 12px; padding: 16px; min-height: 160px; }
.bubble { background: #d8f5c8; border-radius: 10px 10px 2px 10px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; margin-left: auto; max-width: 92%; box-shadow: 0 1px 1px rgba(0,0,0,.08); font-size: 13.5px; }

/* QR */
.qrbox { display: grid; grid-template-columns: 300px 1fr; gap: 24px; align-items: start; }
.qrbox img { width: 280px; height: 280px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.steps { margin: 0; padding-left: 18px; }
.steps li { margin-bottom: 6px; }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.quota { height: 8px; background: #eeebe5; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.quota span { display: block; height: 100%; background: var(--accent); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; background: none; }
  .side { position: static; height: auto; padding: 12px 16px; }
  .brand { margin-bottom: 10px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; }
  .nav a { white-space: nowrap; }
  .side-foot { position: absolute; top: 12px; right: 16px; left: auto; bottom: auto; }
  .side { position: relative; }
  .side-foot button { width: auto; padding: 5px 10px; font-size: 12px; }
  main { padding: 18px 16px 50px; }
  .grid2, .grid3, .qrbox { grid-template-columns: 1fr; }
  .frow { grid-template-columns: 90px 1fr 56px; }
}
