/* ═══════════════════════════════════════════════════════════
   Позтрек — Main Stylesheet
   Font: Inter (text) + JetBrains Mono (numbers/data)
   Theme: Light default, Dark via [data-theme="dark"]
═══════════════════════════════════════════════════════════ */

/* ── Google Fonts загружаются через <link> в main.php (параллельно с остальными CSS) ── */

/* ── Variables: Light ────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-page:      #f5f4f1;
  --bg-surface:   #ffffff;
  --bg-surface2:  #f9f8f6;
  --bg-sidebar:   #16162a;
  --bg-sidebar2:  #1e1e38;
  --bg-input:     #ffffff;
  --bg-hover:     #f0eeea;
  --bg-active:    rgba(99,91,255,.08);

  /* Text */
  --tx-primary:   #1a1a2e;
  --tx-secondary: #5a5a7a;
  --tx-muted:     #9898b0;
  --tx-inverse:   #ffffff;
  --tx-sidebar:   rgba(255,255,255,.72);
  --tx-sidebar-muted: rgba(255,255,255,.38);

  /* Brand / accent */
  --accent:       #635bff;
  --accent-hover: #4f46e5;
  --accent-light: #ededff;

  /* Semantic */
  --green:        #0d9e6e;
  --green-light:  #d1fae5;
  --red:          #e53e3e;
  --red-light:    #fee2e2;
  --amber:        #d97706;
  --amber-light:  #fef3c7;
  --blue:         #2563eb;
  --blue-light:   #dbeafe;

  /* Campaign colours */
  --ark-bg:       #e8f5e9; --ark-tx:    #1b5e20; --ark-border: #a5d6a7;
  --manual-bg:    #fff8e1; --manual-tx: #6d4c00; --manual-border: #ffe082;
  --clicks-bg:    #ede7f6; --clicks-tx: #311b92; --clicks-border: #b39ddb;

  /* Status */
  --active-bg:    #e8f5e9; --active-tx:   #1b5e20;
  --seasonal-bg:  #e3f2fd; --seasonal-tx: #0d47a1;
  --archived-bg:  #f3f3f3; --archived-tx: #616161;

  /* Borders */
  --border:       #e8e6e0;
  --border-focus: #635bff;

  /* Shadows */
  --shadow-sm:    0 1px 2px rgba(0,0,0,.06);
  --shadow:       0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg:    0 4px 24px rgba(0,0,0,.10);

  /* Radius */
  --r-sm:  6px;
  --r:     10px;
  --r-lg:  14px;
  --r-xl:  20px;

  /* Sidebar */
  --sidebar-w:    256px;
  --topbar-h:     58px;

  /* Transitions */
  --ease: .18s cubic-bezier(.4,0,.2,1);

  /* Aliases used across feature templates (competitor analytics etc.) */
  --tx:          var(--tx-primary);
  --bg-muted:    var(--bg-surface2);
  --border-hover:#d4d1c8;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;
  --rgb-accent:  99, 91, 255;   /* #635bff — keep in sync with --accent */
}

/* ── Variables: Dark ─────────────────────────────────────── */
[data-theme="dark"] {
  --bg-page:      #0e0e1a;
  --bg-surface:   #17172b;
  --bg-surface2:  #1e1e35;
  --bg-sidebar:   #0b0b17;
  --bg-sidebar2:  #13132a;
  --bg-input:     #1e1e35;
  --bg-hover:     #1e1e35;
  --bg-active:    rgba(99,91,255,.18);

  --tx-primary:   #e8e8f5;
  --tx-secondary: #9898c0;
  --tx-muted:     #55557a;

  --accent-light: #2a2860;
  --green-light:  #064e3b;
  --red-light:    #7f1d1d;
  --amber-light:  #451a03;
  --blue-light:   #1e3a5f;

  --ark-bg:       #1a2e1a; --ark-tx:    #86efac; --ark-border: #166534;
  --manual-bg:    #2e2000; --manual-tx: #fcd34d; --manual-border: #92400e;
  --clicks-bg:    #1e1440; --clicks-tx: #c4b5fd; --clicks-border: #4c1d95;

  --active-bg:    #1a2e1a; --active-tx:   #86efac;
  --seasonal-bg:  #1e3a5f; --seasonal-tx: #93c5fd;
  --archived-bg:  #2a2a2a; --archived-tx: #9ca3af;

  --border:       #2a2a45;
  --border-hover: #3a3a5a;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.3);
  --shadow:       0 1px 4px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.2);
  --shadow-lg:    0 4px 24px rgba(0,0,0,.4);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--tx-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  transition: background var(--ease), color var(--ease);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Monospace for all data/numbers */
.mono, .num-cell, td.num, .pos-val, .bid-val, .stat-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

/* ── Layout ──────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--ease);
}

.app-content {
  flex: 1;
  padding: 28px 32px;
  width: 100%;
  min-width: 0;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow: hidden;
  transition: transform var(--ease), width var(--ease);
}

.sidebar__brand {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
  gap: 8px;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  letter-spacing: -.3px;
  min-width: 0;
  flex: 1;
}

.sidebar__logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.sidebar__close {
  background: none; border: none;
  color: var(--tx-sidebar-muted);
  cursor: pointer; font-size: 18px;
  padding: 2px; line-height: 1;
  display: none;
}

/* Search */
.sidebar__search {
  padding: 12px 12px 8px;
  flex-shrink: 0;
  position: relative;
}

.sidebar__search-wrap {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-sm);
  padding: 0 10px;
  gap: 6px;
  transition: border-color var(--ease);
}
.sidebar__search-wrap:focus-within {
  border-color: var(--accent);
  background: rgba(99,91,255,.12);
}
.sidebar__search-wrap i { color: var(--tx-sidebar-muted); font-size: 13px; flex-shrink: 0; }
.sidebar__search-input {
  background: transparent;
  border: none; outline: none;
  color: rgba(255,255,255,.85);
  font-size: 13px;
  padding: 7px 0;
  width: 100%;
}
.sidebar__search-input::placeholder { color: rgba(255,255,255,.3); }

.search-dropdown {
  position: absolute;
  left: 12px; right: 12px;
  top: calc(100% - 4px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 340px;
  overflow-y: auto;
  display: none;
}
.search-dropdown.open { display: block; }
.search-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--ease);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg-hover); }
.search-item__art { font-weight: 600; font-size: 13px; font-family: 'JetBrains Mono', monospace; }
.search-item__sub { font-size: 12px; color: var(--tx-secondary); margin-top: 1px; }
.search-empty { padding: 16px; text-align: center; color: var(--tx-muted); font-size: 13px; }

/* Nav */
.sidebar__nav { flex: 1; overflow-y: auto; padding: 6px 8px; }
.sidebar__nav::-webkit-scrollbar { width: 4px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-group { margin-bottom: 4px; }
.nav-group__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--tx-sidebar-muted);
  padding: 10px 10px 4px;
}

.nav-item { list-style: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  color: var(--tx-sidebar);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
  text-decoration: none;
}
.nav-link i { font-size: 16px; flex-shrink: 0; opacity: .8; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active {
  background: rgba(99,91,255,.22);
  color: #a5a0ff;
  font-weight: 500;
}
.nav-link.active i { opacity: 1; }

/* Sidebar footer / user */
.sidebar__footer {
  padding: 10px 10px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: var(--r-sm);
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.user-name  { color: #fff; font-size: 13px; font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { color: var(--tx-sidebar-muted); font-size: 11px; text-transform: capitalize; }
.user-logout {
  flex-shrink: 0;
  color: var(--tx-sidebar-muted);
  font-size: 16px;
  text-decoration: none;
  transition: color var(--ease);
  padding: 2px;
  line-height: 1;
}
.user-logout:hover { color: #fc8181; }
.sidebar__theme {
  display: flex; justify-content: flex-end;
  padding: 4px 8px 0;
}
.theme-btn {
  background: none; border: none;
  color: var(--tx-sidebar-muted);
  cursor: pointer; font-size: 15px;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  transition: background var(--ease), color var(--ease);
}
.theme-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
}
.topbar__burger {
  background: none; border: none;
  font-size: 22px; color: var(--tx-secondary);
  cursor: pointer; padding: 4px; line-height: 1;
  display: none;
}
.topbar__breadcrumb { flex: 1; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.breadcrumb a { color: var(--tx-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb__sep { color: var(--tx-muted); }
.breadcrumb__current { color: var(--tx-primary); font-weight: 500; }
.topbar__actions { display: flex; gap: 8px; align-items: center; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1039;
  display: none;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body  { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ── Stat cards ──────────────────────────────────────────── */
.stat-card {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease), border-color var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.stat-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--tx-muted);
  margin-bottom: 6px;
}
.stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px; font-weight: 500;
  line-height: 1.1;
  color: var(--tx-primary);
}
.stat-trend {
  margin-top: 5px;
  font-size: 12px;
  display: flex; align-items: center; gap: 4px;
}
.stat-prev { color: var(--tx-muted); }

/* ── Trend ───────────────────────────────────────────────── */
.trend-up   { color: var(--green); }
.trend-down { color: var(--red); }
.trend-eq   { color: var(--tx-muted); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge i { line-height: 1; }
.badge-ark     { background: var(--ark-bg);      color: var(--ark-tx);      border-color: var(--ark-border); }
.badge-manual  { background: var(--manual-bg);   color: var(--manual-tx);   border-color: var(--manual-border); }
.badge-clicks  { background: var(--clicks-bg);   color: var(--clicks-tx);   border-color: var(--clicks-border); }
.badge-active  { background: var(--active-bg);   color: var(--active-tx); }
.badge-seasonal{ background: var(--seasonal-bg); color: var(--seasonal-tx); }
.badge-archived{ background: var(--archived-bg); color: var(--archived-tx); }
.badge-danger  { background: var(--red-light);   color: var(--red); }
.badge-changed { background: var(--amber-light); color: var(--amber); font-size: 10px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--ease);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn i { font-size: 15px; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-sm i { font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; }

/* Date picker button - wraps native input[type=date] cleanly */
.date-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--tx-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease);
  user-select: none;
  min-width: 110px;
  justify-content: center;
}
.date-btn:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.date-btn input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 1px;
  border: none;
  background: transparent;
  z-index: 2;
}
/* Fix Firefox - make sure whole area is clickable */
.date-btn input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--tx-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--tx-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--tx-primary); }
.topbar-active { background: var(--accent) !important; color: #fff !important; }
.topbar-active:hover { background: var(--accent) !important; opacity: .9; }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border-color: transparent;
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-success {
  background: var(--green-light);
  color: var(--green);
  border-color: transparent;
}
.btn-success:hover { background: var(--green); color: #fff; }

.btn-icon {
  padding: 7px;
  background: transparent;
  border-color: var(--border);
  color: var(--tx-secondary);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--accent); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px; font-weight: 500;
  color: var(--tx-secondary);
  margin-bottom: 5px;
}
.form-label .req { color: var(--red); margin-left: 2px; }

.form-control, .form-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--tx-primary);
  font-family: inherit;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
}
.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,91,255,.12);
}
.form-control.mono, input.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
.form-control-sm { padding: 5px 9px; font-size: 13px; }
.form-select-sm  { padding: 5px 9px; font-size: 13px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--tx-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }
.form-control.is-invalid { border-color: var(--red); }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--tx-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-surface2);
  text-align: left;
}
.table th.num, .table td.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: var(--bg-hover); }
.table tbody tr.row-striped:nth-child(even) td { background: var(--bg-surface2); }

/* ── Position display ────────────────────────────────────── */
.pos-cell { display: flex; gap: 10px; align-items: center; }
.pos-org  { font-family: 'JetBrains Mono', monospace; color: var(--blue); }
.cpo-high { color: var(--red); font-weight: 600; }  /* CPO > 120 */
.pos-adv  { font-family: 'JetBrains Mono', monospace; color: var(--tx-primary); font-weight: 500; }
.pos-adv.danger { color: var(--red); font-weight: 600; }
.pos-none { color: var(--tx-muted); }

/* ── Day compare view ────────────────────────────────────── */
.day-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.day-col {
  padding: 0;
}
.day-col + .day-col {
  border-left: 1px solid var(--border);
}
.day-col--today { background: rgba(99,91,255,.02); }
.day-col__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface2);
  display: flex; align-items: center; justify-content: space-between;
}
.day-col__label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--tx-muted);
}
.day-col--today .day-col__label { color: var(--accent); }
.day-summary {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.day-stat {
  background: var(--bg-surface);
  padding: 10px 12px;
  text-align: center;
}
.day-stat__label { font-size: 10px; color: var(--tx-muted); text-transform: uppercase; letter-spacing: .3px; }
.day-stat__val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px; font-weight: 500;
  margin-top: 2px;
}
.day-stat__trend { font-size: 11px; margin-top: 1px; }

/* ── Keyword table ───────────────────────────────────────── */
.kw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kw-table th {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--tx-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface2);
  white-space: nowrap;
}
.kw-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.kw-table tbody tr:last-child td { border-bottom: none; }
.kw-table tbody tr:hover td { background: var(--bg-hover); }
.kw-name { font-size: 13px; color: var(--tx-primary); word-break: break-word; }
.kw-org-val  { font-family: 'JetBrains Mono', monospace; color: var(--blue); font-size: 13px; }
.kw-adv-val  { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500; }
.kw-adv-val.adv-danger { color: var(--red); }
.kw-bid-input {
  width: 70px; padding: 3px 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  color: var(--tx-primary);
  text-align: right;
}
.kw-bid-input:focus { border-color: var(--border-focus); outline: none; box-shadow: 0 0 0 2px rgba(99,91,255,.1); }
.kw-bid-input.changed { border-color: var(--amber); background: var(--amber-light); }

/* ── Paste area (Evirma) ─────────────────────────────────── */
.paste-area {
  background: var(--bg-surface2);
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color var(--ease), background var(--ease);
}
.paste-area:focus-within {
  border-color: var(--accent);
  background: rgba(99,91,255,.02);
}
.paste-area textarea {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  resize: vertical;
  color: var(--tx-primary);
  width: 100%;
  outline: none;
  padding: 0;
}
.paste-area textarea::placeholder { color: var(--tx-muted); }

/* Preview after parse */
.parse-preview {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-top: 12px;
}
.parse-preview__header {
  background: var(--bg-surface2);
  padding: 8px 14px;
  font-size: 12px; font-weight: 500;
  color: var(--tx-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}
.parse-row {
  display: grid; grid-template-columns: 1fr 120px 60px 60px;
  gap: 8px; align-items: center;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.parse-row:last-child { border-bottom: none; }
.parse-row:hover { background: var(--bg-hover); }
.parse-row__key { color: var(--tx-secondary); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parse-row__raw { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--tx-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parse-row__org { font-family: 'JetBrains Mono', monospace; color: var(--blue); font-size: 13px; text-align: right; }
.parse-row__adv { font-family: 'JetBrains Mono', monospace; font-weight: 500; font-size: 13px; text-align: right; }
.parse-row--mismatch { background: var(--amber-light); }

/* ── Article list cards ──────────────────────────────────── */
.article-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--ease), border-color var(--ease), transform var(--ease);
  cursor: pointer;
}
.article-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
  transform: translateY(-1px);
  color: inherit;
}
.article-card__wb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px; font-weight: 500;
}
.article-card__subject { font-size: 12.5px; color: var(--tx-secondary); margin-top: 2px; }
.article-card__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.article-card__stats { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--tx-muted); }
.article-card__stat-val { font-family: 'JetBrains Mono', monospace; color: var(--tx-primary); font-weight: 500; }

/* ── Charts ──────────────────────────────────────────────── */
.chart-wrap { position: relative; }
.chart-wrap canvas { max-width: 100%; }

/* ── Lock button ─────────────────────────────────────────── */
.lock-btn { font-size: 12px; }
.lock-btn.locked { color: var(--amber); }
.lock-btn.unlocked { color: var(--green); }

/* ── Tabs ────────────────────────────────────────────────── */
.tab-list {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.tab-btn {
  padding: 10px 18px;
  background: none; border: none;
  font-size: 13.5px; font-weight: 500;
  color: var(--tx-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--ease), border-color var(--ease);
}
.tab-btn:hover { color: var(--accent); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Flash messages ──────────────────────────────────────── */
.flash-msg {
  padding: 12px 16px;
  border-radius: var(--r);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  animation: slideDown .25s ease;
}
.flash-success { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.flash-danger  { background: var(--red-light);   color: var(--red);   border: 1px solid var(--red); }
.flash-warning { background: var(--amber-light);  color: var(--amber); border: 1px solid var(--amber); }
.flash-info    { background: var(--blue-light);   color: var(--blue);  border: 1px solid var(--blue); }
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }
.flash-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .55; font-size: 18px; line-height: 1; padding: 0 2px; transition: opacity .15s; }
.flash-close:hover { opacity: 1; }

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  width: 100%;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 600; line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--tx-secondary); margin-top: 3px; }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-sidebar);
  padding: 24px;
  box-sizing: border-box;
}
.login-box {
  width: 100%; max-width: 400px;
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}
.login-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-bottom: 28px;
}
.login-logo-icon {
  width: 44px; height: 44px;
  background: var(--accent);
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.login-logo-text { font-size: 20px; font-weight: 700; color: var(--tx-primary); }
.login-title { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.login-sub   { font-size: 13px; color: var(--tx-secondary); text-align: center; margin-bottom: 24px; }

/* ── Export (public) page ────────────────────────────────── */
.export-page { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.export-header { text-align: center; margin-bottom: 32px; }
.export-article {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  margin-bottom: 24px;
  overflow: hidden;
}
.export-article__head {
  padding: 14px 20px;
  background: var(--bg-surface2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.export-article__wb { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 15px; }

/* ── Utilities ───────────────────────────────────────────── */
.text-muted   { color: var(--tx-muted) !important; }
.text-secondary { color: var(--tx-secondary) !important; }
.text-success { color: var(--green) !important; }
.text-danger  { color: var(--red) !important; }
.text-accent  { color: var(--accent) !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.ms-auto { margin-left: auto; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
.p-0 { padding: 0; }
.w-100 { width: 100%; }
.hidden { display: none; }

/* ── Grid helpers ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

/* ── Divider ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Skeleton loading ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface2) 25%, var(--bg-hover) 50%, var(--bg-surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #e8ecf0; border-radius: 5px; }
::-webkit-scrollbar-thumb { background: #8e99aa; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }
/* Firefox */
* { scrollbar-width: auto; scrollbar-color: #8e99aa #e8ecf0; }


/* ── Responsive ──────────────────────────────────────────── */
@media (min-width: 1600px) {
  .app-content { padding: 28px 40px; }
}

@media (max-width: 1200px) {
  .app-content { padding: 20px 24px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-256px); width: 256px; }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar__burger { display: block; }
  .sidebar__close { display: block; }
  .app-content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .day-compare { grid-template-columns: 1fr; }
  .day-col + .day-col { border-left: none; border-top: 1px solid var(--border); }
  .page-header { flex-direction: column; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr; }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .login-box { padding: 28px 20px; }
  .topbar { padding: 0 12px; }
  .app-content { padding: 12px; }
}

/* ═══════════════════════════════════════════════════════════
   PzTable — единая система таблиц: сортировка, фильтры, видимость колонок
   ═══════════════════════════════════════════════════════════ */

/* Toolbar над таблицей */
.pzt-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface2);
  font-size: 12.5px;
}
.pzt-toolbar__count  { font-weight: 600; color: var(--tx-primary); }
.pzt-toolbar__stat   { color: var(--tx-muted); font-size: 12px; }
.pzt-toolbar__stat strong { color: var(--tx-primary); }
.pzt-toolbar__spacer { flex: 1; min-width: 0; }

/* Кнопка сброса фильтров */
.pzt-reset-btn {
  display: none;
  align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 9px;
  font-size: 11.5px; color: var(--tx-muted); cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.pzt-reset-btn:hover { color: var(--red); border-color: var(--red); background: var(--red-light); }
.pzt-reset-btn.visible { display: flex; }

/* Кнопка и дропдаун видимости колонок */
.pzt-colvis-wrap { position: relative; }
.pzt-colvis-btn {
  display: flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 9px;
  font-size: 11.5px; color: var(--tx-muted); cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
}
.pzt-colvis-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(99,91,255,.06); }
.pzt-colvis-btn.has-hidden { color: var(--accent); border-color: var(--accent); }
.pzt-colvis-dd {
  display: none; position: absolute; right: 0; top: calc(100% + 5px);
  z-index: 1200;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.22);
  min-width: 210px; max-height: 400px;
  overflow-y: auto; padding: 5px 0;
}
.pzt-colvis-dd.open { display: block; }
.pzt-colvis-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px; cursor: pointer;
  font-size: 12.5px; color: var(--tx-primary);
  transition: background .1s;
  user-select: none;
}
.pzt-colvis-item:hover { background: var(--bg-hover); }
.pzt-colvis-item input[type=checkbox] { flex-shrink: 0; accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.pzt-colvis-sep {
  height: 1px; background: var(--border); margin: 4px 0;
}

/* Таблица */
.pzt {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: auto;
}

/* Заголовки — sticky при вертикальном скролле внутри .pzt-wrap */
.pzt thead th {
  padding: 0;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--tx-muted);
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg-surface2);
  white-space: nowrap;
  user-select: none;
  vertical-align: middle;
  position: sticky; top: 0; z-index: 20;
}
.pzt thead th:last-child { border-right: none; }

/* Внутренний flex-контейнер в th */
.pzt-th-inner {
  display: flex; align-items: center; gap: 2px;
  padding: 7px 8px; min-width: 0;
}

/* Кликабельный текст — триггер сортировки */
.pzt-sort {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; display: block;
  transition: color .15s;
}
.pzt-sort:hover { color: var(--accent); }
.pzt-sort-icon { font-size: 10px; margin-left: 2px; opacity: .4; vertical-align: middle; transition: opacity .15s; }
.pzt-sort:hover .pzt-sort-icon { opacity: 1; color: var(--accent); }

/* Кнопка фильтра в заголовке */
.pzt-filter-btn {
  flex-shrink: 0;
  background: transparent; border: none; cursor: pointer;
  padding: 2px 4px; border-radius: 3px;
  color: var(--tx-muted); font-size: 11px; line-height: 1;
  opacity: .3; transition: opacity .15s, color .15s, background .15s;
}
.pzt thead th:hover .pzt-filter-btn { opacity: .6; }
.pzt-filter-btn:hover  { opacity: 1 !important; color: var(--accent); background: rgba(99,91,255,.1); }
.pzt-filter-btn.active { opacity: 1 !important; color: var(--accent); }

/* Ячейки тела */
.pzt tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: middle;
}
.pzt tbody td:last-child { border-right: none; }
.pzt tbody tr:last-child td { border-bottom: none; }
.pzt tbody tr:hover td { background: var(--bg-hover); }

/* Числовые ячейки */
.pzt .num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* Footer — sticky при вертикальном скролле */
.pzt tfoot td {
  padding: 6px 8px; font-weight: 700;
  border-top: 2px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg-surface2);
  position: sticky; bottom: 0; z-index: 20;
}
.pzt tfoot td:last-child { border-right: none; }

/* Скрытая колонка */
.pzt th.pzt-col-hidden,
.pzt td.pzt-col-hidden { display: none !important; }

/* Обёртка — скролл по обеим осям; высота задаётся через pztFitHeight() */
.pzt-wrap { overflow: auto; }


/* ── Shared filter popup (singleton #pztPopup) ─────────────── */
#pztPopup {
  display: none; position: fixed; z-index: 9500;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.24);
  width: 264px; max-height: 430px;
  flex-direction: column; overflow: hidden;
}
#pztPopup.pzt-open { display: flex; }
.pzt-pp-search {
  padding: 8px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.pzt-pp-search input {
  width: 100%; box-sizing: border-box;
  height: 30px; font-size: 12px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-input); color: var(--tx-primary);
  outline: none; transition: border-color .15s;
}
.pzt-pp-search input:focus { border-color: var(--border-focus); }
.pzt-pp-selall {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  font-size: 12px; cursor: pointer; user-select: none;
  flex-shrink: 0;
}
.pzt-pp-selall:hover { background: var(--bg-hover); }
.pzt-pp-list { overflow-y: auto; flex: 1; }
.pzt-pp-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; cursor: pointer;
  font-size: 12px; border-bottom: 1px solid var(--border);
  user-select: none; transition: background .1s;
}
.pzt-pp-item:hover { background: var(--bg-hover); }
.pzt-pp-item:last-child { border-bottom: none; }
.pzt-pp-item input[type=checkbox] { flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }
.pzt-pp-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; color: var(--tx-primary); }
.pzt-pp-empty { padding: 16px; text-align: center; color: var(--tx-muted); font-size: 12px; }
.pzt-pp-footer {
  padding: 8px 10px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 8px;
  flex-shrink: 0;
}

/* Ручки изменения ширины колонок */
.pzt-resize-handle {
  position: absolute; top: 0; right: 0;
  width: 5px; height: 100%;
  cursor: col-resize; z-index: 25; user-select: none;
}
.pzt-resize-handle:hover,
.pzt-resize-handle.resizing { background: var(--accent); opacity: 0.35; }

/* ═══════════════════════════════════════════════════════════
   PzTip — всплывающие подсказки (data-pztip)
   ═══════════════════════════════════════════════════════════ */
#pzTip {
  position: fixed; z-index: 99100; pointer-events: none;
  max-width: 270px; min-width: 120px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 12px; line-height: 1.55;
  color: var(--tx-primary);
  box-shadow: 0 6px 24px rgba(0,0,0,.16);
  opacity: 0; transition: opacity .15s;
  font-weight: 400; text-transform: none;
  letter-spacing: normal; white-space: normal;
  display: flex; flex-direction: column; gap: 3px;
}
#pzTip.pz-tip--vis { opacity: 1; }
.pz-tip__title {
  font-size: 11.5px; font-weight: 700;
  color: var(--accent); display: block;
  margin-bottom: 1px;
}
.pz-tip__desc {
  display: block; color: var(--tx-muted);
}

/* ═══════════════════════════════════════════════════════════
   Page loader — красивый экран загрузки
   ═══════════════════════════════════════════════════════════ */
#pzLoader {
  position: fixed; inset: 0; z-index: 99999;
  background: var(--bg-page);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  transition: opacity .35s ease, visibility .35s ease;
}
#pzLoader.pz-loader--hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}
.pz-loader__logo {
  display: flex; align-items: center; gap: 12px;
}
.pz-loader__icon {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(99,91,255,.35);
  animation: pzLoaderPulse 1.8s ease-in-out infinite;
}
.pz-loader__wordmark {
  font-size: 22px; font-weight: 700; letter-spacing: -.5px; line-height: 1;
}
.pz-loader__wordmark span:first-child { color: var(--accent); }
.pz-loader__wordmark span:last-child  { color: var(--tx-primary); }
.pz-loader__bar {
  width: 160px; height: 3px;
  background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.pz-loader__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 2px;
  animation: pzLoaderSlide 1.4s ease-in-out infinite;
}
@keyframes pzLoaderPulse {
  0%,100% { transform: scale(1);   box-shadow: 0 8px 24px rgba(99,91,255,.35); }
  50%      { transform: scale(1.06); box-shadow: 0 12px 32px rgba(99,91,255,.55); }
}
@keyframes pzLoaderSlide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

/* ── Кнопка в состоянии загрузки (form submit) ──────────── */
@keyframes pzSpin {
  to { transform: rotate(360deg); }
}
.pz-spin-icon {
  display: inline-block;
  animation: pzSpin .7s linear infinite;
  margin-right: 5px;
}
/* Кнопка в состоянии загрузки: не серая, а чуть приглушённая */
.btn.pz-btn-loading,
.btn.pz-btn-loading:disabled {
  opacity: .82;
  cursor: default;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   Compact filter bar (rk-report и другие страницы с фильтрами)
   ═══════════════════════════════════════════════════════════ */

/* Компактная строка фильтров */
.cbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 12px;
}
.cbar__sep {
  width: 1px; height: 22px;
  background: var(--border);
  flex-shrink: 0;
  align-self: center;
}
.cbar__title {
  display: flex; align-items: center; gap: 7px;
  font-size: 15px; font-weight: 700;
  color: var(--tx-primary); white-space: nowrap;
  letter-spacing: -.3px;
}
.cbar__title i { color: var(--accent); font-size: 17px; }

/* ══════════════════════════════════════════════════════════════
   Compact summary strip — заменяет крупные grid-4 stat-cards
   на компактную однострочную сводку (как в Ценах конкурентов).
   Единый стиль для всех аналитических разделов.
══════════════════════════════════════════════════════════════ */
.csum {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.csum__item { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.csum__val {
  font-family: var(--font-mono);
  font-size: 18px; font-weight: 600; line-height: 1;
  color: var(--tx-primary);
}
.csum__val--accent { color: var(--accent); }
.csum__val--green  { color: var(--green); }
.csum__val--red    { color: var(--red); }
.csum__sub { font-size: 13px; font-weight: 400; color: var(--tx-muted); }
.csum__lbl { font-size: 12px; color: var(--tx-muted); }
.csum__sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
.csum__spacer { flex: 1; min-width: 0; }
.csum__note { font-size: 12px; color: var(--tx-muted); display: inline-flex; align-items: center; gap: 5px; }

/* Лёгкая поясняющая плашка (как «Как считаются продажи») — компактнее */
.help-note {
  background: var(--bg-surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: 8px 13px; margin-bottom: 12px;
  font-size: 12px; color: var(--tx-muted); line-height: 1.55;
}
.help-note strong { color: var(--tx-primary); }

/* ── Единое пустое состояние (нет данных / нет пресета и т.п.) ───────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 56px 24px; color: var(--tx-muted);
}
.empty-state__icon {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface2); border: 1px solid var(--border);
  font-size: 28px; color: var(--accent); margin-bottom: 16px;
}
.empty-state__title { font-size: 15px; font-weight: 600; color: var(--tx-primary); }
.empty-state__hint  { font-size: 13px; margin-top: 6px; max-width: 460px; line-height: 1.5; }
.empty-state__actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.empty-state code {
  background: var(--bg-surface2); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: var(--r-sm); font-size: 12px;
  font-family: var(--font-mono); color: var(--tx-primary);
}

/* ── Селектор пресета: подпись + пилюли в одну строку ────────────────── */
.preset-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.preset-bar__label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--tx-muted); white-space: nowrap;
}
.preset-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  font-size: 12.5px; font-weight: 500;
  background: var(--bg-surface); border: 1px solid var(--border);
  color: var(--tx-secondary); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s; text-decoration: none;
}
.preset-pill:hover { border-color: var(--accent); color: var(--accent); }
.preset-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.preset-pill__count {
  font-size: 11px; font-weight: 600; opacity: .7;
  font-family: var(--font-mono);
}
.preset-pill.active .preset-pill__count { opacity: .85; }

/* ── Подсветка строк-угроз в таблицах цен (конкурент дешевле нас) ────── */
.row-threat td { background: rgba(229,62,62,.045) !important; }
.row-threat:hover td { background: rgba(229,62,62,.085) !important; }

/* ── Мини-бар «разрыв с конкурентом» / доля и т.п. ──────────────────── */
.gap-bar { display: flex; align-items: center; gap: 6px; min-width: 78px; }
.gap-bar__track {
  flex: 1; height: 5px; border-radius: 3px;
  background: var(--bg-surface2); overflow: hidden; min-width: 36px;
}
.gap-bar__fill { height: 100%; border-radius: 3px; }
.gap-bar__fill--good { background: var(--green); }
.gap-bar__fill--bad  { background: var(--red); }

/* ── Бейдж тренда (продажи 7д vs пред. 7д) ──────────────────────────── */
.trend-pill {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; font-family: var(--font-mono);
}
.trend-pill--up   { color: var(--green); }
.trend-pill--down { color: var(--red); }
.trend-pill--flat { color: var(--tx-muted); }

/* Быстрые кнопки периода */
.period-pills {
  display: flex; gap: 3px;
}
.period-pill {
  padding: 4px 9px; font-size: 11.5px; font-weight: 500;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--tx-muted);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.4;
}
.period-pill:hover { background: var(--bg-hover); color: var(--tx-primary); border-color: var(--border-hover); }
.period-pill.active { background: rgba(99,91,255,.1); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Dropdown multi-select picker (used in normquery, campaigns list, dashboard) */
.nq-artdd {
  display: none; position: absolute; top: calc(100% + 4px); left: 0;
  z-index: 1200; width: 380px; max-height: 540px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,.2);
  flex-direction: column; overflow: hidden;
}
.nq-artdd.nq-artdd-open { display: flex; }
.nq-art-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface); transition: background .1s;
}
.nq-art-item:hover { background: var(--bg-hover); }
.nq-art-item:last-child { border-bottom: none; }
.nq-art-item input[type=checkbox] { flex-shrink: 0; cursor: pointer; accent-color: var(--accent); }

/* Preset chips inside article picker */
.preset-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 10px;
  background: rgba(99,89,255,.1); color: var(--accent);
  font-size: 11px; font-weight: 500; cursor: pointer;
  user-select: none; white-space: nowrap;
  transition: background .12s, color .12s;
  max-width: 160px; overflow: hidden;
}
.preset-chip:hover { background: rgba(99,89,255,.18); }
.preset-chip span { overflow: hidden; text-overflow: ellipsis; }
.preset-count { background: var(--accent); color: #fff; border-radius: 8px; padding: 0 4px; font-size: 10px; font-weight: 700; flex-shrink: 0; opacity: .85; }
.preset-x { opacity: .5; font-size: 10px; line-height: 1; flex-shrink: 0; padding: 0 1px; transition: opacity .1s; }
.preset-x:hover { opacity: 1; }

/* Fill dot — used in campaigns list and dashboard */
.fill-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.fill-dot--yes { background: var(--green); }
.fill-dot--no  { background: var(--border); }

/* Сегментированный переключатель (группировка и т.п.) */
.seg-ctrl {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.seg-btn {
  background: var(--bg-surface2);
  border: none; border-right: 1px solid var(--border);
  padding: 4px 11px; font-size: 11.5px; font-weight: 500;
  color: var(--tx-muted); cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
  line-height: 1.5;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--bg-hover); color: var(--tx-primary); }
.seg-btn.active { background: var(--accent); color: #fff; font-weight: 600; }

/* Кнопка-пикер даты (компактная) */
.date-btn-sm {
  position: relative;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: var(--bg-surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 500;
  color: var(--tx-primary); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
  user-select: none;
}
.date-btn-sm i { font-size: 12px; color: var(--tx-muted); flex-shrink: 0; }
.date-btn-sm:hover { background: var(--bg-hover); border-color: var(--border-hover); }
.date-btn-sm input[type="date"] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  font-size: 1px; border: none; background: transparent; z-index: 2;
}
.date-btn-sm input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}

/* Дата-диапазон: «от — до» */
.date-range {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.date-range__sep { font-size: 12px; color: var(--tx-muted); }

/* ══════════════════════════════════════════════════════════════
   Sidebar flyout sub-menus
   .nav-has-sub — nav-item wrapper with a submenu
   .nav-sub     — the flyout panel (position:fixed, JS-positioned)
   .nav-sub-link — individual link inside the panel
══════════════════════════════════════════════════════════════ */
.nav-has-sub { position: relative; }
.nav-sub {
  position: fixed;
  display: none;
  flex-direction: column;
  gap: 1px;
  min-width: 196px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 5px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  z-index: 9999;
}
.nav-sub-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--tx-main);
  text-decoration: none;
  transition: background var(--ease);
  white-space: nowrap;
}
.nav-sub-link i { font-size: 14px; color: var(--tx-muted); flex-shrink: 0; }
.nav-sub-link:hover { background: var(--bg-hover); }
.nav-sub-link:hover i { color: var(--tx-main); }
.nav-sub-link.active { color: var(--accent); font-weight: 500; }
.nav-sub-link.active i { color: var(--accent); }
.nav-sub-sep {
  height: 1px; background: var(--border);
  margin: 3px 6px;
}
.nav-link__arr {
  margin-left: auto;
  font-size: 11px;
  opacity: .4;
  flex-shrink: 0;
  transition: opacity var(--ease);
}
.nav-has-sub:hover .nav-link__arr { opacity: .85; }

/* ══════════════════════════════════════════════════════════════
   Section tab navigation (Эффективность РК, Габариты)
   Place inside .cbar or below breadcrumb/title row.
══════════════════════════════════════════════════════════════ */
.section-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}
.section-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 400;
  color: var(--tx-muted);
  text-decoration: none;
  transition: background var(--ease), color var(--ease);
  white-space: nowrap;
  line-height: 1.4;
}
.section-tab i { font-size: 13px; opacity: .75; }
.section-tab:hover { background: var(--bg-hover); color: var(--tx-primary); }
.section-tab:hover i { opacity: 1; }
.section-tab.active {
  background: rgba(99,91,255,.12);
  color: var(--accent);
  font-weight: 500;
}
.section-tab.active i { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   Campaign effectiveness — status badges
══════════════════════════════════════════════════════════════ */
.eff-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.eff-dot--good    { background: var(--green); }
.eff-dot--warn    { background: #f59e0b; }
.eff-dot--bad     { background: var(--red); }
.eff-dot--drain   { background: #ef4444; box-shadow: 0 0 0 2px rgba(239,68,68,.25); }
.eff-dot--unknown { background: var(--border); }

.eff-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 5px;
  border-radius: 20px;
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.eff-badge--good  { background: rgba(34,197,94,.12);  color: #16a34a; }
.eff-badge--warn  { background: rgba(245,158,11,.12); color: #b45309; }
.eff-badge--bad   { background: rgba(239,68,68,.10);  color: #dc2626; }
.eff-badge--drain { background: rgba(239,68,68,.14);  color: #dc2626; }
.eff-badge--unknown { background: var(--bg-surface2); color: var(--tx-muted); }

/* Row tinting by status */
.eff-row--bad   td { background: rgba(239,68,68,.04) !important; }
.eff-row--drain td { background: rgba(239,68,68,.07) !important; }
.eff-row--warn  td { background: rgba(245,158,11,.04) !important; }

/* Contribution progress bar */
.contrib-bar {
  display: flex; align-items: center; gap: 6px;
  min-width: 90px;
}
.contrib-bar__track {
  flex: 1; height: 5px;
  background: var(--bg-surface2);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}
.contrib-bar__fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}
.contrib-bar__fill--good  { background: var(--green); }
.contrib-bar__fill--warn  { background: #f59e0b; }
.contrib-bar__fill--bad   { background: var(--red); }
.contrib-bar__fill--drain { background: var(--red); }
.contrib-bar__fill--unknown { background: var(--tx-muted); }


/* ── Флаги артикула: галочки «Начёс» / «Вакуум» (как в Позтреке) ─────── */
.pz-flagbar { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pz-flag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px; min-height: 32px;
  border: 1px solid var(--border); background: var(--bg-surface2);
  font-size: 12.5px; white-space: nowrap; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.pz-flag input { accent-color: var(--accent); margin: 0; width: 16px; height: 16px; cursor: pointer; }
.pz-flag:hover { border-color: var(--accent); }
.pz-flag.on { border-color: var(--accent); color: var(--accent); font-weight: 600;
  background: color-mix(in srgb, var(--accent) 8%, transparent); }
.pz-flag--vac input { accent-color: #0891b2; }
.pz-flag--vac:hover { border-color: #0891b2; }
.pz-flag--vac.on { border-color: #0891b2; color: #0e7490;
  background: color-mix(in srgb, #0891b2 9%, transparent); }
/* Телефон (склад): крупнее зона нажатия, галочки на всю ширину панели в 2 колонки */
@media (max-width: 640px) {
  .pz-flagbar { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .pz-flag { min-height: 40px; justify-content: flex-start; }
}
