:root {
  --bg: #f6f7f6; --card: #fff; --ink: #14201f; --muted: #5d6b69; --line: #dde3e1; --soft: #eef2f1;
  --accent: #0f766e; --accent-ink: #fff; --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --err: #b91c1c; --err-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe; --wa: #dcf8c6;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1514; --card: #172120; --ink: #e8efee; --muted: #9bb0ad; --line: #2a3836; --soft: #1e2b29;
    --accent: #2dd4bf; --accent-ink: #04201c; --ok: #4ade80; --ok-bg: #123b22; --warn: #fbbf24; --warn-bg: #3d2f0b;
    --err: #f87171; --err-bg: #431414; --info: #93c5fd; --info-bg: #14274a; --wa: #1f3a2c; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
h1 { font-size: 1.4rem; margin: 0 0 4px; } h2 { font-size: 1.1rem; margin: 0 0 10px; } h3 { font-size: 1rem; margin: 0 0 8px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center-msg { text-align: center; padding: 40px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .grow { flex: 1 1 160px; min-width: 0; }
.stack > * + * { margin-top: 12px; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--soft); padding: 1px 5px; border-radius: 5px; word-break: break-all; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 1.1rem; padding: 4px 10px 12px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.side a.nav { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; }
.side a.nav:hover { background: var(--soft); }
.side a.nav.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.badge-n { margin-left: auto; background: var(--err); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 7px; }
.side .foot { margin-top: auto; padding: 8px 10px; font-size: .85rem; color: var(--muted); }
main { padding: 22px 24px 80px; min-width: 0; max-width: 1150px; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 30; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); gap: 2px; }
  .brand, .side .foot { display: none; }
  .side a.nav { white-space: nowrap; padding: 8px 12px; }
  main { padding: 16px 14px 80px; }
}

/* parts */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; } .cols-2 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; } .stat span { color: var(--muted); font-size: .82rem; }
button, .btn { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--err); } button.sm { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-height: 40px; max-width: 100%; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 3px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: .95rem; }
.field { min-width: 0; } .field input, .field select { width: 100%; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--soft); }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); } .pill.info { background: var(--info-bg); color: var(--info); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { background: var(--soft); border: 1px solid var(--line); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: .85rem; display: inline-flex; align-items: center; gap: 4px; }
.chip button { border: 0; background: none; min-height: 0; padding: 0 6px; color: var(--muted); font-size: 1rem; line-height: 1; }
.bar { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); margin-bottom: 14px; }
.notice.err { background: var(--err-bg); color: var(--err); } .notice.ok { background: var(--ok-bg); color: var(--ok); } .notice.info { background: var(--info-bg); color: var(--info); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.steps { counter-reset: s; } .steps > li { margin-bottom: 6px; }

/* WhatsApp bubbles */
.phone-preview { background: #e5ddd5; border-radius: 14px; padding: 14px; }
@media (prefers-color-scheme: dark) { .phone-preview { background: #0b141a; } }
.bubble { background: var(--card); border-radius: 10px; padding: 8px 12px; max-width: 85%; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.bubble.out { background: var(--wa); margin-left: auto; } .bubble small { display: block; color: var(--muted); font-size: .72rem; text-align: right; margin-top: 2px; }
.thread { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; padding: 12px; background: #e5ddd5; border-radius: 12px; }
@media (prefers-color-scheme: dark) { .thread { background: #0b141a; } }
.inbox { display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
@media (max-width: 800px) { .inbox { grid-template-columns: 1fr; } }
.conv { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; } .conv:hover, .conv.on { background: var(--soft); }
.conv b { display: flex; justify-content: space-between; gap: 8px; }

/* login */
.login { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
.login .card { padding: 24px; }
.login input { width: 100%; margin-bottom: 12px; }

/* drawer / modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; justify-content: flex-end; }
.drawer { background: var(--bg); width: min(560px, 100%); height: 100%; overflow-y: auto; padding: 18px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 99; max-width: 90vw; }
