/* WA Sender — pine ink, cool mist, receipt-tick blue. */
:root {
  --ink: #0e2a2c;
  --ink-2: #163a3d;
  --ink-text: #b9cfcc;
  --bg: #f2f5f4;
  --card: #ffffff;
  --text: #13201f;
  --muted: #61716f;
  --line: #e1e8e6;
  --line-2: #eef2f1;
  --go: #16a374;
  --go-deep: #0f8a61;
  --go-soft: #e3f5ee;
  --read: #3b8fe0;
  --hold: #e09a2d;
  --hold-soft: #fdf3e2;
  --stop: #d5455c;
  --stop-soft: #fcebee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(14, 42, 44, .05), 0 4px 16px rgba(14, 42, 44, .05);
  --display: "Bricolage Grotesque", "Hind Siliguri", system-ui, sans-serif;
  --body: "Hind Siliguri", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--body); background: var(--bg); color: var(--text); }
a { color: var(--go-deep); text-underline-offset: 3px; }
a:hover { color: var(--go); }
code { font: 13px var(--mono); background: var(--line-2); padding: 1px 6px; border-radius: 6px; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--read); outline-offset: 2px; }
.ico { width: 18px; height: 18px; flex: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: var(--ink-text);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 700 19px var(--display); padding: 4px 8px 22px; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--go); color: #fff; }
.brand-mark .ico { width: 19px; height: 19px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-out {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 10px; color: var(--ink-text); text-decoration: none;
  font: 500 15px var(--body); background: none; border: 0; cursor: pointer; text-align: left;
}
.side-nav a:hover, .side-out:hover { background: var(--ink-2); color: #fff; }
.side-nav a.on { background: var(--ink-2); color: #fff; box-shadow: inset 3px 0 0 var(--go); }
.side-nav .count { margin-left: auto; background: var(--go); color: #fff; font: 600 12px var(--mono); padding: 1px 7px; border-radius: 99px; }
.side-foot { margin-top: auto; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 26px 36px 8px; max-width: 1240px; width: 100%;
}
.topbar h1 { margin: 0; font: 700 30px/1.15 var(--display); letter-spacing: -.02em; overflow-wrap: anywhere; }
.topbar .sub { margin: 4px 0 0; color: var(--muted); }
.number-pill {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 99px;
  padding: 7px 14px 7px 12px; font-size: 13.5px; box-shadow: var(--shadow);
}
.number-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa9a7; box-shadow: 0 0 0 3px rgba(154,169,167,.2); }
.q-green .dot { background: var(--go); box-shadow: 0 0 0 3px rgba(22,163,116,.18); }
.q-yellow .dot { background: var(--hold); box-shadow: 0 0 0 3px rgba(224,154,45,.2); }
.q-red .dot { background: var(--stop); box-shadow: 0 0 0 3px rgba(213,69,92,.2); }
.content { padding: 18px 36px 56px; max-width: 1240px; width: 100%; }
.content h2 { font: 700 19px var(--display); letter-spacing: -.01em; margin: 30px 0 12px; }
.content h3 { font: 600 15px var(--body); margin: 18px 0 8px; }
.content > h2:first-child { margin-top: 6px; }

/* ---------- Cards, notices ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.flash, .warn {
  border-radius: 12px; padding: 12px 16px; margin: 0 0 18px; border: 1px solid;
  display: block;
}
.flash { background: var(--go-soft); border-color: #bfe6d6; color: #0b5f43; }
.flash.error, .warn { background: var(--stop-soft); border-color: #f4c9d0; color: #8c2034; }
.warn form { display: inline; margin-left: 8px; }
.warn ul { margin: 6px 0 0; padding-left: 20px; }
.note { background: var(--line-2); border-radius: 12px; padding: 12px 16px; color: var(--muted); }
.muted { color: var(--muted); font-size: 13.5px; }
.inline { display: inline; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); color: var(--muted); font-size: 13.5px;
}
.stat b { display: block; color: var(--text); font: 700 26px/1.2 var(--display); letter-spacing: -.02em; margin-bottom: 2px; font-feature-settings: "tnum"; }
.stat b.mono { font: 500 19px/1.6 var(--mono); }
.stat .meter { height: 6px; border-radius: 99px; background: var(--line-2); margin-top: 10px; overflow: hidden; }
.stat .meter i { display: block; height: 100%; background: var(--go); border-radius: 99px; }
.stat.alert b { color: var(--go-deep); }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font: 600 12.5px var(--body); padding: 2px 10px 2px 8px; border-radius: 99px; white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip em { font-style: normal; font-weight: 500; opacity: .8; }
.chip-go { background: var(--go-soft); color: var(--go-deep); }
.chip-hold { background: var(--hold-soft); color: #9a6212; }
.chip-stop { background: var(--stop-soft); color: #a8293f; }
.chip-done { background: #e6effa; color: #275f99; }
.chip-idle { background: var(--line-2); color: var(--muted); }

/* ---------- The tick ledger ---------- */
.ledger { margin-top: 14px; }
.ledger-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--line-2); gap: 2px; }
.seg { min-width: 4px; }
.seg-clicked { background: var(--go); }
.seg-read { background: var(--read); }
.seg-delivered { background: #7fb5ea; }
.seg-sent { background: #b9cfe3; }
.seg-queued { background: repeating-linear-gradient(135deg, #dbe3e1 0 5px, #eef2f1 5px 10px); }
.seg-failed { background: var(--stop); }
.seg-empty { flex: 1; }
.ledger-cols { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 14px; }
.lc { display: flex; flex-direction: column; gap: 2px; padding-left: 12px; border-left: 2px solid var(--line); }
.lc .mark { height: 18px; display: flex; align-items: center; color: #8fa09e; }
.lc .mark svg { height: 12px; width: auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lc .num { font: 700 22px/1.2 var(--display); letter-spacing: -.02em; font-feature-settings: "tnum"; }
.lc .lbl { color: var(--muted); font-size: 13px; }
.lc .pct { font: 500 11.5px var(--mono); color: #8fa09e; margin-left: 2px; }
.lc-sent .mark, .lc-delivered .mark { color: #7d8f8d; }
.lc-read .mark { color: var(--read); }
.lc-read { border-left-color: var(--read); }
.lc-clicked { border-left-color: var(--go); }
.lc-clicked .num { color: var(--go-deep); }
.lc .yes { font: 600 13px var(--body); color: #fff; background: var(--go); border-radius: 6px; padding: 0 7px; line-height: 18px; }
.lc .x { font: 700 11px var(--mono); font-style: normal; color: #fff; background: var(--stop); width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; }
.lc-failed .num { color: var(--stop); }

/* Campaign cards on the dashboard */
.camp-card .card-head a { font: 700 17px var(--display); color: var(--text); text-decoration: none; }
.camp-card .card-head a:hover { color: var(--go-deep); }

/* ---------- Tables ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 18px; }
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font: 600 12px var(--body); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #f8faf9; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); font-size: 14.5px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: #fafcfb; }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 13.5px; }
td .mono, td.mono { font-size: 13.5px; }
td a { font-weight: 600; text-decoration: none; }
.body-cell { white-space: pre-wrap; max-width: 420px; color: #2c3a39; }
.empty-row td { text-align: center; color: var(--muted); padding: 34px 16px; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 16px; font-weight: 600; font-size: 14px; }
label .muted { display: block; font-weight: 400; margin-top: 5px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid #d5dedc; border-radius: 10px; background: #fff;
  font: 400 15px var(--body); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--go); box-shadow: 0 0 0 3px rgba(22,163,116,.15); }
textarea { resize: vertical; min-height: 84px; }
input[type=file] { padding: 18px 14px; border: 1.5px dashed #c3d1ce; background: #f8faf9; cursor: pointer; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 2px; margin: 0 0 16px; }
legend { font: 600 13px var(--mono); padding: 0 6px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--go); color: #fff; border: 1px solid var(--go);
  padding: 9px 16px; border-radius: 10px; font: 600 14.5px var(--body);
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
button:hover, .btn:hover { background: var(--go-deep); border-color: var(--go-deep); color: #fff; }
button:active, .btn:active { transform: translateY(1px); }
button.secondary, .btn.secondary { background: #fff; color: var(--text); border-color: #d5dedc; }
button.secondary:hover, .btn.secondary:hover { background: var(--line-2); color: var(--text); }
button.danger { background: var(--stop); border-color: var(--stop); }
button.danger:hover { background: #b83349; border-color: #b83349; }
button.small, .btn.small { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
button .ico, .btn .ico { width: 16px; height: 16px; }

/* ---------- Two-column panels, cost, timeline ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.split > .card { margin-bottom: 18px; }
.cost { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 16px; }
.cost > div { background: #f8faf9; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; }
.cost span { display: block; font-size: 12.5px; }
.cost b { font-size: 17px; }
.timeline { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; }
.timeline dt { color: var(--muted); font-size: 13.5px; }
.timeline dd { margin: 0; font: 500 13.5px var(--mono); }

/* ---------- Template preview (WhatsApp-like) ---------- */
.wa-preview { background: #e7efe9; border-radius: 12px; padding: 16px; }
.wa-bubble { background: #fff; border-radius: 4px 12px 12px 12px; padding: 10px 12px; max-width: 420px; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.06); font-size: 14.5px; }
.wa-buttons { max-width: 420px; display: grid; gap: 4px; margin-top: 4px; }
.wa-buttons span { background: #fff; border-radius: 10px; text-align: center; padding: 7px; color: #1c86c7; font-weight: 600; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.06); }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 150px); min-height: 460px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.convs { border-right: 1px solid var(--line); overflow: auto; }
.convs > p.muted { padding: 16px; margin: 0; }
.conv { padding: 13px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; transition: background .12s; }
.conv:hover { background: #f8faf9; }
.conv.active { background: var(--go-soft); box-shadow: inset 3px 0 0 var(--go); }
.conv > div:first-child { font-weight: 600; display: flex; align-items: center; }
.conv .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.badge { margin-left: auto; background: var(--go); color: #fff; border-radius: 99px; padding: 0 7px; font: 600 11.5px/18px var(--mono); }
.thread-wrap { display: flex; flex-direction: column; min-width: 0; background: #eef3ef; }
.thread { flex: 1; overflow: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 8px; }
.thread > p.muted { margin: auto; text-align: center; }
.bubble { max-width: min(72%, 560px); padding: 8px 12px 6px; border-radius: 12px; white-space: pre-wrap; font-size: 14.5px; box-shadow: 0 1px 1px rgba(0,0,0,.06); overflow-wrap: anywhere; }
.bubble.in { background: #fff; align-self: flex-start; border-top-left-radius: 4px; }
.bubble.out { background: #d6f5e3; align-self: flex-end; border-top-right-radius: 4px; }
.bubble small { display: block; color: #75847f; font: 500 10.5px var(--mono); margin-top: 3px; text-align: right; }
.thread-wrap > .warn { margin: 0 16px 10px; }
.composer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--card); align-items: flex-end; }
.composer textarea { flex: 1; height: 64px; min-height: 64px; margin: 0; }
.composer > div { display: flex; flex-direction: column; gap: 6px; }
.composer > div br { display: none; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 500px at 15% -10%, #16413f 0%, transparent 60%), var(--ink); }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 18px; padding: 32px 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card .brand { color: var(--text); padding: 0 0 6px; }
.login-card .brand:hover { color: var(--text); }
.login-card p.lead { color: var(--muted); margin: 0 0 22px; }
.login-card button { width: 100%; padding: 11px; margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .ledger-cols { grid-template-columns: repeat(3, 1fr); row-gap: 14px; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat b { font-size: 22px; }
  .brand { padding: 0 8px 0 0; font-size: 0; gap: 0; }
  .side-nav { flex-direction: row; gap: 2px; }
  .side-nav a, .side-out { padding: 8px 10px; white-space: nowrap; }
  .side-nav a span, .side-out span { display: none; }
  .side-nav a.on { box-shadow: inset 0 -2px 0 var(--go); }
  .side-foot { margin: 0 0 0 auto; }
  .topbar { padding: 18px 16px 4px; flex-wrap: wrap; }
  .topbar h1 { font-size: 24px; }
  .content { padding: 14px 16px 40px; }
  .form-grid, .split { grid-template-columns: 1fr; }
  .cost { grid-template-columns: 1fr 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .convs { max-height: 34vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .thread { min-height: 50vh; }
  .card { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
