/* ══════════════════════════════════════════════════════════════════════════
   El Chapo — "Oro Negro · Art Déco" · Left rail · Gold-on-black luxe · dual-theme (dark default)
   Display: Cormorant Garamond · Body: Manrope · Mono: IBM Plex Mono
   ══════════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Yeseva+One&family=Cormorant+Garamond:ital,wght@0,600;0,700;1,600&family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@500;600&display=swap');

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

:root {
  /* DARK (default) — warm near-black + gold */
  --bg: #0b0a0c;
  --surface: #161319;
  --surface-2: #1e1a22;
  --border: #2b2620;
  --accent: #d4af37;
  --accent-dark: #b8932b;
  --accent-rgb: 212,175,55;
  --accent2: #8a6d1f;
  --text: #ece4d2;
  --muted: #908975;
  --danger: #d9544e;
  --warning: #d99a3c;
  --sidebar-bg: #0f0d0b;
  --sidebar-border: #272219;
  --gold-grad: linear-gradient(135deg, #f6e08c 0%, #e7c451 26%, #d4af37 52%, #a9821f 100%);
  --gold-soft: linear-gradient(135deg, rgba(246,224,140,.18), rgba(212,175,55,.05));
  --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display: 'Yeseva One', 'Cormorant Garamond', 'Times New Roman', serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 20px 44px -24px rgba(0,0,0,.82);
  --hairline: rgba(212,175,55,.22);
  /* ── Mexican folk-art ornaments (gold on transparent) ───────────────────── */
  --talavera: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='76' height='76' viewBox='0 0 76 76'%3E%3Cg fill='none' stroke='%23d4af37' stroke-width='1'%3E%3Cpath d='M38 7l6 23 23 6-23 6-6 23-6-23-23-6 23-6z'/%3E%3Ccircle cx='38' cy='38' r='14'/%3E%3Cpath d='M38 24v28M24 38h28' stroke-opacity='.6'/%3E%3Ccircle cx='38' cy='38' r='4.5' fill='%23d4af37' stroke='none'/%3E%3Ccircle cx='38' cy='3' r='2'/%3E%3Ccircle cx='38' cy='73' r='2'/%3E%3Ccircle cx='3' cy='38' r='2'/%3E%3Ccircle cx='73' cy='38' r='2'/%3E%3C/g%3E%3C/svg%3E");
  --papel: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='26' viewBox='0 0 30 26'%3E%3Cpath fill='%23d4af37' fill-rule='evenodd' d='M1 0h28v13L15 23 1 13z M20 8a5 5 0 1 0-10 0 5 5 0 1 0 10 0z M9 5.6a1.7 1.7 0 1 0-3.4 0 1.7 1.7 0 1 0 3.4 0z M24.4 5.6a1.7 1.7 0 1 0-3.4 0 1.7 1.7 0 1 0 3.4 0z M16.5 14.5a1.5 1.5 0 1 0-3 0 1.5 1.5 0 1 0 3 0z'/%3E%3C/svg%3E");
  --rosette: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cg fill='none' stroke='%23d4af37' stroke-width='1.2'%3E%3Cpath d='M15 3l3.2 8.8L27 15l-8.8 3.2L15 27l-3.2-8.8L3 15l8.8-3.2z'/%3E%3Ccircle cx='15' cy='15' r='2.4' fill='%23d4af37'/%3E%3C/g%3E%3C/svg%3E");
  --otomi: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='14' viewBox='0 0 48 14'%3E%3Cg fill='none' stroke='%23d4af37' stroke-width='1'%3E%3Cpath d='M0 7h12M36 7h12'/%3E%3Cpath d='M24 1l5 6-5 6-5-6z'/%3E%3Ccircle cx='14.5' cy='7' r='1.5' fill='%23d4af37'/%3E%3Ccircle cx='33.5' cy='7' r='1.5' fill='%23d4af37'/%3E%3C/g%3E%3C/svg%3E");
}

:root.light {
  --bg: #f3ecdb;
  --surface: #fffdf7;
  --surface-2: #f3ecdb;
  --border: #e6dcc5;
  --accent-dark: #9a7a1c;
  --text: #1b1712;
  --muted: #6c6555;
  --sidebar-bg: #fbf7ed;
  --sidebar-border: #e8dfca;
  --shadow: 0 1px 2px rgba(27,23,18,.04), 0 18px 40px -24px rgba(27,23,18,.24);
  --hairline: rgba(154,122,28,.28);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
:root.light body { color: var(--text); }
.hidden { display: none !important; }
.card-value, .dist-item-count, .pagination, .mono { font-variant-numeric: tabular-nums; }

/* Art-déco kicker label helper (purely decorative, used via display font) */
.eyebrow { font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: var(--accent); font-weight: 700; }

/* ══════════════════════════════════════════════════════════════════════════
   LOGIN — déco frame, sunburst, monogram emblem
   ══════════════════════════════════════════════════════════════════════════ */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg); position: relative; overflow: hidden;
  background-image:
    radial-gradient(ellipse 60% 50% at 50% -8%, rgba(212,175,55,.16) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 50% 108%, rgba(212,175,55,.07) 0%, transparent 60%);
}
/* radiant déco sunburst behind the card */
.login-screen::before {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 150vmax; height: 150vmax; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    rgba(212,175,55,.045) 0deg 1.6deg, transparent 1.6deg 9deg);
  -webkit-mask-image: radial-gradient(circle at center, #000 0%, transparent 46%);
  mask-image: radial-gradient(circle at center, #000 0%, transparent 46%);
  pointer-events: none; opacity: .7;
}
/* talavera tile field */
.login-screen::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .07;
  background: var(--talavera) repeat; background-size: 76px 76px;
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, transparent 28%, #000 72%);
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, transparent 28%, #000 72%);
}
.login-box {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 88%, #000));
  border: 1px solid rgba(212,175,55,.45);
  border-radius: 16px;
  padding: 60px 44px 40px;
  width: 392px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.5), 0 50px 100px -34px rgba(0,0,0,.92), 0 0 60px -30px rgba(212,175,55,.4),
    inset 0 0 0 7px var(--surface), inset 0 0 0 8px var(--hairline);
}
/* papel picado garland hanging from the top edge */
.login-box::before {
  content: ""; position: absolute; left: 16px; right: 16px; top: 16px; height: 26px;
  border-top: 1px solid rgba(212,175,55,.6);
  background: var(--papel) repeat-x left top; background-size: 30px 26px;
  pointer-events: none;
}
/* talavera rosettes in the four corners */
.login-box::after {
  content: ""; position: absolute; inset: 13px; pointer-events: none;
  background:
    var(--rosette) left top no-repeat,
    var(--rosette) right top no-repeat,
    var(--rosette) left bottom no-repeat,
    var(--rosette) right bottom no-repeat;
  background-size: 22px 22px;
  opacity: .8;
}
.login-box h1 {
  position: relative;
  font-family: var(--display);
  font-size: 40px; font-weight: 400; letter-spacing: .01em;
  text-align: center; margin: 6px 0 12px; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
/* loteria-style gold medallion with dashed ring */
.login-box h1::before {
  content: "C"; width: 60px; height: 60px; border-radius: 50%;
  background: var(--gold-grad);
  display: grid; place-items: center; color: #1a1407;
  font-family: var(--display); font-size: 32px; font-weight: 400;
  box-shadow:
    0 6px 22px -4px rgba(212,175,55,.65), inset 0 2px 0 rgba(255,255,255,.55), inset 0 -3px 8px rgba(120,90,0,.45);
  outline: 2px dashed rgba(212,175,55,.65); outline-offset: 5px;
}
/* déco diamond divider under the title */
.login-box h1::after {
  content: ""; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  width: 150px; height: 14px;
  background: var(--otomi) center/auto 14px repeat-x;
  opacity: .85;
}
.login-box input { height: 44px; }
.login-box button { height: 46px; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.login-logo-text { font-family: var(--display); font-size: 30px; font-weight: 700; color: var(--text); }
.login-pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px rgba(212,175,55,.7); }
.login-subtitle { text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .26em; text-transform: uppercase; margin-top: -4px; }

/* ══════════════════════════════════════════════════════════════════════════
   LEFT RAIL SHELL — vertical sidebar
   ══════════════════════════════════════════════════════════════════════════ */
#app { display: flex; flex-direction: row; height: 100vh; }

.sidebar {
  width: 244px; height: 100vh; flex-shrink: 0;
  background: var(--sidebar-bg);
  background-image: linear-gradient(180deg, rgba(212,175,55,.06), transparent 280px);
  border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column;
  padding: 26px 14px 18px;
  position: sticky; top: 0; z-index: 30;
}
/* talavera tile wash behind the rail */
.sidebar::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .05;
  background: var(--talavera) repeat; background-size: 76px 76px;
}
.sidebar > * { position: relative; z-index: 1; }
/* luminous right edge */
.sidebar::after {
  content: ""; position: absolute; top: 0; right: -1px; bottom: 0; width: 1px; z-index: 2;
  background: linear-gradient(180deg, transparent, rgba(212,175,55,.55) 16%, rgba(212,175,55,.55) 84%, transparent);
  pointer-events: none;
}

.logo {
  position: relative;
  font-family: var(--display);
  font-size: 25px; font-weight: 400; color: var(--text);
  letter-spacing: .01em; display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; white-space: nowrap; padding: 0 8px 22px;
  margin-bottom: 12px; border-bottom: 1px solid var(--sidebar-border);
}
/* loteria medallion emblem */
.logo::before {
  content: "C"; width: 40px; height: 40px; border-radius: 50%;
  background: var(--gold-grad);
  display: grid; place-items: center; color: #1a1407;
  font-family: var(--display); font-size: 23px; font-weight: 400;
  box-shadow: 0 4px 12px -2px rgba(212,175,55,.55), inset 0 1px 0 rgba(255,255,255,.5), inset 0 -2px 5px rgba(120,90,0,.4);
  outline: 1.5px dashed rgba(212,175,55,.6); outline-offset: 3px; flex-shrink: 0;
}
/* papel picado garland strung under the logo */
.logo::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 16px;
  background: var(--papel) repeat-x left top; background-size: 22px 19px;
  opacity: .9; pointer-events: none;
}
.logo-text { letter-spacing: .01em; }
.logo-pulse { display: none; }

nav {
  display: flex; flex-direction: column; align-items: stretch; gap: 2px; flex: 1;
  overflow-y: auto; overflow-x: hidden; padding: 8px 0;
  scrollbar-width: none; -ms-overflow-style: none;
}
nav::-webkit-scrollbar { display: none; }
nav a {
  position: relative;
  text-decoration: none; color: var(--muted);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  padding: 9px 14px; border-radius: 8px; border-left: 3px solid transparent;
  transition: background .16s, color .16s, box-shadow .16s; display: flex; align-items: center;
}
.nav-icon { display: none; }
nav a:hover:not(.active) { background: rgba(var(--accent-rgb),.07); color: var(--text); }
nav a.active {
  background: linear-gradient(90deg, rgba(var(--accent-rgb),.18), rgba(var(--accent-rgb),.02)) !important;
  color: var(--accent) !important; font-weight: 600;
  border-left: 3px solid var(--accent) !important; border-radius: 0 8px 8px 0 !important;
  box-shadow: inset 0 0 0 1px rgba(212,175,55,.12), 0 0 20px -8px rgba(212,175,55,.5);
}
/* small gilt dot marker on the active row */
nav a.active::after {
  content: ""; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px rgba(212,175,55,.9);
}

.sidebar-footer {
  position: relative;
  display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  flex-shrink: 0; padding-top: 16px; border-top: 1px solid var(--sidebar-border);
}
.sidebar-footer::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,175,55,.5), transparent);
}
.sidebar-footer > div { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; width: 100% !important; }
.sidebar-footer #user-name { font-size: 13px; color: var(--muted); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer button {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 9px 13px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .15s;
}
.sidebar-footer > button { width: 100%; }
.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; }

/* ── Main content ──────────────────────────────────────────────────────── */
#main-content {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 100% 0%, rgba(212,175,55,.06), transparent 26%),
    radial-gradient(circle at 0% 100%, rgba(212,175,55,.035), transparent 30%);
  background-attachment: local;
  padding: 36px max(36px, calc((100% - 1180px) / 2)) 80px;
}

/* ── Page header — déco rule + diamond ─────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; flex-wrap: wrap; gap: 16px; }
.page-header h2 { font-family: var(--display); font-size: 38px; font-weight: 400; letter-spacing: .01em; position: relative; padding-bottom: 14px; }
.page-header h2::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 150px; height: 14px;
  background: var(--otomi) left center/auto 14px repeat-x;
  -webkit-mask-image: linear-gradient(90deg, #000 60%, transparent);
  mask-image: linear-gradient(90deg, #000 60%, transparent);
}

/* ── Metric cards — corner gilding ─────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
  position: relative; overflow: hidden; transition: transform .16s, box-shadow .16s, border-color .16s;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: linear-gradient(180deg, var(--accent), transparent); opacity: .6; }
.card::after { content: ""; position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; pointer-events: none;
  background: var(--rosette) center/26px 26px no-repeat; opacity: .32;
}
.card:hover { transform: translateY(-2px); border-color: rgba(var(--accent-rgb),.45); box-shadow: 0 2px 4px rgba(0,0,0,.4), 0 24px 50px -22px rgba(var(--accent-rgb),.34); }
.card-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .16em; margin-bottom: 14px; }
.card-value { font-family: var(--mono); font-size: 31px; font-weight: 600; letter-spacing: -.02em; }
.card-value.green { color: var(--accent); }
.card-value.red { color: var(--danger); }
.card-value.blue { color: var(--text); }

/* ── 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); position: relative; overflow: hidden; }
.dist-status::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--gold-grad); opacity: .6; }
.dist-status-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .18em; 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: rgba(var(--accent-rgb),.08); border: 1px solid rgba(var(--accent-rgb),.22); border-radius: 9px; }
.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: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.period-pill { padding: 7px 15px; border-radius: 7px; font-size: 13px; font-weight: 600; 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(--gold-grad); color: #1a1407; box-shadow: 0 2px 8px -2px rgba(212,175,55,.5); }

/* ── 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: hidden; box-shadow: var(--shadow); }
.table-wrap[style*="overflow-x"] { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: var(--surface-2); padding: 13px 22px; text-align: left; font-weight: 700; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; border-bottom: 1px solid var(--accent); box-shadow: inset 0 -1px 0 rgba(212,175,55,.25); }
tbody tr { border-top: 1px solid var(--border); transition: background .12s; }
tbody tr:first-child { border-top: none; }
tbody tr:hover { background: rgba(var(--accent-rgb),.06); }
tbody td { padding: 13px 22px; }
.mono { font-family: var(--mono); }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 4px 11px; border-radius: 7px; font-size: 12px; font-weight: 600; letter-spacing: .02em; border: 1px solid transparent; }
.badge-approved   { background: rgba(212,175,55,.16); color: var(--accent); border-color: rgba(212,175,55,.3); }
.badge-rejected   { background: rgba(217,84,78,.16); color: #e8857f; border-color: rgba(217,84,78,.3); }
.badge-pending    { background: rgba(217,154,60,.16); color: var(--warning); border-color: rgba(217,154,60,.3); }
.badge-sent       { background: rgba(212,175,55,.13); color: var(--accent); }
.badge-hold       { background: rgba(255,255,255,.06); color: var(--muted); }
.badge-chargeback { background: rgba(217,84,78,.16); color: #e8857f; }
.badge-declined   { background: rgba(217,84,78,.16); color: #e8857f; }
.badge-queued     { background: rgba(212,175,55,.13); color: var(--accent); }
.badge-new        { background: rgba(212,175,55,.16); color: var(--accent); border-color: rgba(212,175,55,.3); }
.badge-active\ shave { background: rgba(255,255,255,.06); color: var(--muted); }
.badge-lost\ shave   { background: rgba(217,84,78,.16); color: #e8857f; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  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(var(--accent-rgb),.16); }
input::placeholder { color: var(--muted); opacity: .7; }

button {
  background: var(--gold-grad); color: #1a1407; border: none; border-radius: 8px;
  padding: 9px 17px; font-size: 13.5px; font-weight: 700; font-family: var(--font);
  cursor: pointer; transition: filter .15s, box-shadow .15s, opacity .15s, transform .1s;
  box-shadow: 0 2px 10px -3px rgba(212,175,55,.5), inset 0 1px 0 rgba(255,255,255,.35);
}
button:hover { filter: brightness(1.08); box-shadow: 0 4px 16px -3px rgba(212,175,55,.6), inset 0 1px 0 rgba(255,255,255,.4); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; filter: none; }
button.secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: none; }
button.secondary:hover { border-color: var(--accent); color: var(--accent); filter: none; }
button.danger { background: var(--danger); color: #fff; box-shadow: none; }
button.danger:hover { background: #b8443e; filter: none; }
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); box-shadow: none; }
.pagination button:hover { border-color: var(--accent); color: var(--accent); filter: none; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.66); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px); }
.modal { position: relative; background: var(--surface); border: 1px solid rgba(212,175,55,.35); border-radius: var(--radius); padding: 30px 28px; width: 500px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 50px 100px -28px rgba(0,0,0,.85); }
.modal::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--gold-grad); border-radius: var(--radius) var(--radius) 0 0; }
.modal h3 { font-family: var(--display); font-size: 25px; font-weight: 400; 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; }

/* ── 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: var(--surface-2); border-radius: 5px; height: 8px; }
.chart-bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #9c7c1f, var(--accent)); }
.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(--surface-2); color: var(--text); border: 1px solid var(--border); font-size: 12px; padding: 8px 12px; border-radius: 9px; white-space: normal; word-break: break-word; max-width: 320px; z-index: 999; box-shadow: 0 8px 24px rgba(0,0,0,.5); 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(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; font-size: 11px; white-space: nowrap; z-index: 1000; box-shadow: 0 8px 24px rgba(0,0,0,.5); 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(--surface-2); }
.score-hover:hover .score-tip { display: block; }
.status-tooltip { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-width: 220px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.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: 8px; border: 1px solid var(--border); flex-shrink: 0; }
.logo-preview { max-height: 60px; max-width: 200px; object-fit: contain; border-radius: 8px; }
.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: 28px; right: 28px; width: 360px; height: 500px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; z-index: 998; box-shadow: 0 20px 60px rgba(0,0,0,.6); overflow: hidden; }
.chat-header { padding: 14px 18px; background: var(--accent); color: #1a1407; 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: #1a1407; border-bottom-right-radius: 4px; }
.chat-msg.bot { align-self: flex-start; background: var(--surface-2); 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: var(--border); border-radius: 5px; }
#main-content::-webkit-scrollbar-thumb:hover { background: rgba(var(--accent-rgb),.4); }

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE — rail collapses to a top bar
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .sidebar::after { display: none; }
  .logo { padding: 0 12px 0 0; margin: 0; border-bottom: none; border-right: 1px solid var(--sidebar-border); }
  .logo::after { display: none; }
  nav { flex-direction: row; overflow-x: auto; gap: 4px; padding: 0; }
  nav a { border-left: none !important; border-radius: 8px !important; }
  nav a.active { border-radius: 8px !important; }
  nav a.active::after { display: none; }
  .sidebar-footer { flex-direction: row; border-top: none; padding-top: 0; margin-left: auto; }
  .sidebar-footer::before { display: none; }
  .sidebar-footer > button { width: auto; }
  .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: 28px; }
  .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: 22px; margin-bottom: 14px; }
  .lead-detail-grid { grid-template-columns: 1fr; gap: 10px; }
  .login-box { width: 90vw; max-width: 392px; padding: 32px 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), .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: var(--accent); }
.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; }
