:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1d1d1b; --muted: #6b6a64; --line: #e4e2da;
  --brand: #9a7b2f; --brand-soft: #f5efe0; --side: #1f2430; --side-ink: #c9ccd4;
  --ok: #2f7d4f; --ok-soft: #e6f2ea; --warn: #a3620a; --warn-soft: #fbf0dc; --bad: #b42318; --bad-soft: #fdecea;
  --ai: #3b5bdb; --ai-soft: #e8edff; --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 2px; }
.side .brand small { display: block; color: #8a8f9c; font-weight: 400; font-size: 12px; }
.side nav { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: var(--side-ink); padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: #2b3242; text-decoration: none; }
.side nav a.on { background: #343c4f; color: #fff; }
.side .count { background: var(--brand); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; }
.side .me { margin-top: 24px; padding: 10px; font-size: 12px; color: #8a8f9c; border-top: 1px solid #2f3646; }
main { padding: 24px 32px 60px; min-width: 0; }
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.banner.warn { background: var(--warn-soft); border-color: #efd5a6; color: #6b4206; }
.banner.ok { background: var(--ok-soft); border-color: #bfdcc9; color: #1d5233; }
.banner.error { background: var(--bad-soft); border-color: #f2c1bc; color: #7a1a12; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } .side { position: static; height: auto; } .g2 { grid-template-columns: 1fr; } main { padding: 16px; } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 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: 12px; color: var(--muted); font-weight: 500; background: #fbfaf7; }
tr:hover td { background: #fcfbf8; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: #eeede8; color: #4a4943; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.ai { background: var(--ai-soft); color: var(--ai); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=time], input[type=datetime-local], select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid #d6d3c8; border-radius: 8px; background: #fff; width: 100%; color: var(--ink); }
textarea { min-height: 90px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
textarea.prose { font-family: inherit; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #e8d9b0; border-color: var(--brand); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 5px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; padding: 7px 14px; border-radius: 8px;
  border: 1px solid #d6d3c8; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: #f4f2ec; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: #876b27; }
.btn.danger { color: var(--bad); border-color: #f0c4bf; } .btn.ok { color: var(--ok); border-color: #bfdcc9; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.inline { display: inline; }
.switch { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; background: #fcfbf8; }
.switch input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); }
.switch b { display: block; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 20px; background: #fff; color: var(--ink); font-size: 13px; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.settings { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }
.settings .menu { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 16px; }
.settings .menu a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--ink); }
.settings .menu a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
@media (max-width: 900px) { .settings { grid-template-columns: 1fr; } .settings .menu { position: static; } }
.checklist { display: flex; flex-wrap: wrap; gap: 6px; }
.checklist a { font-size: 12px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.checklist a.ok::before { content: "✓ "; color: var(--ok); } .checklist a.no::before { content: "○ "; color: var(--warn); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; }
.bubble.out { align-self: flex-end; background: #eaf6e6; border-color: #cfe7c6; }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; }
pre { background: #faf9f5; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12px; margin: 6px 0; white-space: pre-wrap; }
.matrix td, .matrix th { text-align: center; } .matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input { width: 16px; height: 16px; accent-color: var(--brand); }
.call { border-left: 4px solid var(--brand); }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.auth { max-width: 380px; margin: 10vh auto; }
.auth .card { padding: 26px; }
@media print { .side, .noprint { display: none !important; } main { padding: 0; } .layout { display: block; } body { background: #fff; } .card { border: none; } }

/* ---------------- Orders workspace (list + detail in one window) ---------------- */
.ow-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.ow-head .sub { margin: 0; }
.ow { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: 14px; height: calc(100vh - 130px); min-height: 520px; }
.ow-list, .ow-detail { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; }
.ow-list { display: flex; flex-direction: column; overflow: hidden; }
.ow-filters { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line); }
.ow-filters input[type=search] { font: inherit; padding: 8px 10px; border: 1px solid #d6d3c8; border-radius: 8px; width: 100%; }
.ow-filters .row { flex-wrap: nowrap; } .ow-filters select { padding: 5px 8px; font-size: 13px; }
.ow-chips { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.ow-chips a { flex: none; font-size: 12px; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); color: var(--ink); background: #fff; }
.ow-chips a b { font-weight: 600; color: var(--muted); margin-left: 2px; }
.ow-chips a:hover { text-decoration: none; background: #f4f2ec; }
.ow-chips a.on { background: var(--ink); border-color: var(--ink); color: #fff; } .ow-chips a.on b { color: #d8d6cf; }
.ow-chips a.hot:not(.on) { border-color: #f0c4bf; color: var(--bad); } .ow-chips a.hot:not(.on) b { color: var(--bad); }
.ow-rows { overflow-y: auto; flex: 1; }
.ow-row { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink); border-left: 3px solid transparent; }
.ow-row:hover { background: #fbfaf6; text-decoration: none; }
.ow-row.on { background: var(--brand-soft); border-left-color: var(--brand); }
.ow-r1 { display: flex; align-items: center; gap: 8px; }
.ow-num { font-weight: 600; flex: none; } .ow-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ow-r2 { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 3px; }
.ow-r2 .ow-store { font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.ow-r2 .ow-time { margin-left: auto; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; } .dot.bad { background: var(--bad); }
.ow-pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; }
.ow-detail { overflow-y: auto; transition: opacity .15s; } .ow-detail.loading { opacity: .5; }
.ow-placeholder { height: 100%; display: flex; align-items: center; justify-content: center; }

.op { padding: 18px 20px 24px; }
.op-head { margin-bottom: 12px; }
.op-back { display: none; margin-bottom: 8px; }
.op-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.op-title h2 { margin: 0; font-size: 20px; }
.op-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; margin-top: 4px; align-items: baseline; }
.op-total { margin-left: auto; color: var(--ink); font-size: 18px; font-weight: 600; }
.op-total em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 400; }
.op-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 0 14px; border-bottom: 1px solid var(--line); }
.op-more { position: relative; } .op-more summary { list-style: none; } .op-more summary::-webkit-details-marker { display: none; }
.op-menu { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08); padding: 4px; min-width: 200px; z-index: 5; }
.op-menu button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.op-menu button:hover { background: #f4f2ec; } .op-menu button.danger { color: var(--bad); }
.op-steps { list-style: none; display: flex; margin: 16px 0 10px; padding: 0; counter-reset: s; }
.op-steps li { flex: 1; position: relative; text-align: center; font-size: 12px; color: var(--muted); padding-top: 22px; }
.op-steps li span { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid #d6d3c8; z-index: 1; }
.op-steps li::before { content: ""; position: absolute; top: 10px; left: -50%; width: 100%; height: 2px; background: #e4e2da; }
.op-steps li:first-child::before { display: none; }
.op-steps li.done { color: var(--ink); } .op-steps li.done span { background: var(--ok); border-color: var(--ok); }
.op-steps li.done::before, .op-steps li.now::before { background: var(--ok); }
.op-steps li.now { color: var(--ink); font-weight: 600; } .op-steps li.now span { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.op-steps.issue li.now span { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.op-flag { font-size: 13px; padding: 8px 12px; border-radius: 8px; margin: 6px 0; }
.op-flag.bad { background: var(--bad-soft); color: #7a1a12; } .op-flag.warn { background: var(--warn-soft); color: #6b4206; }
.op-flag.brand { background: var(--brand-soft); color: #6b5520; }
.op-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 14px 0 14px; overflow-x: auto; }
.op-tabs button { all: unset; cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.op-tabs button b { font-weight: 500; font-size: 11px; background: #eeede8; border-radius: 10px; padding: 0 6px; margin-left: 3px; }
.op-tabs button.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.op-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.op-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.op-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; line-height: 1.5; min-width: 0; }
.op-grid .op-box { margin-bottom: 0; }
.op-box h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.op-addr-name { font-weight: 600; }
.op-history { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.op-history b { color: var(--ink); } .op-history .bad b { color: var(--bad); }
.op-items td { border: 0; padding: 6px 4px; } .op-items tr:hover td { background: none; }
.op-items .num { text-align: right; white-space: nowrap; width: 1%; }
.op-items tr.sum td { color: var(--muted); border-top: 1px solid var(--line); }
.op-items tr.total td { color: var(--ink); font-weight: 600; font-size: 15px; }
.op-dl { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.op-dl dt { color: var(--muted); } .op-dl dd { margin: 0; min-width: 0; } .op-dl dd.wrap { word-break: break-all; }
.op-reasons { margin: 0; padding-left: 18px; font-size: 13px; }
.op-line { padding: 4px 0; border-bottom: 1px solid var(--line); }
.op-note { display: flex; gap: 8px; } .op-note input { flex: 1; }
.op-notetext { background: #fffbea; border: 1px solid #f1e3a8; border-radius: 6px; padding: 6px 8px; margin-top: 4px; font-size: 13px; }
.op-chat { max-height: none; background: #efeae2; border-radius: 10px; padding: 12px; min-height: 200px; }
.bubble.failed { border-color: #f2c1bc; background: #fdf3f2; }

@media (max-width: 1250px) { .op-grid { grid-template-columns: 1fr 1fr; } .op-grid > .op-box:first-child { grid-column: 1 / -1; } }
@media (max-width: 1000px) {
  .ow { grid-template-columns: 1fr; height: auto; }
  .ow-list { max-height: none; } .ow-rows { max-height: 70vh; }
  .ow.has-sel .ow-list { display: none; } .ow:not(.has-sel) .ow-detail { display: none; }
  .op-back { display: inline-flex; } .op-grid, .op-grid.two { grid-template-columns: 1fr; }
}

/* Call list tabs */
.call-tabs { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0 14px; padding: 10px 12px; }
.call-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }
.call-compare > div { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fbfaf6; }
.call-compare > div:last-child { background: var(--brand-soft); }
@media (max-width: 700px) { .call-compare { grid-template-columns: 1fr; } }
.op-book { display: inline-flex; gap: 4px; align-items: center; } .op-book select { padding: 4px 6px; font-size: 13px; width: auto; }
tr.row-warn td { background: #fff8ec; }
.ow-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; } .ow-tags .pill { font-size: 10.5px; padding: 1px 7px; }
.bulkbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fbfaf6; }
.bulkbar.active { background: var(--brand-soft); }
.bulkbar:not(.active) button[name], .bulkbar:not(.active) button.ok { opacity: .55; }
.btn.danger-outline { color: var(--bad); border-color: #f0c4bf; }

/* ======================================================================
   Polish layer (v5): navigation, surfaces, tables, scrolling, dashboard
   ====================================================================== */
:root { --bg: #f4f3ee; --side: #141923; --side-ink: #aeb4c2; --shadow: 0 1px 2px rgba(20, 25, 35, .05), 0 1px 1px rgba(20, 25, 35, .03);
  --radius: 12px; font-feature-settings: "cv11", "ss01"; }
body { -webkit-font-smoothing: antialiased; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { letter-spacing: -.005em; }

/* sidebar */
.layout { grid-template-columns: 248px minmax(0, 1fr); }
.side { padding: 16px 12px 12px; display: flex; flex-direction: column; border-right: 1px solid #0d1118; scrollbar-width: thin; scrollbar-color: #2b3242 transparent; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; border-bottom: 1px solid #222938; font-size: 15px; }
.side .brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #c9a24a, #8a6a22); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.side .brand small { font-size: 11px; color: #7d8494; }
.side nav { margin-top: 8px; gap: 1px; flex: 1; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6b7282; padding: 14px 10px 6px; font-weight: 600; }
.side nav a { justify-content: flex-start; gap: 10px; padding: 7px 10px; font-size: 13.5px; transition: background .12s, color .12s; }
.side nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side nav a .lbl { flex: 1; }
.side nav a:hover { background: #1f2533; color: #fff; }
.side nav a.on { background: #262e3f; color: #fff; box-shadow: inset 3px 0 0 #c9a24a; }
.side .count { background: #343c4f; color: #e6e8ee; font-weight: 600; }
.side .count.hot { background: #c9a24a; color: #1b1405; }
.side .me { display: flex; gap: 10px; align-items: center; margin-top: 12px; padding: 12px 8px 4px; border-top: 1px solid #222938; }
.side .me b { color: #e6e8ee; font-weight: 500; } .side .me a { color: #c9a24a; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #2b3242; color: #e6e8ee; display: grid; place-items: center; font-weight: 600; flex: none; }
.topbar { display: none; }
.side-scrim { display: none; }
main { padding: 24px 32px 64px; }

/* surfaces */
.card, .stat { box-shadow: var(--shadow); }
.card.flush { padding: 0; }
.card:has(> table), .card:has(> form > table), .card.flush { overflow-x: auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { margin: 4px 0 0; max-width: 860px; }

/* tables */
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; color: #7a786f; background: #faf9f5; white-space: nowrap; }
td { font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }
.card table th:first-child, .card table td:first-child { padding-left: 16px; }
.card table th:last-child, .card table td:last-child { padding-right: 16px; }

/* buttons */
.btn { transition: background .12s, border-color .12s, box-shadow .12s; }
.btn.primary { box-shadow: 0 1px 0 rgba(0, 0, 0, .08); }
.btn:focus-visible { outline: 2px solid #e8d9b0; outline-offset: 1px; }

/* progress bar */
.bar { height: 6px; background: #eeece5; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }

/* promotions */
.new-promo > summary { list-style: none; cursor: pointer; } .new-promo > summary::-webkit-details-marker { display: none; }
.new-promo[open] > summary { margin-bottom: 14px; }
.promo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.promo-grid section { min-width: 0; } .promo-grid h3 { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.radio { display: inline-flex; gap: 6px; align-items: center; margin: 0 14px 10px 0; } .radio input { width: auto; }
.preview-bubble { background: #d9fdd3; border-radius: 10px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; margin-bottom: 12px; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .k-label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.kpi .k-val { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dash { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.dash .card { margin-bottom: 16px; }
.chart { width: 100%; height: 190px; display: block; overflow: visible; }
.chart .gl { stroke: #ecebe5; stroke-width: 1; } .chart .ax { fill: #8a887f; font-size: 10.5px; font-family: inherit; }
.chart .b { fill: #b8963f; } .chart .b:hover, .chart .b.hl { fill: #8a6a22; }
.chart .hit { fill: transparent; cursor: default; }
.chart-tip { position: absolute; pointer-events: none; background: #141923; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; }
.queue-list a { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.queue-list a:last-child { border-bottom: 0; } .queue-list a:hover { text-decoration: none; color: var(--brand); }
.queue-list b { font-variant-numeric: tabular-nums; font-size: 15px; }
.queue-list .zero b { color: #b5b3ab; font-weight: 500; }
.hbar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; padding: 4px 0; }
.hbar .t { height: 8px; background: #f0eee7; border-radius: 4px; overflow: hidden; } .hbar .t span { display: block; height: 100%; background: #b8963f; border-radius: 4px; }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.agents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.agents div { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 0; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: #c9c7bf; flex: none; } .sdot.ok { background: var(--ok); } .sdot.bad { background: var(--bad); }
.alert-row { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.alert-row:last-child { border-bottom: 0; }

@media (max-width: 1300px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } .promo-grid { grid-template-columns: 1fr; } }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 264px; height: 100vh; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .layout.nav-open .side { transform: none; }
  .layout.nav-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(10, 12, 18, .45); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 10px; margin: -16px -16px 14px; padding: 10px 14px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 20; }
  .menu-btn { background: none; border: 0; padding: 4px; color: #fff; cursor: pointer; } .menu-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2; fill: none; }
  .topbar-title { font-weight: 600; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agents { grid-template-columns: 1fr; }
  main { padding: 16px; }
}
@media print { .side, .topbar { display: none !important; } .layout { display: block; } }
[hidden] { display: none !important; }

/* ---- risk tooltip ---- */
.has-tip { cursor: help; }
.has-tip:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
#tipbox { position: fixed; z-index: 1000; width: 320px; max-width: calc(100vw - 16px); background: #1f1e1b; color: #f3f2ee; border-radius: 10px;
  padding: 10px 12px; font-size: 12px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0,0,0,.25); pointer-events: none; }
#tipbox[hidden] { display: none !important; }
#tipbox .tip-h { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 6px; }
#tipbox .tip-h span, #tipbox .tip-d { color: #b9b7ae; font-size: 11px; }
#tipbox .tip-t { width: 100%; border-collapse: collapse; }
#tipbox .tip-t td { padding: 2px 0; border: 0; color: inherit; vertical-align: top; }
#tipbox .tip-t td.num { text-align: right; font-variant-numeric: tabular-nums; padding-left: 10px; white-space: nowrap; }
#tipbox .tip-t td.neg { color: #8fd6a4; }
#tipbox .tip-sum td { border-top: 1px solid #3a3934; padding-top: 4px; font-weight: 600; }
#tipbox .tip-f { background: #6b2a24; color: #ffd9d4; border-radius: 10px; padding: 0 6px; font-size: 10px; }
#tipbox .tip-l { margin: 0; padding-left: 16px; }
#tipbox .tip-foot { margin-top: 8px; padding-top: 6px; border-top: 1px solid #3a3934; color: #b9b7ae; font-size: 11px; }
/* ---- risk rules page ---- */
.rr-table td, .rr-table th { vertical-align: middle; }
.rr-table input[type=number] { width: 84px; }
.rr-table .rr-help { font-size: 12px; color: var(--muted, #777); }
.rr-table tr.off td:not(:first-child) { opacity: .5; }
.rr-params { display: flex; gap: 8px; flex-wrap: wrap; }
.rr-params label { font-size: 11px; color: var(--muted, #777); display: flex; flex-direction: column; gap: 2px; }
.rr-th { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.rr-th label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.rr-wrap { overflow-x: auto; }
.pill.wa { background: #dcf8e6; color: #11743b; }

/* link inside a panel heading: clearly a link */
a.op-link { margin-left: auto; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--brand);
  text-decoration: underline; text-underline-offset: 2px; padding: 2px 8px; border-radius: 6px; }
a.op-link:hover { background: var(--brand-soft); text-decoration: none; }

/* ---- WhatsApp chats ---- */
.ch-wrap { display: grid; grid-template-columns: 340px 1fr; gap: 16px; height: calc(100vh - 210px); min-height: 480px; }
.ch-list, .ch-main { background: #fff; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ch-search { padding: 10px; border-bottom: 1px solid var(--line); }
.ch-search input { width: 100%; }
.ch-filters { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ch-filters a { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink, inherit); }
.ch-filters a.on { background: var(--ink, #1f1e1b); color: #fff; border-color: transparent; }
.ch-threads { overflow-y: auto; flex: 1; }
.ch-thread { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.ch-thread:hover { background: #faf9f6; }
.ch-thread.on { background: var(--brand-soft); }
.ch-av { flex: 0 0 36px; height: 36px; border-radius: 50%; background: #e8e4da; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #5b5547; }
.ch-av.lg { flex-basis: 42px; height: 42px; }
.ch-tx { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.ch-top { display: flex; justify-content: space-between; gap: 8px; }
.ch-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.ch-ph { font-size: 11.5px; color: var(--muted); }
.ch-prev { font-size: 12.5px; color: #55524b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.ch-tags .pill { font-size: 10.5px; padding: 0 6px; }
.ch-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ch-who { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.ch-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ch-note { background: #fbf3e2; color: #7a5a14; font-size: 12.5px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.ch-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f4f1ea; }
.ch-b { max-width: 72%; padding: 8px 10px; border-radius: 10px; background: #fff; border: 1px solid #e6e1d6; align-self: flex-start; }
.ch-b.out { align-self: flex-end; background: #dcf8e6; border-color: #c4ebd1; }
.ch-b.failed { background: #fdf3f2; border-color: #f2c1bc; }
.ch-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.ch-img { display: block; max-width: 220px; max-height: 220px; border-radius: 8px; margin-bottom: 6px; object-fit: cover; }
.ch-kind { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.ch-meta { display: block; font-size: 10.5px; color: var(--muted); margin-top: 4px; text-align: right; }
.bad-t { color: #b42318; }
.ch-reply { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.ch-reply textarea { flex: 1; resize: vertical; min-height: 42px; }
@media (max-width: 860px) {
  .ch-wrap { grid-template-columns: 1fr; height: auto; }
  .ch-list { max-height: 45vh; }
  .ch-main { min-height: 70vh; }
  .ch-b { max-width: 88%; }
}
.ch-search input, .ch-reply textarea { font: inherit; font-size: 13.5px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: inherit; }
.ch-search input:focus, .ch-reply textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }

/* ---- users admin ---- */
.us-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.us-stat { display: flex; flex-direction: column; min-width: 92px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: inherit; text-decoration: none; }
.us-stat b { font-size: 20px; } .us-stat span { font-size: 12px; color: var(--muted); }
.us-stat.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.us-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.us-filter input[type=search] { flex: 1; min-width: 220px; }
.us-filter select { width: auto; }
.us-card { padding: 0; }
.us-wrap { overflow-x: auto; }
.us-table td { vertical-align: middle; }
.us-table tr.us-off td { opacity: .6; }
.us-who { display: flex; gap: 10px; align-items: center; }
.us-av { flex: 0 0 34px; height: 34px; border-radius: 50%; background: #e8e4da; display: grid; place-items: center; font-weight: 600; color: #5b5547; }
.us-act { white-space: nowrap; text-align: right; }
.us-act form { display: inline; }
.us-roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.us-form-grid { align-items: start; }
.us-filter input[type=search] { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
