:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --line: #e3e8e6;
  --text: #17211f;
  --muted: #64716e;
  --brand: #0f766e;
  --brand-dark: #0b5c56;
  --brand-soft: #e3f4f1;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #92600a;
  --warn-soft: #fdf3dc;
  --info: #1d5fa8;
  --info-soft: #e6f0fb;
  --bubble-out: #d9fdd3;
  --chat-bg: #efeae2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 1px 3px rgba(16, 24, 22, .04);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 650; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: #0d2b28; color: #cfe1dd; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: #14b8a6; display: grid; place-items: center; }
.logo-mark svg { width: 17px; height: 17px; fill: #06302c; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #cfe1dd; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.nav a.active { background: rgba(20, 184, 166, .2); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .count { margin-left: auto; background: #14b8a6; color: #06302c; border-radius: 99px; font-size: 11.5px; font-weight: 700; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 12.5px; }
.sidebar-foot .name { color: #fff; font-weight: 600; }
.sidebar-foot button { background: none; border: 0; color: #9fc0ba; padding: 0; cursor: pointer; font: inherit; }
.sidebar-foot button:hover { color: #fff; }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 2px; }
.banner {
  background: var(--warn-soft); color: var(--warn); border: 1px solid #f1dca6; border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.grid { display: grid; gap: 14px; }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12.5px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f2f5f4; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #5eead4; outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid #cfd8d5; border-radius: 8px; padding: 8px 11px; font: inherit; color: var(--text); background: #fff;
}
textarea { resize: vertical; min-height: 90px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--brand-soft); color: var(--brand-dark); border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 550; }
.chip.pick { cursor: pointer; border: 1px solid transparent; background: #eef1f0; color: var(--muted); user-select: none; }
.chip.pick.on { background: var(--brand-soft); color: var(--brand-dark); border-color: #9fd9d0; }
.badge { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: #eef1f0; color: var(--muted); text-transform: capitalize; }
.badge.ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: #f8faf9; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 18px 18px 0; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 2px; height: 100%; }
.bars .bar { background: var(--brand); border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .bar.in { background: #f59e0b; }
.bar-labels { display: flex; gap: 6px; padding: 6px 18px 14px; color: var(--muted); font-size: 11px; }
.bar-labels span { flex: 1; text-align: center; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; margin-left: auto; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--brand); margin-right: 5px; }
.legend i.in { background: #f59e0b; }
.progress { height: 8px; background: #e7ecea; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .4s; }

/* whatsapp preview + chat */
.phone { background: var(--chat-bg); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.bubble { background: #fff; border-radius: 8px; padding: 8px 10px; max-width: 290px; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .b-head { font-weight: 650; margin-bottom: 3px; }
.bubble .b-media { background: #dfe5e3; border-radius: 6px; height: 110px; display: grid; place-items: center; color: var(--muted); margin-bottom: 6px; text-transform: capitalize; }
.bubble .b-foot { color: var(--muted); font-size: 12px; margin-top: 4px; }
.bubble .b-btn { border-top: 1px solid #e9eeec; margin: 6px -10px 0; padding: 7px 10px 0; text-align: center; color: #0b74c4; font-weight: 550; }
.inbox { display: grid; grid-template-columns: 310px 1fr; height: calc(100vh - 150px); min-height: 420px; overflow: hidden; }
.conv-list { border-right: 1px solid var(--line); overflow-y: auto; }
.conv { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv:hover { background: #f8faf9; }
.conv.active { background: var(--brand-soft); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #cfe6e2; color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; flex: none; }
.conv .preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .unread { background: var(--brand); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-body { flex: 1; overflow-y: auto; background: var(--chat-bg); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; }
.msg.out { align-items: flex-end; }
.msg.out .bubble { background: var(--bubble-out); }
.msg .meta { font-size: 11px; color: #6b7672; margin-top: 2px; }
.msg .meta.err { color: var(--danger); }
.chat-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-end; }
.chat-foot textarea { min-height: 40px; height: 40px; max-height: 140px; }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(13, 27, 25, .45); display: grid; place-items: start center; padding: 6vh 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 860px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head button { margin-left: auto; background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: #17211f; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 380px; }
.toast.err { background: var(--danger); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #0d2b28 0%, #0f766e 100%); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .logo { color: var(--text); padding: 0 0 14px; }
.steps { counter-reset: step; display: flex; flex-direction: column; gap: 10px; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: step; display: flex; gap: 10px; }
.steps li::before { content: counter(step); flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 12px; display: grid; place-items: center; }
.copy { display: flex; gap: 8px; align-items: center; background: #f2f5f4; border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 11px; }
.copy code { flex: 1; overflow-wrap: anywhere; }
pre.code { background: #10201e; color: #d7ebe7; border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .logo { padding: 4px 10px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a span.t { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0 8px; }
  .main { padding: 18px 16px 50px; }
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.c2, .grid.split { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .conv-list { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat { height: 70vh; }
}
.chat-head .grow { overflow: hidden; white-space: nowrap; }
.chat-head .grow > * { overflow: hidden; text-overflow: ellipsis; }
.chat-head .chips { flex: 0 1 auto; justify-content: flex-end; max-height: 24px; overflow: hidden; }
