:root {
  --bg: #f4f6f5; --panel: #ffffff; --ink: #14201c; --muted: #5b6b65; --line: #dfe5e2;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #e3f2ef;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --info: #1d4ed8;
  --radius: 10px; --side: 220px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1412; --panel: #141d1a; --ink: #e5ece9; --muted: #93a39c; --line: #26332e;
    --brand: #2dd4bf; --brand-ink: #062a25; --brand-soft: #123a33; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 17px; padding: 0 8px 18px; color: var(--ink); }
.logo i { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); display: inline-block; }
.nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); margin-bottom: 2px; }
.nav a:hover { background: var(--brand-soft); text-decoration: none; }
.nav a.on { background: var(--brand); color: var(--brand-ink); }
.nav .badge { float: right; }
.main { flex: 1; padding: 24px 28px; max-width: 1200px; min-width: 0; }
.side form { margin-top: 18px; padding: 0 10px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
textarea { min-height: 110px; resize: vertical; }
.field { margin-bottom: 14px; }
.btn { display: inline-block; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 8px 15px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.inline { display: inline; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table-wrap { overflow-x: auto; }
td.body { max-width: 420px; white-space: pre-wrap; word-break: break-word; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--ink); }
.pill.queued, .pill.dispatched { background: #fef3c7; color: #78350f; }
.pill.sent { background: #dbeafe; color: #1e3a8a; }
.pill.delivered, .pill.read, .pill.received, .pill.online { background: #dcfce7; color: #14532d; }
.pill.failed, .pill.offline { background: #fee2e2; color: #7f1d1d; }
.pill.cancelled { background: #e5e7eb; color: #374151; }
.pill.whatsapp { background: #d1fae5; color: #065f46; }
.badge { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 12px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash.warn { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.flash.err { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.errors { color: var(--bad); font-size: 13px; margin-top: 4px; }

.thread { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; padding: 6px; }
.bubble { max-width: 72%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.bubble.in { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.bubble.out { align-self: flex-end; background: var(--brand-soft); }
.bubble small { display: block; font-size: 11px; margin-top: 3px; }
.threads a { display: block; padding: 10px 8px; border-bottom: 1px solid var(--line); color: var(--ink); }
.threads a:hover { background: var(--brand-soft); text-decoration: none; }
.code-box { font-family: ui-monospace, Menlo, monospace; font-size: 26px; letter-spacing: .18em; font-weight: 700; padding: 10px 14px; background: var(--brand-soft); border-radius: 8px; display: inline-block; }
.pager { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; }

.login { max-width: 380px; margin: 12vh auto; padding: 0 16px; }

@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .main { padding: 16px; }
}
