:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e6eaf2;

  --sidebar: #263245;
  --sidebar-2: #1f2937;
  --sidebar-text: #e5e7eb;
  --sidebar-muted: rgba(229, 231, 235, 0.72);

  --accent: #6d5efc;
  --accent-2: #60a5fa;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  min-width: 0;
}

.content,
.content-inner {
  min-width: 0;
  max-width: 100%;
}

/* ПК (≥981px): сайдбар слева, бургер и backdrop скрыты */
@media (min-width: 61.3125rem) {
  .mobile-header,
  .sidebar-backdrop {
    display: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    clip-path: inset(100%) !important;
    left: -9999px !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  .sidebar { grid-row: 1; grid-column: 1; }
  .content { grid-row: 1; grid-column: 2; }
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header { padding: 6px 8px 14px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--sidebar-text);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: rgba(109, 94, 252, 0.18);
  border: 1px solid rgba(109, 94, 252, 0.35);
}

.brand-title { display: block; font-weight: 700; font-size: 14px; }
.brand-subtitle { display: block; font-size: 12px; color: var(--sidebar-muted); margin-top: 2px; }

.sidebar-nav {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--sidebar-muted);
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--sidebar-text);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(109, 94, 252, 0.22);
  color: #ffffff;
  border: 1px solid rgba(109, 94, 252, 0.35);
}

.nav-ico {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
}

.nav-ico svg { width: 20px; height: 20px; display: block; }

.sidebar-footer {
  padding: 10px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-user {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: rgba(96, 165, 250, 0.2);
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.sidebar-user-name { font-size: 13px; font-weight: 650; }
.sidebar-user-role { font-size: 12px; color: var(--sidebar-muted); }

.nav-item-logout { color: rgba(255,255,255,0.8); }
.nav-item-logout:hover { background: rgba(248, 113, 113, 0.18); border: 1px solid rgba(248, 113, 113, 0.25); }

/* Mobile header (hidden on desktop) */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.hamburger {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-shrink: 0;
}

.hamburger:hover {
  background: rgba(255,255,255,0.1);
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.mobile-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--sidebar-text);
  text-decoration: none;
}

.mobile-brand:hover {
  text-decoration: none;
  color: var(--sidebar-text);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.content {
  padding: 22px 26px;
}

.content-inner {
  max-width: none;
  width: 100%;
  margin: 0;
}

/* Sidebar groups (collapsible) */
.nav-group {
  border-radius: 14px;
  overflow: hidden;
}

.nav-group + .nav-group {
  margin-top: 10px;
}

.nav-group > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-group > summary::-webkit-details-marker {
  display: none;
}

.nav-group > summary:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(229, 231, 235, 0.78);
}

.nav-group-caret {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  opacity: 0.8;
  transition: transform 0.15s ease;
}

.nav-group[open] > summary .nav-group-caret {
  transform: rotate(180deg);
}

.nav-group-items {
  padding: 6px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-group .nav-item {
  margin: 0 6px;
}

/* Header */
.page-top {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.page-title-ico {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(109, 94, 252, 0.12);
  border: 1px solid rgba(109, 94, 252, 0.28);
  color: var(--accent);
}

.page-title-ico svg { width: 18px; height: 18px; }

.page-title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.page-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* User detail: карточка с данными */
.user-detail-card {
  margin-bottom: 16px;
}

.user-detail-body {
  padding: 20px 22px;
}

.user-detail-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 32px;
  margin: 0;
  font-size: 14px;
}

.user-detail-dl-row {
  display: contents;
}

.user-detail-dl-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  min-width: 140px;
}

.user-detail-dl-row dd {
  margin: 0;
  color: var(--text);
}

.user-detail-dl-row dd code {
  font-size: 13px;
  word-break: break-all;
}

.page-title-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.page-title-meta code {
  font-size: 12px;
}

.inline-form {
  display: inline-flex;
  align-items: center;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.withdrawals-controls,
.payments-controls,
.users-controls {
  flex-wrap: wrap;
  gap: 12px;
}
.withdrawals-controls .ctrl input[type="date"],
.payments-controls .ctrl input[type="date"],
.users-controls .ctrl input[type="date"] {
  min-width: 0;
}

.period-label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
}
.period-label strong {
  color: var(--text);
  font-weight: 700;
}
.period-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.period-tab {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.period-tab:hover {
  background: #eef2f9;
  color: var(--text);
  border-color: rgba(109, 94, 252, 0.25);
}

.period-tab.active {
  color: #fff;
  background: linear-gradient(90deg, var(--accent) 0%, #7c3aed 100%);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(109, 94, 252, 0.3);
  font-weight: 700;
  outline: 2px solid rgba(109, 94, 252, 0.5);
  outline-offset: 2px;
}

.period-tab.active:hover {
  filter: brightness(1.05);
  color: #fff;
}

.controls-period { flex-wrap: wrap; gap: 12px; align-items: center; }
.users-period-wrap,
.payments-period-wrap { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.period-custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-custom-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.period-custom-text { white-space: nowrap; }
.period-custom-date { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; background: var(--surface-2); }

.ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.ctrl input {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--text);
}

.ctrl-with-clear { position: relative; }
.ctrl-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 2px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  flex-shrink: 0;
}
.ctrl-clear:hover {
  background: var(--border);
  color: var(--text);
}

/* Safari-friendly select styling */
.ctrl select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  outline: none;
  background-color: transparent;
  font: inherit;
  color: var(--text);
  padding-right: 28px; /* room for arrow */
  min-width: 180px;
  line-height: 1.2;
  /* Most compatible custom arrow (Atlas/Safari/Chrome/FF) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%2364748b' d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}

/* Hide native arrow in old Edge/IE (harmless elsewhere) */
.ctrl select::-ms-expand { display: none; }

.ctrl select:focus-visible {
  outline: 2px solid rgba(109, 94, 252, 0.35);
  outline-offset: 2px;
}

/* Safari-friendly select styling */
.ctrl select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--text);
  padding-right: 28px; /* room for arrow */
  min-width: 180px;
  line-height: 1.2;
}

/* Custom arrow (Safari/Chrome/Firefox) */
.ctrl:has(select) {
  position: relative;
}
.ctrl:has(select)::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.7;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='black' d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Fallback if :has() unsupported */
@supports not selector(:has(*)) {
  .ctrl select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%2364748b' d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px 12px;
  }
}

/* Hide native arrow in old Edge/IE (harmless elsewhere) */
.ctrl select::-ms-expand { display: none; }

.ctrl select:focus-visible {
  outline: 2px solid rgba(109, 94, 252, 0.35);
  outline-offset: 2px;
}

.filter-multi {
  position: relative;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.filter-main {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.filter-label {
  font-size: 12px;
  color: var(--muted);
}

.filter-input-wrap {
  flex: 1;
}

.filter-input {
  width: 100%;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5edff;
  border: 1px solid #c7d2fe;
  font-size: 11px;
  color: #1e293b;
}

.filter-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
  padding: 6px 0;
  z-index: 20;
  display: none;
}

.filter-dropdown.is-open {
  display: block;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.filter-option input {
  flex-shrink: 0;
}

.filter-option:hover {
  background: #f8fafc;
}

.filter-empty {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 650;
  color: #fff;
  background: linear-gradient(90deg, var(--accent) 0%, #7c3aed 100%);
  box-shadow: 0 10px 20px rgba(109, 94, 252, 0.22);
}

.btn:hover { filter: brightness(1.03); }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px;
}

.card-gap {
  margin-top: 16px;
}

.card.card-span-6 { grid-column: span 6; }
.card.card-span-3 { grid-column: span 3; }
.card.card-span-4 { grid-column: span 4; }

.card-topline {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  margin: -14px -14px 12px;
}

.kpi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.kpi-left { display: flex; align-items: center; gap: 10px; }

.kpi-badge {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.25);
  color: #2563eb;
}

.kpi-badge.purple {
  background: rgba(109, 94, 252, 0.12);
  border-color: rgba(109, 94, 252, 0.25);
  color: var(--accent);
}

.kpi-badge svg { width: 18px; height: 18px; }

.kpi-title { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 750; margin-top: 2px; letter-spacing: -0.02em; }

.kpi-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

/* Chart placeholder */
.chart {
  overflow: hidden;
  padding: 0;
}

.chart + .chart-row {
  margin-top: 16px;
}

.chart-row {
  display: flex;
  gap: 12px;
  padding: 0;
}

.chart-row-main,
.chart-row-side {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.chart-row-main {
  flex: 2;
  border-right: 1px solid var(--border);
}

.chart-row-side {
  flex: 1;
}

.chart-head {
  padding: 14px;
  background: linear-gradient(90deg, #5b6cfb 0%, #7c3aed 100%);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Broadcast page */
.broadcast {
  width: 100%;
}

.broadcast-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-top: 20px;
}

.broadcast-section + .broadcast-section {
  margin-top: 14px;
}

.broadcast-title {
  font-weight: 800;
  font-size: 20px;
  margin: 0;
}

.broadcast-subtitle {
  margin: 6px 0 20px 0;
  color: var(--muted);
  font-size: 13px;
}

.broadcast-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid #eef2f7;
}

.broadcast-section-head h2 {
  margin: 0;
  font-weight: 800;
  font-size: 20px;
}

.broadcast-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 900px) {
  .broadcast-grid-2 { grid-template-columns: 1fr; }
}

.broadcast-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 900px) {
  .broadcast-form-grid { grid-template-columns: 1fr; }
}

.broadcast-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  display: block;
}

.broadcast-divider {
  height: 1px;
  background: #eef2f7;
  margin: 14px 0;
}

.broadcast-textarea {
  width: 100%;
  resize: vertical;
  min-height: 160px;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

.broadcast-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.broadcast-toolbar .toolbtn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
}

.broadcast-toolbar .toolbtn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.broadcast-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.broadcast-card {
  border: 1px solid #eef2f7;
  border-radius: 14px;
  padding: 16px;
  background: #fff;
}

.broadcast-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.broadcast-card-head h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

/* removed underline to match design */

.broadcast-item {
  border: 1px solid #eef2f7;
  border-radius: 12px;
  padding: 14px;
  background: #fafafa;
}

.broadcast-item + .broadcast-item { margin-top: 12px; }

.broadcast-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.broadcast-item-title {
  font-weight: 750;
}

.btn-danger {
  background: #ef4444;
  border: 1px solid #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  text-decoration: none;
}

.broadcast-actions {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid #eef2f7;
}

/* Broadcast dropdown with search */
.broadcast-dropdown {
  position: relative;
  display: inline-block;
  min-width: 200px;
  max-width: 320px;
}
.broadcast-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 42px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}
.broadcast-dropdown-trigger:hover {
  border-color: #c4b5fd;
}
.broadcast-dropdown-trigger-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.broadcast-dropdown-trigger-caret {
  flex-shrink: 0;
  margin-left: 8px;
  font-size: 10px;
  opacity: 0.7;
}
.broadcast-dropdown-panel {
  display: none;
  position: absolute;
  z-index: 100;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  max-height: 280px;
  flex-direction: column;
}
.broadcast-dropdown.is-open .broadcast-dropdown-panel {
  display: flex;
}
.broadcast-dropdown-search {
  width: 100%;
  height: 36px;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
}
.broadcast-dropdown-search:focus {
  outline: 2px solid rgba(109, 94, 252, 0.35);
  outline-offset: 0;
}
.broadcast-dropdown-list {
  overflow-y: auto;
  max-height: 220px;
}
.broadcast-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 6px;
}
.broadcast-dropdown-option:hover {
  background: #f3f4f6;
}
.broadcast-dropdown-option input[type="checkbox"],
.broadcast-dropdown-option input[type="radio"] {
  width: auto;
  height: auto;
  margin: 0;
  flex-shrink: 0;
}
.broadcast-dropdown-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.broadcast-dropdown-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.broadcast-badge-test {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  border-radius: 6px;
}

.broadcast-utm-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 8px;
}
.broadcast-utm-cb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}
.broadcast-utm-cb input { width: auto; height: auto; }
.broadcast-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.broadcast-checkbox-wrap input { width: auto; height: auto; }
.broadcast-label-check { display: block; margin-bottom: 4px; }
.broadcast-label-hint {
  font-size: 12px;
  font-weight: normal;
  color: var(--muted, #64748b);
}

/* Broadcast form controls (Atlas/Safari compatible) */
.broadcast select,
.broadcast input[type="text"],
.broadcast input[type="number"],
.broadcast input[type="date"],
.broadcast input[type="datetime-local"],
.broadcast input[type="time"] {
  width: 100%;
  height: 42px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--text);
  box-sizing: border-box;
}

.broadcast input[type="date"],
.broadcast input[type="datetime-local"],
.broadcast input[type="time"] {
  min-width: 140px;
  max-width: 200px;
  cursor: pointer;
}

.broadcast input[type="date"]::-webkit-calendar-picker-indicator,
.broadcast input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.broadcast input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
}

.broadcast select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 34px; /* arrow space */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%2364748b' d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
}

.broadcast select::-ms-expand { display: none; }

.broadcast select:focus-visible,
.broadcast input[type="text"]:focus-visible,
.broadcast input[type="number"]:focus-visible,
.broadcast input[type="date"]:focus-visible,
.broadcast input[type="datetime-local"]:focus-visible,
.broadcast input[type="time"]:focus-visible,
.broadcast textarea:focus-visible {
  outline: 2px solid rgba(109, 94, 252, 0.35);
  outline-offset: 2px;
}

.chart-head-inner {
  border-radius: var(--radius) var(--radius) 0 0;
}

.chart-head-title { font-weight: 750; }
.chart-head-sub { font-size: 12px; opacity: 0.9; margin-top: 4px; }

.chart-head-with-period {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chart-head-with-period .chart-head-left { flex-shrink: 0; }
.chart-head-with-period .chart-head-period { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.chart-head-with-period .chart-head-period .period-label { color: rgba(255,255,255,0.95); }
.chart-head-with-period .chart-head-period .period-label strong { color: #fff; }
.chart-head-with-period .chart-head-period .period-tab {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
}
.chart-head-with-period .chart-head-period .period-tab:hover {
  background: rgba(255,255,255,0.3);
  color: #fff;
}
.chart-head-with-period .chart-head-period .period-tab.active {
  color: #5b6cfb;
  background: #fff;
  border-color: transparent;
}
.chart-head-with-period .chart-head-period .period-tab.active:hover { color: #5b6cfb; background: #fff; }
.chart-head-with-period .chart-head-period .period-custom-date {
  background: rgba(255,255,255,0.95);
  border-color: rgba(255,255,255,0.5);
  color: var(--text);
}
.chart-head-with-period .chart-head-period .period-custom-text { color: rgba(255,255,255,0.9); }
.chart-head-with-period .chart-head-period .btn { background: rgba(255,255,255,0.95); color: #5b6cfb; border: none; }
.chart-head-with-period .chart-head-period .btn:hover { background: #fff; }
.chart-head-with-period .chart-head-period .btn-secondary { background: rgba(255,255,255,0.25); color: #fff; }
.chart-head-with-period .chart-head-period .btn-secondary:hover { background: rgba(255,255,255,0.4); }

.chart-body {
  background: #fff;
  padding: 14px;
}

.chart-body-inner {
  border-radius: 0 0 var(--radius) var(--radius);
}

.chart-canvas-wrap {
  height: 260px;
  position: relative;
}

.chart-canvas-wrap-sm {
  height: 220px;
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
  margin-bottom: 4px;
}

.table-title {
  margin: 0;
  padding: 12px 14px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.table-sub {
  color: var(--muted);
  font-size: 12px;
  margin: 0 14px 8px;
}

.table-wrap-full {
  width: 100%;
  margin-top: 18px;
  padding-left: 14px;
  padding-right: 14px;
  box-sizing: border-box;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  padding: 12px 14px;
  background: #f7f9ff;
  color: var(--muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.data-table .th-sort .th-sort-link {
  color: var(--muted);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.data-table .th-sort .th-sort-link:hover { color: var(--accent); text-decoration: none; }
.data-table .th-sort-arrow { font-size: 12px; opacity: 0.9; }

.data-table .th-filter {
  white-space: nowrap;
}
.data-table .th-filter .th-select {
  display: block;
  margin-top: 4px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 0;
  width: 100%;
  max-width: 120px;
}
.data-table .th-filter .th-select:hover,
.data-table .th-filter .th-select:focus {
  border-color: var(--accent);
  outline: none;
}

.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover td {
  background: #fbfcff;
}

.user-created-cell {
  white-space: nowrap;
  line-height: 1.35;
}
.user-created-cell .user-created-date,
.user-created-cell .user-created-time {
  display: block;
  white-space: nowrap;
}
.user-created-cell .user-created-time {
  font-size: 0.9em;
  color: var(--muted);
}

.data-table code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: #f1f5ff;
  color: #334155;
  border: 1px solid #e2e8ff;
  padding: 2px 6px;
  border-radius: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f1f5ff;
  border: 1px solid #e2e8ff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge--pending {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
}
.status-badge--paid {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
  box-shadow: none;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.pagination {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.pagination-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination-info {
  font-size: 12px;
  color: var(--muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 460px;
  max-width: calc(100% - 32px);
  border: 1px solid var(--border);
}

.broadcast-modal-large {
  width: 720px;
  max-width: calc(100% - 32px);
}

.broadcast-modal-large .modal-body {
  max-height: 75vh;
  overflow-y: auto;
}

.modal-backdrop {
  backdrop-filter: blur(4px);
}

.modal {
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-title {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text);
}

.modal-close {
  border: none;
  background: transparent;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
}

.modal-body {
  padding: 20px 20px 24px;
}

/* Admin form modal (create/edit admin) */
.admin-form-modal .modal {
  width: 480px;
  max-width: calc(100% - 32px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.admin-form-modal .modal-body {
  padding: 24px 24px 28px;
  max-height: calc(90vh - 60px);
  overflow-y: auto;
  flex: 1 1 auto;
}

.admin-form-modal .form-error {
  margin-bottom: 20px;
  padding: 12px 14px;
  background: rgba(185, 28, 28, 0.06);
  border: 1px solid rgba(185, 28, 28, 0.2);
  border-radius: 12px;
  font-size: 13px;
  color: #b91c1c;
}

.admin-form-modal .form-group {
  margin-bottom: 20px;
}

.admin-form-modal .form-group:last-of-type {
  margin-bottom: 0;
}

.admin-form-modal .form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.admin-form-modal .form-label .form-label-hint {
  font-weight: 400;
  color: var(--muted);
}

.admin-form-modal .form-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-form-modal .form-input:focus {
  outline: none;
  border-color: rgba(109, 94, 252, 0.5);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.12);
}

.admin-form-modal .form-input::placeholder {
  color: var(--muted);
}

.admin-form-modal .form-input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
}

.admin-form-modal .form-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  margin-bottom: 20px;
}

.admin-form-modal .form-check input {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.admin-form-modal .form-check span {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.admin-form-modal .form-perms-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.admin-form-modal .form-perms-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.admin-form-modal .form-perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.admin-form-modal .form-perm-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.admin-form-modal .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.admin-form-modal .form-actions .btn {
  min-width: 100px;
}

/* Settings page form (same form styles as modal) */
.settings-form .form-group {
  margin-bottom: 20px;
}
.settings-form .form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.settings-form .form-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.settings-form .form-input:focus {
  outline: none;
  border-color: rgba(109, 94, 252, 0.5);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.12);
}
.settings-form .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Parser log filters */
.parser-log-filters {
  padding: 20px 24px;
}
.parser-log-filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 24px;
  align-items: flex-end;
}
.parser-log-filters-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.parser-log-filters-field:first-child {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
}
.parser-log-filters-field:nth-child(2) { width: 160px; }
.parser-log-filters-field:nth-child(3) { width: 220px; }
.parser-log-filters-field:nth-child(4) { width: 160px; }
.parser-log-filters-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.parser-log-filters-input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.parser-log-filters-input:focus {
  outline: none;
  border-color: rgba(109, 94, 252, 0.5);
  box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.12);
}
.parser-log-filters-input::placeholder {
  color: var(--muted);
}
select.parser-log-filters-input {
  cursor: pointer;
}
.parser-log-filters-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.modal-footer {
  padding: 10px 14px 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 20% 10%, rgba(109,94,252,0.18), transparent 60%),
              radial-gradient(900px 500px at 80% 40%, rgba(96,165,250,0.18), transparent 60%),
              var(--bg);
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-box h1 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.login-subtitle { margin: 6px 0 16px; color: var(--muted); font-size: 13px; }

.login-form label { display: block; margin-bottom: 12px; }
.login-form label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.login-form input {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.login-form input:focus {
  border-color: rgba(109, 94, 252, 0.55);
  box-shadow: 0 0 0 4px rgba(109, 94, 252, 0.12);
}

.login-form button {
  width: 100%;
  margin-top: 8px;
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 750;
  color: #fff;
  background: linear-gradient(90deg, var(--accent) 0%, #7c3aed 100%);
  cursor: pointer;
}

.error {
  color: #b91c1c;
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.25);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  margin: 0 0 12px;
}

/* ========== Responsive: до 980px — бургер + полноэкранное меню (rem = учёт zoom) ========== */
@media (max-width: 61.25rem) {
  .app {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: unset !important;
    min-height: 100vh;
  }
  .mobile-header {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 11;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: var(--sidebar-text);
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .sidebar-backdrop {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 98;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .app.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.sidebar-open { overflow: hidden; }
  .sidebar {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 12px 10px;
    padding-top: max(12px, env(safe-area-inset-top));
    box-shadow: none;
    grid-row: unset !important;
    grid-column: unset !important;
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .content {
    flex: 1;
    padding: 14px 12px;
    min-width: 0;
    grid-row: unset !important;
    grid-column: unset !important;
  }
  .sidebar-header { padding: 4px 0 10px; }
  .brand-title { font-size: 13px; }
  .brand-subtitle { font-size: 11px; }
  .nav-group > summary { padding: 8px 10px; }
  .nav-group-title { font-size: 11px; }
  .nav-item { padding: 8px 10px; font-size: 12px; }
  .page-top { flex-direction: column; align-items: stretch; padding: 14px 12px; gap: 12px; }
  .page-title h1 { font-size: 1.25rem; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card.card-span-6, .card.card-span-3, .card.card-span-4 { grid-column: span 1; }
  .table-two-col { grid-template-columns: 1fr; }
  .chart-row { flex-direction: column; }
  .chart-row-main { border-right: none; border-bottom: 1px solid var(--border); }
}

@media (max-width: 48rem) {
  .content { padding: 12px 10px; }
  .page-top { padding: 12px 10px; }
  .card { padding: 12px 10px; }
  .chart-head, .chart-body-inner { padding: 12px 10px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 12px; min-width: 600px; }
  .data-table thead th, .data-table tbody td { padding: 10px 8px; }
  .controls { flex-wrap: wrap; gap: 8px; }
  .ctrl { min-width: 0; }
  .pagination-inner { flex-wrap: wrap; gap: 8px; justify-content: center; }
  .user-detail-body .controls, .inline-form { flex-wrap: wrap; }
}

@media (max-width: 30rem) {
  .sidebar { padding: 8px 10px; }
  .brand-mark { width: 32px; height: 32px; font-size: 12px; }
  .brand-title { font-size: 13px; }
  .content { padding: 10px 8px; }
  .page-top { padding: 10px 8px; margin-bottom: 12px; }
  .page-title { flex-wrap: wrap; gap: 8px; }
  .page-title-ico { width: 28px; height: 28px; }
  .page-title-ico svg { width: 16px; height: 16px; }
  .page-title h1 { font-size: 1.1rem; }
  .card { padding: 10px 8px; }
  .chart-head, .chart-body-inner { padding: 10px 8px; }
  .chart-head-title { font-size: 14px; }
  .data-table { font-size: 11px; min-width: 500px; }
  .data-table thead th, .data-table tbody td { padding: 8px 6px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .kpi-value { font-size: 18px; }
  .user-detail-card .controls { flex-direction: column; align-items: stretch; }
}
tion: column; align-items: stretch; }
}
