@import url('https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Государственный синий */
  --bg-primary: #f0f2f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef1f8;

  --accent: #1a3d8f;
  --accent-light: #2454b5;
  --accent-hover: #122e6e;
  --accent-bg: #e8eef9;
  --accent-subtle: #f0f4fc;

  --success: #1e7e4b;
  --success-bg: #eaf5ef;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warning: #a55f1a;
  --warning-bg: #fef8ee;
  --info: #1a3d8f;
  --info-bg: #e8eef9;
  --success-hover: #046043;
  --danger-hover:  #a61818;
  --badge-blue-bg:   #eff6ff;  --badge-blue-text:   #1d4ed8;
  --badge-green-bg:  #ecfdf5;  --badge-green-text:  #065f46;
  --badge-red-bg:    #fef2f2;  --badge-red-text:    #991b1b;
  --badge-orange-bg: #fff7ed;  --badge-orange-text: #9a3412;
  --badge-purple-bg: #f5f3ff;  --badge-purple-text: #5b21b6;
  --badge-gray-bg:   #f3f4f6;  --badge-gray-text:   #4b5563;

  --text-primary: #0d1b3e;
  --text-secondary: #3d4f6e;
  --text-muted: #6b7a99;
  --border: #dce3f0;
  --border-light: #edf1f9;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 4px rgba(26,61,143,0.10);
  --shadow-sm: 0 1px 2px rgba(26,61,143,0.07);
  --shadow-lg: 0 4px 20px rgba(26,61,143,0.14);

  --font-base: 'Golos Text', 'Segoe UI', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

/* ── DARK THEME ───────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1f2937;
  --bg-card: #1f2937;
  --bg-hover: #374151;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-hover: #2563eb;
  --success: #10b981;
  --danger: #f87171;
  --warning: #fbbf24;
  --info: #22d3ee;
  --success-bg: #064e3b;
  --danger-bg:  #450a0a;
  --warning-bg: #422006;
  --info-bg:    #0c2340;
  --badge-blue-bg:   #1e3a5f;  --badge-blue-text:   #93c5fd;
  --badge-green-bg:  #064e3b;  --badge-green-text:  #6ee7b7;
  --badge-red-bg:    #450a0a;  --badge-red-text:    #fca5a5;
  --badge-orange-bg: #422006;  --badge-orange-text: #fcd34d;
  --badge-purple-bg: #2e1065;  --badge-purple-text: #c4b5fd;
  --badge-gray-bg:   #1f2937;  --badge-gray-text:   #94a3b8;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #9ca3af;
  --border: #374151;
  --border-light: #2d3748;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
}

[data-theme="dark"] .sidebar {
  background: #0a0f1e;
}
[data-theme="dark"] .sidebar-logo {
  border-bottom-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .sidebar-footer {
  border-top-color: rgba(255,255,255,0.06);
}

/* Подсказка участка — dark handled via CSS vars */

/* Ошибка строки в preview */
[data-theme="dark"] .preview-row-error td { background: rgba(248,113,113,0.08); }

/* Кнопка переключения темы */
.theme-toggle { border-radius: var(--radius-sm); }

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

body {
  font-family: var(--font-base);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px; min-height: 100vh;
  background: var(--accent);
  border-right: none;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease, width 0.25s ease;
  overflow: hidden;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: relative;
}
.sidebar-logo .logo-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-light), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 10px;
}
.sidebar-logo h2 {
  font-size: 15px; font-weight: 700;
  color: #f1f5f9; line-height: 1.3;
}
.sidebar-logo span {
  font-size: 11px; color: #94a3b8; font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) rgba(0, 0, 0, 0.18);
}
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.48);
}

.nav-section { margin-bottom: 16px; }
.nav-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  color: #64748b; text-transform: uppercase;
  padding: 0 8px; margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: #94a3b8; text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all 0.15s ease; cursor: pointer;
  margin-bottom: 1px;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #f1f5f9; }
.nav-item.active { background: rgba(37,99,235,0.25); color: #93c5fd; }
.nav-item--aux { opacity: 0.88; font-size: 12px; }
.nav-item--aux .nav-label { font-size: 12px; }
.nav-item .nav-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-item .nav-icon svg { width: 18px; height: 18px; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-light), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0; color: #fff;
}
.user-info-text { flex: 1; min-width: 0; }
.user-info-text .uname {
  font-size: 13px; font-weight: 600; color: #f1f5f9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info-text .urole {
  font-size: 11px; color: #94a3b8;
}

/* ── SIDEBAR COLLAPSE ─────────────────────────────────────── */
.sidebar-collapse-btn {
  position: absolute; top: 12px; right: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px; cursor: pointer;
  color: #94a3b8; transition: all 0.15s;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.14); color: #f1f5f9; }
.sidebar-collapse-btn svg { transition: transform 0.25s ease; flex-shrink: 0; }

/* Nav label spans for text hiding when collapsed */
.nav-label { white-space: nowrap; }

/* Collapsed state */
html.sidebar-collapsed .sidebar { width: 64px; }
html.sidebar-collapsed .sidebar-logo { padding: 16px 10px; flex-direction: column; align-items: center; }
html.sidebar-collapsed .sidebar-logo h2,
html.sidebar-collapsed .sidebar-logo span { display: none; }
html.sidebar-collapsed .sidebar-logo .logo-icon { margin-bottom: 0; }
html.sidebar-collapsed .nav-section-title { display: none; }
html.sidebar-collapsed .nav-section { margin-bottom: 8px; }
html.sidebar-collapsed .nav-label { display: none; }
html.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 8px; }
html.sidebar-collapsed .user-info { justify-content: center; padding: 10px 8px; }
html.sidebar-collapsed .user-info-text { display: none; }
html.sidebar-collapsed .sidebar-logo .sidebar-collapse-btn { position: static; margin-top: 10px; }
html.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

@media (min-width: 769px) {
  html.sidebar-collapsed .main-content { margin-left: 64px; }
}
@media (max-width: 768px) {
  .sidebar-collapse-btn { display: none; }
}

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.main-content {
  margin-left: 260px; flex: 1;
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left 0.25s ease;
}
.main-content--workspace { margin-left: 0; }

.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ── CAMPAIGN BADGE ─────────────────────────────────────── */
.campaign-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  background: var(--bg-hover); border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
  text-decoration: none;
  transition: background 0.15s;
}
.campaign-badge:hover { background: var(--bg-hover); color: var(--text-primary); }
.campaign-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.campaign-dot.active { background: var(--success); }
.campaign-dot.closed { background: var(--text-muted); }

/* ── BREADCRUMBS ───────────────────────────────────────── */
.breadcrumbs {
  padding: 8px 28px; font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs span { color: var(--text-muted); }

/* ── BURGER BUTTON ───────────────────────────────────────── */
.burger-btn {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px; padding: 6px; background: none; border: none;
  cursor: pointer; border-radius: var(--radius-sm); flex-shrink: 0;
  transition: background 0.15s;
}
.burger-btn:hover { background: var(--bg-hover); }
.burger-btn span {
  display: block; height: 2px; background: var(--text-secondary);
  border-radius: 2px; transition: all 0.2s;
}

.page-content { padding: 28px; flex: 1; }
.main-content--workspace .page-content { padding: 14px; }
.main-content--workspace .topbar,
.main-content--workspace .breadcrumbs { padding-left: 14px; padding-right: 14px; }

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

/* ── STATS GRID ───────────────────────────────────────────── */
.stats-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent-light), #7c3aed);
}
.stat-icon { display: flex; align-items: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  min-height: 40px; line-height: 1.2;
  border: none; outline: none; transition: all 0.15s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:focus { outline: none; }
.btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 3px rgba(26,61,143,0.25); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; box-shadow: 0 2px 6px rgba(26,61,143,0.35); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #8f4f16; color: #fff; }
.btn-secondary {
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-sm { padding: 7px 12px; font-size: 13px; min-height: 36px; }
.btn-icon { padding: 0; width: 36px; height: 36px; min-height: 36px; justify-content: center; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: none; padding: 7px 10px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── TABLE ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); max-width: 100%; }
/* Обёртка для очень широких таблиц (дашборд и т.п.) */
.table-wrap--scroll-hint {
  -webkit-overflow-scrolling: touch;
}
.table-scroll-hint {
  margin: 0 0 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
/* Широкая таблица: не сжимать страницу — скролл внутри блока; липкая первая колонка */
table.table-dashboard-wide {
  width: max-content;
  min-width: 100%;
  max-width: none;
}
.table-dashboard-wide thead th:first-child,
.table-dashboard-wide tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 4px 0 12px -4px rgba(0, 0, 0, 0.12);
}
.table-dashboard-wide thead th:first-child {
  z-index: 3;
  background: var(--bg-primary);
}
.table-dashboard-wide tbody td:first-child {
  background: var(--bg-card);
}
.table-dashboard-wide tbody tr:hover td:first-child {
  background: var(--bg-hover);
}
.table-dashboard-wide .td-poll-place {
  max-width: 220px;
  vertical-align: top;
}
.table-dashboard-wide .td-ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: var(--bg-primary);
  color: var(--text-secondary); font-weight: 600;
  padding: 12px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 12px 14px; color: var(--text-primary); vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ── VOTERS GRID ──────────────────────────────────────────── */
.voters-grid-card { padding: 0; overflow: hidden; }

/* ── Card toolbar ─ */
.vg-card-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 12px; flex-wrap: wrap;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.vg-toolbar-left  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vg-toolbar-right { display: flex; align-items: center; gap: 8px; }
.vg-toolbar-divider { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }

.vg-filter-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12.5px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.vg-filter-btn:hover { border-color: var(--accent-light); color: var(--accent); }
.vg-filter-btn.is-active { border-color: var(--accent); color: var(--accent); background: var(--info-bg); }

.vg-active-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--accent); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700;
}

.vg-count { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.vg-count strong { color: var(--text-primary); font-weight: 600; }

/* ── Filter panel ─ */
.vg-filter-panel { border-bottom: 1px solid var(--border); }

.vg-filter-inner {
  padding: 16px 20px 14px;
  background: var(--bg-secondary);
}

.vg-filter-groups {
  display: flex; flex-wrap: wrap; gap: 0;
  margin-bottom: 12px;
}
.vg-filter-group {
  display: flex; flex-direction: column; gap: 7px;
  padding-right: 20px;
}
.vg-filter-group + .vg-filter-group {
  padding-left: 20px;
  border-left: 1px solid var(--border);
}
.vg-filter-group-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.vg-filter-group-fields {
  display: flex; flex-wrap: wrap; gap: 8px;
}

.vg-filter-field { display: flex; flex-direction: column; gap: 3px; width: 135px; }
.vg-filter-label { font-size: 11px; font-weight: 500; color: var(--text-secondary); }

.vg-filter {
  width: 100%; padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px; font-family: inherit;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.vg-filter:focus { border-color: var(--accent-light); box-shadow: 0 0 0 2px rgba(37,99,235,0.10); }
.vg-filter::placeholder { color: var(--text-muted); font-size: 12px; }
select.vg-filter { cursor: pointer; }

/* ── Add voter panel ─ */
.vg-add-panel {
  border: 1.5px solid var(--accent-light) !important;
  box-shadow: 0 4px 12px rgba(37,99,235,0.10) !important;
}
.vg-add-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--info-bg);
  border-bottom: 1px solid var(--border);
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}
.vg-add-panel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--accent);
}
.vg-panel-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1;
  padding: 2px 7px; border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.vg-panel-close:hover { background: rgba(0,0,0,0.06); color: var(--text-primary); }
.vg-add-panel-body { padding: 18px; }

.vg-add-groups { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 16px; }
.vg-add-group { display: flex; flex-direction: column; gap: 7px; padding-right: 20px; }
.vg-add-group + .vg-add-group { padding-left: 20px; border-left: 1px solid var(--border); }
.vg-add-group-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.vg-add-group-fields { display: flex; flex-wrap: wrap; gap: 10px; }

.vg-add-field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; flex: 1; }
.vg-add-field--wide { min-width: 220px; flex: 2; }

.vg-add-panel-actions {
  display: flex; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--border-light);
}

/* ── Table sort ─ */
.voters-grid thead th.sortable { cursor: pointer; user-select: none; }
.voters-grid thead th.sortable:hover { background: var(--bg-hover); color: var(--text-primary); }
.sort-arrow { font-style: normal; color: var(--accent); margin-left: 2px; }
.voters-grid .vg-col-num { width: 38px; text-align: center; padding: 8px 6px; }
.voters-grid .vg-col-actions { width: 66px; }

/* Compact table */
.voters-grid tbody td { padding: 9px 10px; font-size: 13px; }
.voters-grid thead th { padding: 10px 10px; }

/* ── Inline new-row ─────────────────────────────────────── */
.vg-new-row td { padding: 5px 3px !important; border-bottom: 2px solid var(--accent-light) !important; background: var(--info-bg); }
.vg-inline-input {
  width: 100%; padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12.5px; font-family: inherit;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.vg-inline-input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.10);
}
.vg-inline-input::placeholder { color: var(--text-muted); font-size: 11.5px; }
select.vg-inline-input { cursor: pointer; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 3px; }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 14px;
  font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
.form-row {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.form-row-3 {
  display: grid; gap: 16px;
  grid-template-columns: repeat(3, 1fr);
}
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ── VOTER FORM TABLE ─────────────────────────────────────── */
.voter-form-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
  overflow: visible;
}
.voter-form-table th,
.voter-form-table td {
  padding: 8px 12px;
  vertical-align: middle;
  border: 1px solid var(--border-light);
  font-size: 14px;
}
.voter-form-table th {
  background: var(--accent-subtle, #f0f4fc);
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
  text-align: right;
}
.voter-form-table td { background: var(--bg-card); }
.voter-form-table td.vft-empty { background: transparent; border: none; }
.voter-form-table .form-control { margin-bottom: 0; }
.voter-form-table .form-hint { margin-bottom: 0; }
.vft-label-col { width: 13%; }
.vft-input-col { width: 20%; }
@media (max-width: 700px) {
  .voter-form-table, .voter-form-table tbody,
  .voter-form-table tr, .voter-form-table th, .voter-form-table td {
    display: block; width: 100%;
  }
  .voter-form-table th { text-align: left; border-bottom: none; }
  .voter-form-table td.vft-empty { display: none; }
}

/* ── MONO — моноширинные поля (паспорт, СНИЛС, ИНН) ─────── */
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--text-secondary);
}
input.mono, .form-control.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

/* ── STATION HINT ─────────────────────────────────────────── */
.station-hint-box {
  display: none; padding: 8px 12px; margin-top: 6px;
  background: var(--info-bg); border: 1px solid var(--info);
  border-radius: var(--radius-sm); font-size: 12.5px; color: var(--info);
}
.station-hint-box.show { display: block; }
.station-hint-box.not-found { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }

/* ── ALERTS / FLASH ───────────────────────────────────────── */
.flash-messages { margin-bottom: 20px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; margin-bottom: 10px;
  border: 1px solid transparent;
}
.alert-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 0 0 8px; opacity: 0.5;
  color: inherit; flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger);  color: var(--danger); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.alert-info    { background: var(--info-bg);    border-color: var(--info);    color: var(--info); }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-blue   { background: var(--badge-blue-bg);   color: var(--badge-blue-text); }
.badge-green  { background: var(--badge-green-bg);  color: var(--badge-green-text); }
.badge-red    { background: var(--badge-red-bg);    color: var(--badge-red-text); }
.badge-orange { background: var(--badge-orange-bg); color: var(--badge-orange-text); }
.badge-purple { background: var(--badge-purple-bg); color: var(--badge-purple-text); }
.badge-gray   { background: var(--badge-gray-bg);   color: var(--badge-gray-text); }

/* ── AUTOCOMPLETE ─────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  /* позиционирование задаётся через JS (position: fixed + getBoundingClientRect) */
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 9999; max-height: 260px; overflow-y: auto;
  display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
  padding: 9px 14px; cursor: pointer;
  font-size: 13.5px; color: var(--text-primary);
  white-space: nowrap;
  transition: background 0.1s; border-bottom: 1px solid var(--border-light);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg-hover); color: var(--accent-light); }

/* ── FILE UPLOAD ──────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 40px 20px;
  text-align: center; cursor: pointer;
  transition: all 0.2s; color: var(--text-muted); font-size: 14px;
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--accent-light); color: var(--accent-light);
  background: rgba(37,99,235,0.03);
}
.file-drop .file-icon { margin-bottom: 10px; }

/* ── PREVIEW TABLE ────────────────────────────────────────── */
.preview-table { margin-top: 16px; }
.preview-row-error td { background: rgba(200,30,30,0.05); }

/* ── LOGIN PAGE ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg-primary);
  background-image: radial-gradient(ellipse at 20% 20%, rgba(37,99,235,0.06) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 80%, rgba(124,58,237,0.05) 0%, transparent 60%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 48px 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .logo-circle {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-light), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 8px 24px rgba(37,99,235,0.25);
}
.login-logo .logo-circle svg { width: 32px; height: 32px; stroke: #fff; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

/* ── FIELD WITH ICON ─────────────────────────────────────── */
.input-icon-wrap { position: relative; }
.input-icon-wrap .field-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.input-icon-wrap .form-control { padding-left: 40px; }

/* ── STATUS INDICATORS ────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.status-active { background: var(--success); }
.status-inactive { background: var(--danger); }

/* ── PROGRESS ─────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--bg-primary); border-radius: 999px;
  height: 8px; overflow: hidden; margin-top: 6px;
}
.progress-bar {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-light), #7c3aed);
  transition: width 0.5s ease;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ── PROGRESS BAR INLINE ────────────────────────────────── */
.progress-inline { display: flex; align-items: center; gap: 8px; }
.progress-inline-bar {
  flex: 1; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden; min-width: 60px;
}
.progress-inline-fill { height: 100%; border-radius: 3px; }
.progress-inline-label {
  font-size: 11px; color: var(--text-secondary);
  white-space: nowrap; min-width: 32px; text-align: right;
}

/* ── ORG STATS BAR ───────────────────────────────────────── */
.vg-org-stats {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; background: var(--bg-hover);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.vg-org-stat { display: flex; align-items: baseline; gap: 5px; }
.vg-org-stat-val { font-size: 18px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.vg-org-stat-lbl { font-size: 12px; color: var(--text-muted); }
.vg-org-stat-div { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .burger-btn { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.2); }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
  .login-card { margin: 16px; padding: 32px 24px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .campaign-badge { display: none; }
  .breadcrumbs { padding: 8px 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-actions .btn span:not(.nav-icon) { display: none; }
}

/* ── SIDEBAR OVERLAY (mobile) ────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 99;
}
@media (max-width: 768px) {
  .sidebar-overlay.show { display: block; }
}

/* ── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }

/* ── CONFIRM MODAL ───────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; max-width: 360px; width: 90%;
  box-shadow: var(--shadow);
}
.modal-box h3 { margin-bottom: 12px; font-size: 16px; color: var(--text-primary); }
.modal-box p { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── TABLE ROW ACTIONS ────────────────────────────────────── */
.btn-table-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary); border: 1px solid var(--border);
  cursor: pointer; color: var(--text-secondary);
  transition: all 0.15s; text-decoration: none; flex-shrink: 0;
}
.btn-table-action:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border); }
.btn-table-action.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.btn-table-action svg { width: 15px; height: 15px; }
.tbl-actions { display: flex; gap: 3px; align-items: center; }

/* Действия в таблице всегда видимы для лучшей обнаруживаемости */
.voters-grid tbody tr .tbl-actions { opacity: 1; transition: opacity 0.15s; }
.voters-grid tbody tr:hover .tbl-actions,
.voters-grid tbody tr:focus-within .tbl-actions { opacity: 1; }

/* ── STAT ICON WRAP ─────────────────────────────────────────── */
.stat-icon-wrap {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-bottom: 6px;
}
.stat-icon-wrap svg { width: 22px; height: 22px; }
.siw-blue   { background: var(--badge-blue-bg);   color: var(--badge-blue-text); }
.siw-green  { background: var(--badge-green-bg);  color: var(--badge-green-text); }
.siw-purple { background: var(--badge-purple-bg); color: var(--badge-purple-text); }
.siw-orange { background: var(--badge-orange-bg); color: var(--badge-orange-text); }
.siw-teal   { background: #f0fdfa; color: #0f766e; }
[data-theme="dark"] .siw-teal   { background: #134e4a; color: #5eead4; }

/* ── TABS ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.tab-btn {
  padding: 10px 18px; background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 13.5px;
  font-weight: 500; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all 0.15s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-light); border-bottom-color: var(--accent-light); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── FILE UPLOAD ICON ─────────────────────────────────────── */
.file-icon { display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }

/* ── REDUCED MOTION ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
  .progress-bar { transition: none; }
  .stat-card { transition: none; }
}
