/* ══════════════════════════════════════════════════════════════════════════
   Naila — Console / Warm Paper · Top-nav · Deep Emerald (#0d7a5f)
   ══════════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=Spline+Sans+Mono:wght@500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --success: #0f8a5f;
  --bg: #f4f2ec;
  --surface: #ffffff;
  --border: #e6e2d8;
  --accent: #0d7a5f;
  --accent-dark: #0a6450;
  --accent-rgb: 13,122,95;
  --accent2: #c2710c;
  --accent2-rgb: 194,113,12;
  --text: #161513;
  --muted: #5b5750;
  --danger: #c0392b;
  --danger-rgb: 192,57,43;
  --warning: #c2710c;
  --sidebar-bg: rgba(244,242,236,.82);
  --sidebar-border: #e6e2d8;
  --font: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, monospace;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(22,21,19,.04), 0 8px 24px -12px rgba(22,21,19,.12);
  --maxw: 1560px;
  --gutter: clamp(24px, 4vw, 56px);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
.hidden { display: none !important; }

.card-value, .dist-item-count, .pagination, .mono { font-variant-numeric: tabular-nums; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg);
  background-image:
    radial-gradient(ellipse at 22% 30%, rgba(13,122,95,.07) 0%, transparent 58%),
    radial-gradient(ellipse at 80% 75%, rgba(194,113,12,.05) 0%, transparent 55%);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 380px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 1px 2px rgba(22,21,19,.04), 0 30px 60px -24px rgba(22,21,19,.25);
}
.login-box h1 {
  font-size: 30px; font-weight: 700; letter-spacing: -.03em;
  text-align: center; margin-bottom: 4px; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.login-box h1::before {
  content: var(--brand-letter, "N"); width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-dark, #0d7a5f), var(--accent, #13a87f));
  display: grid; place-items: center; color: #fff; font-size: 17px; font-weight: 700;
  box-shadow: 0 3px 10px -2px rgba(var(--accent-rgb, 13,122,95), .5);
}
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.login-logo-text { font-size: 28px; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.login-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(13,122,95,.6); }
.login-subtitle { text-align: center; font-size: 12px; color: var(--muted); letter-spacing: .04em; }

/* ══════════════════════════════════════════════════════════════════════════
   TOP-NAV SHELL — sidebar markup rendered as a horizontal bar
   ══════════════════════════════════════════════════════════════════════════ */
#app { display: flex; flex-direction: column; height: 100vh; }

.sidebar {
  width: 100%; flex-shrink: 0;
  background: var(--sidebar-bg);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px;
  padding: 14px max(var(--gutter), calc((100% - var(--maxw)) / 2)) 0;
  position: sticky; top: 0; z-index: 30; overflow: visible;
}

.logo {
  order: 1;
  font-size: 20px; font-weight: 700; color: var(--text);
  letter-spacing: -.02em; display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; white-space: nowrap;
}
.logo::before {
  content: var(--brand-letter, "N"); width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-dark, #0d7a5f), var(--accent, #13a87f));
  display: grid; place-items: center; color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 14px -3px rgba(var(--accent-rgb, 13,122,95), .6);
}
.logo-text { letter-spacing: -.02em; }
.logo-pulse { display: none; }

nav {
  order: 3; flex-basis: 100%; width: 100%;
  display: flex; align-items: center; gap: 3px;
  flex-wrap: wrap; row-gap: 3px;
  margin-top: 2px; padding-top: 12px; padding-bottom: 10px;
  border-top: 1px solid var(--sidebar-border);
}
nav a {
  text-decoration: none; color: var(--muted);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  padding: 7px 13px; border-radius: 9px;
  transition: background .15s, color .15s, transform .12s;
  display: flex; align-items: center; position: relative;
}
.nav-icon { display: none; }
nav a:hover:not(.active) { background: #ebe7dd; color: var(--text); }
nav a.active {
  background: linear-gradient(135deg, #0d7a5f, #13a87f); color: #fff;
  box-shadow: 0 4px 12px -4px rgba(13,122,95,.6);
}

.sidebar-footer {
  order: 2; margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0; padding: 0; border: none;
}
.sidebar-footer > div { display: flex !important; align-items: center; gap: 8px; width: auto !important; }
.sidebar-footer #user-name { font-size: 13px; color: var(--muted); white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer button {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 9px; padding: 7px 13px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: .15s;
}
.sidebar-footer button:hover { border-color: var(--accent); color: var(--accent); }
#theme-btn { display: inline-flex !important; align-items: center; justify-content: center; }

.sidebar-collapse, .sidebar-expand, .sidebar-overlay { display: none !important; }
.sidebar.collapsed { width: 100% !important; padding: 0 max(var(--gutter), calc((100% - var(--maxw)) / 2)) !important; }

/* ── Main content (centered paper column) ──────────────────────────────── */
#main-content {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--bg);
  padding: 32px max(var(--gutter), calc((100% - var(--maxw)) / 2)) 80px;
}

/* ── Page header ───────────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 26px; flex-wrap: wrap; gap: 16px; }
.page-header h2 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }

/* ── Metric / KPI cards ────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card {
  --k: var(--accent); --krgb: var(--accent-rgb); --vc: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.card::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--k); opacity: .9; }
.card:hover { transform: translateY(-3px); box-shadow: 0 2px 6px rgba(22,21,19,.06), 0 18px 40px -18px rgba(22,21,19,.28); border-color: rgba(var(--krgb), .4); }
.card.t-green   { --k: var(--accent);  --krgb: var(--accent-rgb);  --vc: var(--accent); }
.card.t-red     { --k: var(--danger);  --krgb: var(--danger-rgb);  --vc: var(--danger); }
.card.t-gold    { --k: var(--accent2); --krgb: var(--accent2-rgb); --vc: var(--accent2); }
.card.t-neutral { --k: var(--accent);  --krgb: var(--accent-rgb);  --vc: var(--text); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center; color: var(--k); background: rgba(var(--krgb), .13); }
.card-icon svg { width: 21px; height: 21px; }
.card-value { font-family: var(--mono); font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1; color: var(--vc); }
.card-value.green { color: var(--accent); }
.card-value.red { color: var(--danger); }
.card-value.blue { color: var(--text); }
.card-sub { font-size: 12.5px; color: var(--muted); min-height: 16px; margin-top: -2px; }
.card-sub b { color: var(--text); font-weight: 600; }
.card-bar { height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; }
.card-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--k); }

/* ── Distribution status ───────────────────────────────────────────────── */
.dist-status { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 24px; box-shadow: var(--shadow); }
.dist-status-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 16px; color: var(--accent); }
.dist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.dist-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #e3f3ec; border: 1px solid #cfe9df; border-radius: 11px; }
.dist-item-name { font-size: 13px; font-weight: 500; color: var(--text); }
.dist-item-count { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--accent); }

/* ── Period pills / segmented ──────────────────────────────────────────── */
.period-pills { display: flex; gap: 4px; background: #ebe7dd; border-radius: 11px; padding: 4px; }
.period-pill { padding: 7px 15px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted); background: transparent; border: none; cursor: pointer; transition: .15s; white-space: nowrap; }
.period-pill:hover { color: var(--text); }
.period-pill.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── Filters ───────────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: center; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; box-shadow: var(--shadow); }
.table-wrap[style*="overflow-x"] { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: #faf9f5; padding: 12px 22px; text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:first-child { border-top: none; }
tbody tr:hover { background: #faf9f5; }
tbody td { padding: 13px 22px; }
.mono { font-family: var(--mono); }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 4px 11px; border-radius: 30px; font-size: 12px; font-weight: 600; }
.badge-approved   { background: #e6f4ea; color: #0d7a5f; }
.badge-rejected   { background: #fbeae7; color: #c0392b; }
.badge-pending    { background: #fbf0dd; color: #c2710c; }
.badge-sent       { background: #e3f3ec; color: #0d7a5f; }
.badge-hold       { background: #ece9e1; color: #5b5750; }
.badge-chargeback { background: #fbe2de; color: #b02a1c; }
.badge-declined   { background: #fbeae7; color: #c0392b; }
.badge-queued     { background: #e3f3ec; color: #0d7a5f; }
.badge-new        { background: #e6f4ea; color: #0d7a5f; }
.badge-active\ shave { background: #ece9e1; color: #5b5750; }
.badge-lost\ shave   { background: #fbe2de; color: #b02a1c; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 9px 13px; font-size: 13.5px; font-family: var(--font);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,122,95,.14); }
input::placeholder { color: #9b968d; }

button {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 9px 17px; font-size: 13.5px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background .15s, box-shadow .15s, opacity .15s;
}
button:hover { background: var(--accent-dark); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
button.secondary:hover { border-color: var(--accent); color: var(--accent); }
button.danger { background: var(--danger); }
button.danger:hover { background: #a32f22; }
button.sm { padding: 5px 11px; font-size: 12px; }

.error { color: var(--danger); font-size: 13px; }

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 20px; font-size: 13px; color: var(--muted); }
.pagination button { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.pagination button:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(22,21,19,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 500px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 30px 60px -20px rgba(22,21,19,.35); }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; letter-spacing: -.01em; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row label { font-size: 12px; color: var(--muted); }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Field grid (inline forms outside modals) ──────────────────────────── */
.field-grid { display: grid; gap: 16px 16px; align-items: start; }
.field-grid .fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-grid .fld.col-2 { grid-column: span 2; }
.field-grid .fld > label { font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.3; min-height: 16px; }
.field-grid .fld input, .field-grid .fld select, .field-grid .fld textarea, .field-grid .fld .combo { width: 100%; }

/* ── Chart bars ────────────────────────────────────────────────────────── */
.chart-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.chart-bar-label { width: 120px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { flex: 1; background: #ebe7dd; border-radius: 5px; height: 8px; }
.chart-bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #0d7a5f, #16b78c); }
.chart-bar-count { width: 50px; text-align: right; font-weight: 600; font-family: var(--mono); }

/* ── Misc ──────────────────────────────────────────────────────────────── */
.copy-btn { font-size: 11px; padding: 3px 9px; }
.lead-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.detail-field label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
.detail-field span { font-size: 14px; }

/* ── Tooltips ──────────────────────────────────────────────────────────── */
.tooltip-wrap { position: relative; display: inline-block; cursor: default; }
.tooltip-box { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; font-size: 12px; padding: 8px 12px; border-radius: 10px; white-space: normal; word-break: break-word; max-width: 320px; z-index: 999; box-shadow: 0 8px 24px rgba(22,21,19,.25); pointer-events: none; }
.tooltip-wrap:hover .tooltip-box { display: block; }
.score-hover { position: relative; display: inline-block; }
.score-hover .score-tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; border-radius: 10px; padding: 8px 12px; font-size: 11px; white-space: nowrap; z-index: 1000; box-shadow: 0 8px 24px rgba(22,21,19,.25); pointer-events: none; min-width: 180px; text-align: left; margin-bottom: 6px; }
.score-hover .score-tip::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--text); }
.score-hover:hover .score-tip { display: block; }
.status-tooltip { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; min-width: 220px; box-shadow: 0 12px 30px rgba(22,21,19,.18); }
.status-history-row { display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-size: 12px; border-bottom: 1px solid var(--border); }
.status-history-row:last-child { border-bottom: none; }
.sh-date { color: var(--muted); min-width: 90px; font-size: 11px; }

/* ── Branding preview ──────────────────────────────────────────────────── */
.color-preview { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); flex-shrink: 0; }
.logo-preview { max-height: 60px; max-width: 200px; object-fit: contain; border-radius: 9px; }
.palette-swatch { width: 32px; height: 32px; border-radius: 8px; display: inline-block; border: 1px solid var(--border); }

/* ── Chat / notif (disabled) ───────────────────────────────────────────── */
.chat-btn { display: none !important; }
#notif-bell, #notif-panel { display: none !important; }
.chat-window { position: fixed; bottom: 92px; right: 28px; width: 360px; height: 500px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; z-index: 998; box-shadow: 0 20px 60px rgba(22,21,19,.25); overflow: hidden; }
.chat-header { padding: 14px 18px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: #ebe7dd; color: var(--text); border-bottom-left-radius: 4px; }
.chat-input-row { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input-row input { flex: 1; border-radius: 20px; }
.chat-input-row button { border-radius: 50%; width: 36px; height: 36px; padding: 0; flex-shrink: 0; }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
#main-content::-webkit-scrollbar { width: 9px; }
#main-content::-webkit-scrollbar-track { background: transparent; }
#main-content::-webkit-scrollbar-thumb { background: #d8d3c6; border-radius: 5px; }
#main-content::-webkit-scrollbar-thumb:hover { background: #c4bfb0; }

/* ══════════════════════════════════════════════════════════════════════════
   DARK VARIANT — warm console (emerald on deep green-charcoal)
   Recolours the hardcoded light literals; vars come from applyBranding.
   ══════════════════════════════════════════════════════════════════════════ */
:root:not(.light) thead th { background: #131a17; }
:root:not(.light) tbody tr:hover { background: rgba(255,255,255,.03); }
:root:not(.light) .dist-item { background: rgba(var(--accent-rgb,16,185,129),.1); border-color: rgba(var(--accent-rgb,16,185,129),.24); }
:root:not(.light) .period-pills { background: #1b2420; }
:root:not(.light) .period-pill.active { background: #28332c; color: var(--text); box-shadow: none; }
:root:not(.light) .chart-bar-track { background: #1f2a25; }
:root:not(.light) .chat-msg.bot { background: #1f2a25; color: var(--text); }
:root:not(.light) input::placeholder { color: #6f786f; }
:root:not(.light) #main-content::-webkit-scrollbar-thumb { background: #2c3a32; }
:root:not(.light) #main-content::-webkit-scrollbar-thumb:hover { background: #3a4a40; }
:root:not(.light) .badge-approved, :root:not(.light) .badge-sent, :root:not(.light) .badge-queued, :root:not(.light) .badge-new { background: rgba(16,185,129,.14); color: #34d8a3; }
:root:not(.light) .badge-rejected, :root:not(.light) .badge-declined { background: rgba(192,57,43,.16); color: #f08a7e; }
:root:not(.light) .badge-pending { background: rgba(194,113,12,.16); color: #e3a951; }
:root:not(.light) .badge-hold, :root:not(.light) .badge-chargeback { background: rgba(255,255,255,.06); color: var(--muted); }

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { gap: 14px; padding: 0 14px; }
  .sidebar-footer #user-name { display: none; }
  #main-content { padding: 20px 14px 40px; }
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; overflow: visible; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header h2 { font-size: 22px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px 16px; }
  .card-value { font-size: 24px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .filters input, .filters button { width: 100%; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; min-width: 640px; }
  thead th { padding: 10px 12px; font-size: 10px; }
  tbody td { padding: 10px 12px; }
  .modal { width: 95vw; max-height: 85vh; padding: 16px; }
  .modal h3 { font-size: 16px; margin-bottom: 14px; }
  .lead-detail-grid { grid-template-columns: 1fr; gap: 10px; }
  .login-box { width: 90vw; max-width: 380px; padding: 24px; }
  .dist-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .dist-grid { grid-template-columns: 1fr; }
  table { min-width: 560px; }
}

/* ── Reconciliation (сверка) — theme-inherited via vars ───────────────────── */
.recon-controls { display: flex; gap: 8px; align-items: center; }
.recon-period-label { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.recon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .recon-grid { grid-template-columns: 1fr; } }
.recon-col-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.recon-col-count { background: rgba(var(--accent-rgb, 99,102,241), .14); color: var(--accent); border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.recon-empty, .recon-loading { color: var(--muted); font-size: 13px; padding: 18px 0; }
.recon-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 12px); padding: 16px 18px; margin-bottom: 14px; }
.recon-card.is-paid { opacity: .72; }
.recon-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.recon-party-name { font-weight: 700; font-size: 15px; color: var(--text); }
.recon-party-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.recon-amount { text-align: right; flex-shrink: 0; }
.recon-amount-val { font-weight: 700; font-size: 18px; color: var(--accent); }
.recon-status { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; margin-top: 2px; }
.recon-status.paid { color: #15a06b; }
.recon-status.unpaid { color: var(--warning, #d9881f); }
.recon-section { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.recon-section-h { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.recon-li { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; color: var(--text); }
.recon-geos { font-size: 13px; color: var(--text); }
.recon-inv-email { font-size: 12px; color: var(--muted); font-family: var(--mono, ui-monospace, monospace); }
.recon-pay { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.recon-hash-input { flex: 1; min-width: 160px; padding: 7px 11px; font-size: 12px; }
.recon-hash { font-size: 12px; color: var(--muted); flex: 1; }
.recon-hash code { color: var(--text); }

/* fix(country-picker): checkbox/radio inside .form-row must not inherit width:100% */
.form-row input[type="checkbox"], .form-row input[type="radio"] { width: auto; flex: 0 0 auto; padding: 0; margin: 0; }

/* ── Searchable combobox (filters) ─────────────────────────────────── */
.combo { position: relative; display: inline-block; vertical-align: middle; }
.combo-input {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px;
  min-width: 160px; width: 100%; box-sizing: border-box; cursor: text;
  transition: border-color .15s, box-shadow .15s;
}
.combo-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.12); }
.combo.open .combo-input { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.12); }
.combo-list {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 100%;
  max-height: 300px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(22,21,19,.06), 0 20px 48px -16px rgba(22,21,19,.4);
  z-index: 60; display: none; padding: 5px;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.combo-opt {
  padding: 8px 11px; font-size: 13px; color: var(--text);
  cursor: pointer; white-space: nowrap; border-radius: 8px;
}
.combo-opt:hover, .combo-opt.active { background: var(--accent); color: #fff; }
.combo-opt.selected { font-weight: 600; background: rgba(var(--accent-rgb),.1); color: var(--accent); }
.combo-opt.selected:hover, .combo-opt.selected.active { background: var(--accent); color: #fff; }
.combo-empty { padding: 8px 11px; font-size: 12px; color: var(--muted); }

/* ── Multi-select combo (Include/Exclude) ──────────────────────────── */
.combo.multi .combo-list { max-height: none; overflow: visible; }
.combo-mode { display: flex; gap: 4px; align-items: center; padding: 2px 2px 6px; }
.combo-mode-btn {
  padding: 3px 11px; font-size: 11px; font-weight: 600; border-radius: 7px;
  cursor: pointer; background: var(--card); border: 1px solid var(--border); color: var(--muted);
}
.combo-mode-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.combo-clear { margin-left: auto; font-size: 11px; color: var(--muted); cursor: pointer; text-decoration: underline; }
.combo-clear:hover { color: var(--danger); }
.combo-search {
  width: 100%; box-sizing: border-box; margin-bottom: 5px;
  padding: 6px 10px; font-size: 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.combo-search:focus { outline: none; border-color: var(--accent); }
.combo-body { max-height: 220px; overflow-y: auto; }

/* ── Period selector + custom date range ───────────────────────────── */
.period-wrap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period-date { padding: 8px 11px; font-size: 13px; min-width: 150px; }
.page-header select#period-filter, #fin-period, #ss-period, .recon-sel { font-weight: 500; cursor: pointer; }
.page-header .sub { color: var(--muted); font-size: 13px; margin-top: 4px; font-weight: 400; }

/* ── Panels (titled table/section cards) ───────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 22px; border-bottom: 1px solid var(--border); }
.panel-title { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; color: var(--text); }
.panel-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .14); }
.panel-title .pi { color: var(--accent); display: inline-flex; }
.panel-title .pi svg { width: 17px; height: 17px; }
.panel-count { font-size: 12px; font-weight: 600; color: var(--accent); background: rgba(var(--accent-rgb), .1); padding: 2px 10px; border-radius: 20px; white-space: nowrap; }
.panel-body { padding: 18px 22px; }
.panel > table { width: 100%; }
.panel-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.panel-scroll > table { width: 100%; min-width: max-content; }
.panel-scroll > table th, .panel-scroll > table td { white-space: nowrap; }

/* ── Empty state ───────────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 20px; color: var(--muted); text-align: center; }
.empty-state svg { width: 30px; height: 30px; opacity: .4; }
.empty-state span { font-size: 13px; }
td .empty-state { padding: 26px 20px; }

/* ── Inline CR / progress bar (table cells) ────────────────────────── */
.crbar { display: flex; align-items: center; gap: 8px; }
.crbar .b { flex: 1; min-width: 48px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.crbar .b > span { display: block; height: 100%; border-radius: 3px; }
.crbar .p { font-size: 11px; font-weight: 700; width: 32px; text-align: right; }

:root:not(.light) .crbar .b, :root:not(.light) .card-bar { background: #1f2a25; }
:root:not(.light) .empty-state svg { opacity: .5; }

/* rotation edit modal */
.modal .re-sub { font-size: 12.5px; color: var(--muted); margin: -4px 0 14px; }
.modal .re-days { display: flex; flex-wrap: wrap; gap: 6px; }
.modal .re-day { background: var(--bg); border: 1px solid var(--border); color: var(--muted); border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: 12px; user-select: none; }
.modal .re-day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal .re-chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.modal .re-chk input { width: auto; }
.modal .b-profit { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.modal .b-profit.pos { color: var(--accent); }
.modal .b-profit.zero { color: var(--muted); }
.modal .b-profit.neg { color: var(--danger); }
.modal .acc { color: var(--accent); font-weight: 600; }

/* ── Zenvior lead-view card (ported from legacy crm2) ── */
.lead-detail-page { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
.lead-detail-main { min-width: 0; }
.lead-back { margin-bottom: 16px; }
.lead-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.lead-header-left { display: flex; flex-direction: column; gap: 4px; }
.lead-header-name-row { display: flex; align-items: center; gap: 12px; }
.lead-header-name-row h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.lead-id-badge { font-family: var(--mono); font-size: 12px; color: var(--accent); background: rgba(124,92,255,.14); border: 1px solid rgba(124,92,255,.3); padding: 2px 9px; border-radius: 20px; }
.icon-btn { background: transparent; border: none; color: var(--muted); padding: 4px; border-radius: 7px; cursor: pointer; display: inline-flex; box-shadow: none; }
.icon-btn:hover { color: var(--accent); background: var(--soft); box-shadow: none; }
.promote-link { font-size: 12.5px; color: var(--accent2); cursor: pointer; }
.promote-link:hover { text-decoration: underline; }
.add-link { font-size: 12.5px; color: var(--accent); cursor: pointer; display: inline-block; margin: 2px 0 10px; }
.lead-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.action-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 8px 13px; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; box-shadow: none; }
.action-btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: none; filter: none; }

.lead-stats-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.lead-stat { display: flex; flex-direction: column; gap: 3px; }
.lead-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lead-stat-value { font-family: var(--mono); font-size: 16px; font-weight: 600; color: var(--text); }
.lead-stat-date { margin-left: auto; font-size: 12px; color: var(--muted); }

.lead-tabs { border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.lead-tabs-scroll { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.lead-tabs-scroll::-webkit-scrollbar { display: none; }
.lead-tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; border-radius: 0; box-shadow: none; }
.lead-tab:hover { color: var(--text); box-shadow: none; filter: none; }
.lead-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.lead-tab-content { min-height: 200px; }

.lead-personal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 15px; font-weight: 600; }
.card > .card-header + .card-body-form, .card-body-form { padding: 18px 20px; }
.card-body-form .form-group, .card-body-form .form-row { margin-bottom: 14px; }
.input-with-toggle, .input-with-copy { display: flex; align-items: center; gap: 6px; }
.input-with-toggle input, .input-with-copy input { flex: 1; }
.toggle-btn { background: var(--surface); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 7px; cursor: pointer; display: inline-flex; box-shadow: none; }
.toggle-btn:hover { color: var(--accent); box-shadow: none; filter: none; }
.input-prefix { font-size: 16px; }

.lead-tab-content .card { padding: 0; }
.lead-tab-content .card .table-wrapper { border: none; box-shadow: none; border-radius: 0; }
.order-type { font-weight: 700; font-size: 12px; }
.order-buy { color: var(--accent2); }
.order-sell { color: var(--danger); }
.activity-timeline { padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.activity-item { display: flex; gap: 12px; padding: 8px 0; }
.activity-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; box-shadow: 0 0 8px rgba(124,92,255,.7); }
.activity-content { flex: 1; }
.activity-header { display: flex; justify-content: space-between; gap: 10px; }
.activity-action { font-weight: 600; font-size: 13px; }
.activity-date { font-size: 11px; color: var(--muted); }
.activity-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.settings-grid { padding: 18px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.setting-row { display: flex; flex-direction: column; gap: 5px; }
.setting-row label { font-size: 12px; color: var(--muted); }

/* ── Right comments sidebar ────────────────────────────────────────────── */
.lead-sidebar { position: sticky; top: 22px; }
.lead-sidebar-inner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.lead-sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--muted); }
.lead-sidebar-header-actions { display: flex; gap: 4px; }
.lead-sidebar-tabs { display: flex; gap: 2px; padding: 8px 12px 0; overflow-x: auto; scrollbar-width: none; }
.lead-sidebar-tabs::-webkit-scrollbar { display: none; }
.sidebar-tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 10px; font-size: 12.5px; font-weight: 500; white-space: nowrap; cursor: pointer; box-shadow: none; border-radius: 0; }
.sidebar-tab:hover { color: var(--text); box-shadow: none; filter: none; }
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.lead-sidebar-content { padding: 16px 18px; }
.comments-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; max-height: 360px; overflow-y: auto; }
.comment-item { display: flex; gap: 10px; }
.comment-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; justify-content: space-between; gap: 8px; }
.comment-author { font-size: 13px; font-weight: 600; }
.comment-date { font-size: 11px; color: var(--muted); }
.comment-text { font-size: 13px; color: var(--text); margin-top: 2px; word-break: break-word; }
.comment-actions { margin-top: 3px; }
.comment-action { font-size: 11px; color: var(--danger); cursor: pointer; }
.comment-input { display: flex; flex-direction: column; gap: 8px; }
.comment-input textarea { width: 100%; min-height: 64px; resize: vertical; }
.sidebar-form { display: flex; flex-direction: column; gap: 10px; }
.lead-status-pill { display:inline-flex; align-items:center; padding:3px 12px; border-radius:999px; font-size:11px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; background:rgba(124,92,255,.14); color:var(--accent); border:1px solid rgba(124,92,255,.32); }
.lead-stat-edit { display:flex; align-items:center; gap:4px; font-size:13px; color:var(--muted); }
.lead-stat-edit input { width:92px; font-size:15px; font-weight:700; color:var(--text); padding:4px 8px; }
.zstats-save { align-self:center; }
.ztbl-actions { padding:12px 20px; border-top:1px solid var(--border); }
.table-wrapper td input { width:100%; min-width:78px; padding:5px 8px; font-size:12.5px; }
.zrow-del { background:transparent; color:var(--danger); border:1px solid var(--border); padding:2px 9px; }

@media (max-width: 860px) {
  .lead-detail-page { grid-template-columns: 1fr; }
  .lead-sidebar { position: static; }
  .lead-detail-grid, .lead-personal-grid, .settings-grid { grid-template-columns: 1fr; gap: 10px; }
}
