:root {
  --amber: #f7a81b; --amber-d: #d08818; --amber-l: #fff3dc;
  --ink: #0b0d12; --text: #14161b; --muted: #6f6e74; --line: #e4e2de; --stone: #f4f3f1; --paper: #fff;
  --wa: #1fa855; --wa-dark: #075e54; --wa-out: #d9fdd3; --wa-bg: #e5ddd5;
  --blue: #2563eb; --green: #16a34a; --red: #dc2626; --purple: #7c3aed; --grey: #64748b;
  --r: 8px;
  --sans: "Helvetica Neue", Helvetica, Inter, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); color: var(--text); background: var(--stone); font-size: 15px; line-height: 1.45; }
button, input { font: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; flex-wrap: wrap; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; display: flex; align-items: center; gap: 22px; padding: 0 20px; height: 60px; border-bottom: 3px solid var(--amber); }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { height: 22px; }
.divider { width: 1px; height: 22px; background: #333; }
.product { font-size: 13px; font-weight: 700; color: #bbb; letter-spacing: 0.04em; text-transform: uppercase; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tab { background: none; border: 0; color: #c9c9c9; font-weight: 700; padding: 8px 12px; border-radius: 6px; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.tab:hover { color: #fff; background: #1c1f26; }
.tab.active { color: var(--ink); background: var(--amber); }
.tab .count { background: rgba(255,255,255,0.15); font-size: 11px; padding: 1px 6px; border-radius: 10px; }
.tab.active .count { background: rgba(0,0,0,0.18); }
.tab .count.amber { background: var(--amber); color: var(--ink); }
.tab.active .count.amber { background: var(--ink); color: var(--amber); }
.phone-tab { display: none; }
.clock { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.clock-label { color: #999; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; font-weight: 700; }
.clock strong { color: #fff; margin-right: 6px; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn { border: 1px solid transparent; border-radius: 6px; padding: 9px 14px; font-weight: 700; cursor: pointer; background: #fff; color: var(--text); border-color: var(--line); }
.btn:hover { border-color: #bbb; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn.big { padding: 13px 18px; font-size: 16px; width: 100%; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn.primary:hover { background: var(--amber-d); border-color: var(--amber-d); }
.btn.ghost { background: transparent; color: inherit; border-color: #444; }
.topbar .btn.ghost { color: #ddd; }
.topbar .btn.ghost:hover { border-color: var(--amber); color: var(--amber); }
.pane .btn.ghost { border-color: var(--line); }
.btn.danger { color: var(--red); border-color: #f3c3c3; }
.btn.danger:hover { background: #fff3f3; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; padding: 24px; max-width: 1480px; margin: 0 auto; align-items: start; }
.pane { min-width: 0; }
.view { display: none; }
.view.active { display: block; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 10px; background: var(--stone); }
.pill.amber { background: var(--amber); color: var(--ink); }

/* ---------- form ---------- */
.form-card { max-width: 720px; }
.form-head { margin-bottom: 18px; }
.form-head p { color: var(--muted); margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px; }
.field em { font-style: normal; text-transform: none; font-weight: 500; letter-spacing: 0; }
.field input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; background: #fff; outline: none; }
.field input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-l); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { padding: 9px 18px; cursor: pointer; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.services label { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; cursor: pointer; display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; }
.services label:hover { border-color: #bbb; }
.services input { display: none; }
.services label:has(input:checked) { border-color: var(--amber); background: var(--amber-l); }
.services .ico { font-size: 18px; }
.consent { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin: 4px 0 14px; cursor: pointer; }
.consent input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--amber); }
.consent small { display: block; color: var(--muted); margin-top: 2px; }
.preview { background: var(--wa-bg); border-radius: 6px; padding: 12px 14px; margin-bottom: 16px; }
.preview-label { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: #6b5f52; margin-bottom: 8px; }
.preview p { background: var(--wa-out); display: inline-block; max-width: 100%; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; font-size: 14px; }
.preview p[dir="rtl"] { text-align: right; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; border-top: 3px solid var(--c, var(--amber)); }
.stat b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ---------- table ---------- */
.search { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; min-width: 260px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 4px 11px; font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, #999); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #faf9f7; }
.table tr.sel td { background: var(--amber-l); }
.table .name b { display: block; }
.table .name small { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; padding: 3px 9px; border-radius: 20px; background: color-mix(in srgb, var(--c) 12%, #fff); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 30%, #fff); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.next b { display: block; font-size: 13px; }
.next small { color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.lang { font-size: 11px; font-weight: 800; border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; color: var(--muted); margin-left: 6px; vertical-align: middle; }

/* ---------- queue ---------- */
.queue { display: flex; flex-direction: column; gap: 8px; }
.qitem { display: grid; grid-template-columns: 44px minmax(0,1.3fr) minmax(0,1.2fr) minmax(0,1fr) auto; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.qitem .qi { width: 44px; height: 44px; border-radius: 6px; display: grid; place-items: center; font-size: 20px; background: var(--stone); }
.qitem.due .qi { background: var(--amber-l); }
.qitem.sent { opacity: .75; }
.qitem.cancelled { opacity: .55; }
.qitem.cancelled .qtype { text-decoration: line-through; }
.qitem b { display: block; }
.qitem small { color: var(--muted); display: block; }
.qitem .acts { display: flex; gap: 6px; }
.queue.compact .qitem { grid-template-columns: 44px minmax(0,1.3fr) minmax(0,1.2fr) minmax(0,1fr) auto; padding: 7px 12px; }
.qempty { color: var(--muted); padding: 10px 0; }

/* ---------- settings ---------- */
.offers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
.offer { border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.offer h3 { margin-bottom: 10px; }

/* ---------- phone ---------- */
.phone-pane { position: sticky; top: 84px; }
.phone { width: 380px; height: 760px; margin: 0 auto; background: #000; border-radius: 44px; padding: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.25); position: relative; display: flex; flex-direction: column; overflow: hidden; }
.notch { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: 120px; height: 28px; background: #000; border-radius: 0 0 18px 18px; z-index: 3; }
.wa-head { background: var(--wa-dark); color: #fff; border-radius: 32px 32px 0 0; padding: 38px 12px 10px; display: flex; align-items: center; gap: 10px; }
.wa-back { background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.wa-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.wa-title { flex: 1; min-width: 0; line-height: 1.15; }
.wa-title b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-title small { font-size: 12px; color: #cfe9e3; }
.wa-icons { font-size: 14px; opacity: .9; }
.wa-chat { flex: 1; background: var(--wa-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ccircle cx='30' cy='30' r='1.2' fill='%23c9bfb4'/%3E%3C/svg%3E"); overflow-y: auto; padding: 10px 10px 6px; display: flex; flex-direction: column; gap: 4px; scroll-behavior: smooth; }
.wa-empty { margin: auto; text-align: center; color: #6b5f52; font-size: 13px; background: rgba(255,255,255,.7); padding: 10px 14px; border-radius: 8px; }
.wa-day { align-self: center; background: #fff; color: #6b5f52; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 6px; margin: 6px 0; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.bub { max-width: 84%; padding: 6px 8px 5px; border-radius: 8px; font-size: 14px; line-height: 1.35; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08); position: relative; }
.bub.out { align-self: flex-end; background: var(--wa-out); border-top-right-radius: 2px; }
.bub.in { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.bub[dir="rtl"] { text-align: right; }
.bub .meta { display: block; font-size: 10px; color: #7b8a84; text-align: right; margin-top: 2px; }
.bub.out .meta::after { content: " ✓✓"; color: #53bdeb; }
.bub a { color: #027eb5; word-break: break-all; }
.bub .tag { display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #8a6b2b; background: #fff0cc; padding: 1px 6px; border-radius: 4px; margin-bottom: 4px; }
.linkcard { display: flex; gap: 8px; background: #f0f8f0; border-radius: 6px; padding: 8px; margin-bottom: 6px; align-items: center; }
.linkcard .g { width: 34px; height: 34px; border-radius: 6px; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #4285f4; border: 1px solid #ddd; }
.linkcard div b { display: block; font-size: 12px; }
.linkcard div small { font-size: 11px; color: #6b7280; }
.typing { align-self: flex-start; background: #fff; padding: 10px 12px; border-radius: 8px; display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.wa-compose { background: #f0f0f0; padding: 8px 10px 28px; display: flex; gap: 8px; border-radius: 0 0 32px 32px; }
.wa-compose input { flex: 1; border: 0; border-radius: 20px; padding: 10px 14px; outline: none; }
.wa-sendbtn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--wa); color: #fff; cursor: pointer; font-size: 16px; }
.wa-chats { flex: 1; background: #fff; overflow-y: auto; }
.wa-chats .ci { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #eee; cursor: pointer; align-items: center; }
.wa-chats .ci:hover { background: #f7f7f7; }
.wa-chats .av { width: 42px; height: 42px; border-radius: 50%; background: var(--amber-l); color: var(--amber-d); display: grid; place-items: center; font-weight: 800; }
.wa-chats .ci div { flex: 1; min-width: 0; }
.wa-chats .ci b { display: block; font-size: 14px; }
.wa-chats .ci small { color: #777; font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; min-height: 30px; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.quick button:hover { border-color: var(--amber); background: var(--amber-l); }
.phone-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 11px 14px; border-radius: 6px; font-size: 14px; border-left: 4px solid var(--amber); box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; animation: up .25s ease; }
.toast.red { border-left-color: var(--red); }
.toast.green { border-left-color: var(--green); }
.toast b { color: var(--amber); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0,1fr) 400px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .phone-pane { display: none; position: static; }
  .phone-pane.active { display: block; }
  .pane.hidden { display: none; }
  .phone-tab { display: flex; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .clock { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .product { display: none; }
  .qitem { grid-template-columns: 44px 1fr; }
  .qitem .acts { grid-column: 1 / -1; }
  .offers, .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .phone { width: 100%; max-width: 380px; }
}
