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

/* ═══════════════════════════════════
   CSS ЗМІННІ — ТЕМНА ТЕМА (default)
═══════════════════════════════════ */
:root {
  --bg:       #0D0F12;
  --bg2:      #161A1F;
  --bg3:      #1E2521;
  --bg4:      #242B28;
  --accent:   #00E676;
  --accent2:  #0A4A2A;
  --accent3:  rgba(0, 230, 118, 0.12);
  --text:     #E0E0E0;
  --text2:    #8A9BA8;
  --text3:    #4A5A54;
  --border:   #2A3530;
  --border2:  #1E2820;
  --red:      #FF5252;
  --red-bg:   rgba(255, 82, 82, 0.1);
  --yellow:   #FFD740;
  --yellow-bg:rgba(255, 215, 64, 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --sidebar-w: 220px;
  --topbar-h:  60px;
  --transition: 0.15s ease;
}

/* ═══════════════════════════════════
   СВІТЛА ТЕМА
═══════════════════════════════════ */
[data-theme="light"] {
  --bg:       #F0F4F2;
  --bg2:      #FFFFFF;
  --bg3:      #EAF5EF;
  --bg4:      #DFF0E8;
  --accent:   #00A854;
  --accent2:  #CCF0DC;
  --accent3:  rgba(0, 168, 84, 0.1);
  --text:     #0D1F17;
  --text2:    #4A7A62;
  --text3:    #9AB8A8;
  --border:   #D0E8DC;
  --border2:  #E4F2EA;
  --red:      #C62828;
  --red-bg:   rgba(198, 40, 40, 0.08);
  --yellow:   #E65100;
  --yellow-bg:rgba(230, 81, 0, 0.08);
}

/* ═══════════════════════════════════
   RESET + BASE
═══════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ═══════════════════════════════════
   LAYOUT
═══════════════════════════════════ */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════
   SIDEBAR
═══════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--accent3);
  border: 1px solid var(--accent2);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-text { font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-logo-sub  { font-size: 10px; color: var(--text2); margin-top: 1px; }

.nav { padding: 12px 8px; flex: 1; }
.nav-section {
  font-size: 10px; font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--text2);
  font-size: 13px; font-weight: 500;
  margin-bottom: 1px;
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: var(--accent3);
  color: var(--accent);
  border-color: rgba(0, 230, 118, 0.15);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #0D0F12;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}

.sidebar-bottom {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-bottom-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: transparent; border: none;
  color: var(--text2); font-size: 12px;
  transition: background var(--transition), color var(--transition);
  width: 100%; text-align: left;
}
.sidebar-bottom-btn:hover { background: var(--bg3); color: var(--text); }
.sidebar-bottom-btn.logout:hover { color: var(--red); }
.sidebar-bottom-btn svg { width: 15px; height: 15px; }

/* ═══════════════════════════════════
   MAIN AREA
═══════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.topbar-left h1 { font-size: 17px; font-weight: 600; color: var(--text); }
.topbar-left p  { font-size: 12px; color: var(--text2); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

/* ═══════════════════════════════════
   STAT CARDS
═══════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.stat-card.primary { border-top: 2px solid var(--accent); }
.stat-label { font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-delta { font-size: 11px; margin-top: 8px; }
.delta-up   { color: var(--accent); }
.delta-down { color: var(--red); }
.delta-neutral { color: var(--text2); }

/* ═══════════════════════════════════
   CARDS / PANELS
═══════════════════════════════════ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.card-body  { padding: 16px 18px; }

/* ═══════════════════════════════════
   BADGES
═══════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-premium { background: var(--accent3); color: var(--accent); border: 1px solid rgba(0,230,118,0.25); }
.badge-free    { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.badge-active  { background: var(--accent3); color: var(--accent); }
.badge-blocked { background: var(--red-bg); color: var(--red); }
.badge-draft   { background: var(--yellow-bg); color: var(--yellow); }
.badge-sent    { background: var(--accent3); color: var(--accent); }
.badge-sending { background: var(--yellow-bg); color: var(--yellow); }

/* ═══════════════════════════════════
   BUTTONS
═══════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #0D0F12; }
.btn-primary:hover { background: #00FF88; }
.btn-ghost { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--text2); border-color: var(--border); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ═══════════════════════════════════
   ФОРМИ / INPUTS
═══════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent3);
}
.form-input::placeholder { color: var(--text3); }
.form-textarea { min-height: 100px; resize: vertical; }

/* ═══════════════════════════════════
   ТАБЛИЦЯ
═══════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg3); }
th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent3);
  border: 1px solid rgba(0,230,118,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.user-name  { font-weight: 500; font-size: 13px; }
.user-sub   { font-size: 11px; color: var(--text2); margin-top: 1px; }

.row-actions { display: flex; gap: 5px; }

/* ═══════════════════════════════════
   ФІЛЬТРИ
═══════════════════════════════════ */
.filters {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.filter-input, .filter-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  outline: none;
}
.filter-input:focus, .filter-select:focus { border-color: var(--accent); }
.filter-input::placeholder { color: var(--text3); }
.filters-right { margin-left: auto; display: flex; gap: 6px; }

/* ═══════════════════════════════════
   ПАГІНАЦІЯ
═══════════════════════════════════ */
.pagination {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.pagination-info { font-size: 12px; color: var(--text2); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover    { border-color: var(--accent); color: var(--accent); }
.page-btn.active   { background: var(--accent); color: #0D0F12; border-color: var(--accent); font-weight: 600; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ═══════════════════════════════════
   BAR CHARTS (CSS-based)
═══════════════════════════════════ */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row   { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--text2); width: 90px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.6s ease; }
.bar-value { font-size: 12px; color: var(--text); font-weight: 500; width: 36px; text-align: right; flex-shrink: 0; }

/* ═══════════════════════════════════
   ACTIVITY FEED
═══════════════════════════════════ */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border2);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.activity-text { flex: 1; font-size: 13px; color: var(--text); }
.activity-time { font-size: 11px; color: var(--text2); white-space: nowrap; }

/* ═══════════════════════════════════
   SEARCH BOX (topbar)
═══════════════════════════════════ */
.search-wrap { position: relative; }
.search-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 12px 7px 34px;
  font-size: 13px; color: var(--text);
  outline: none; width: 200px;
  transition: border-color var(--transition), width var(--transition);
}
.search-input:focus { border-color: var(--accent); width: 260px; }
.search-input::placeholder { color: var(--text3); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }

/* ═══════════════════════════════════
   ADMIN AVATAR
═══════════════════════════════════ */
.admin-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #0D0F12;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 2px solid var(--bg3);
}

/* ═══════════════════════════════════
   CONFIRM MODAL
═══════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 380px; max-width: 90vw;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.modal-text  { font-size: 13px; color: var(--text2); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ═══════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.login-theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text2);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 380px; max-width: 90vw;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.login-error {
  background: var(--red-bg);
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px; color: var(--red);
  margin-bottom: 16px;
}
.password-wrap { position: relative; }
.password-wrap .form-input { padding-right: 40px; }
.password-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text2); cursor: pointer;
  padding: 4px;
}
.login-btn { width: 100%; padding: 11px; font-size: 14px; font-weight: 600; }

/* ═══════════════════════════════════
   EMPTY STATE
═══════════════════════════════════ */
.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text2);
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

/* ═══════════════════════════════════
   ALERT / TOAST
═══════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--accent3); color: var(--accent); border: 1px solid rgba(0,230,118,0.2); }
.alert-error   { background: var(--red-bg); color: var(--red); border: 1px solid rgba(255,82,82,0.2); }

/* ═══════════════════════════════════
   RESPONSIVE
═══════════════════════════════════ */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { display: none; }
}

/* Broadcasts */
.badge-cancelled {
  background: var(--bg4);
  color: var(--text2);
  border: 1px solid var(--border);
}
.sending-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--yellow);
  animation: sending-pulse 1s ease-in-out infinite;
  vertical-align: middle;
  margin-right: 4px;
}
@keyframes sending-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}
.broadcast-progress {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.broadcast-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.broadcast-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.broadcast-stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.broadcast-stat-card .label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; }
.broadcast-stat-card .value { font-size: 20px; font-weight: 600; margin-top: 4px; }
.text-muted { color: var(--text2); font-size: 12px; }
.broadcast-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.form-step-title { font-weight: 600; margin: 20px 0 10px; color: var(--accent); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.radio-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; align-items: center; }
.radio-row label { cursor: pointer; display: flex; align-items: center; gap: 6px; }

/* Broadcast detail — metrics & logs */
.broadcast-detail-header-sub { max-width: 720px; }
.broadcast-metric-row-wrap { overflow-x: auto; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.broadcast-metric-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  min-width: min(100%, 520px);
}
@media (max-width: 720px) {
  .broadcast-metric-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .broadcast-metric-row { grid-template-columns: 1fr; }
}
.broadcast-metric-card {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  border: 1px solid transparent;
}
.broadcast-metric-card--primary {
  background: var(--accent3);
  border: 1px solid rgba(0, 230, 118, 0.2);
}
html[data-theme="light"] .broadcast-metric-card--primary {
  border-color: rgba(0, 168, 84, 0.22);
}
.broadcast-metric-card .metric-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.broadcast-metric-card .metric-label {
  font-size: 11px;
  color: var(--text2);
  margin-top: 5px;
}
.broadcast-metric-card .metric-val.metric-val--accent { color: var(--accent); }
.broadcast-metric-card .metric-val.metric-val--yellow { color: var(--yellow); }
.broadcast-metric-card .metric-val.metric-val--neutral { color: var(--text); }

.broadcast-msg-preview {
  background: var(--bg3);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  border-left: 3px solid var(--accent);
  margin-top: 8px;
  white-space: pre-wrap;
}

.broadcast-detail-kv { display: flex; flex-direction: column; gap: 4px; }
.broadcast-detail-kv-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.06em;
}
.broadcast-detail-kv-value { font-size: 13px; color: var(--text); line-height: 1.45; }

.log-status { display: inline-flex; align-items: center; font-size: 13px; color: var(--text); }
.log-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  flex-shrink: 0;
}
.log-status-dot--sent { background: #00e676; }
.log-status-dot--failed { background: #ff5252; }
.log-status-dot--blocked { background: #ffd740; }
.log-status-dot--clicked { background: #4fc3f7; }
.log-status-dot--muted { background: var(--text2); }
.log-error-cell { font-size: 12px; color: var(--text2); max-width: 280px; word-break: break-word; }

/* Stats / analytics */
.stats-metrics-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) {
  .stats-metrics-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .stats-metrics-row { grid-template-columns: repeat(2, 1fr); }
}
.stats-charts-row {
  min-width: 0;
}
@media (max-width: 900px) {
  .stats-charts-row { grid-template-columns: 1fr !important; }
}
