*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- MULTI-SELECT DROPDOWN ---- */
.multi-select-wrap { position: relative; flex: 1; }
.multi-select-trigger {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; user-select: none; color: var(--text);
}
.multi-select-trigger:hover { border-color: var(--accent); }
.multi-select-arrow { color: var(--muted); font-size: 16px; transition: transform .15s; }
.multi-select-wrap.open .multi-select-arrow { transform: rotate(180deg); }
.multi-select-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 300;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px; max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px #0006;
}
.multi-select-panel label {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  cursor: pointer; border-radius: 4px; color: var(--text);
}
.multi-select-panel label:hover { background: var(--bg3); }
.multi-select-panel label input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.multi-select-count { font-size: 12px; color: var(--muted); }

:root {
  --bg:        #0f172a;
  --bg2:       #1e293b;
  --bg3:       #334155;
  --border:    #334155;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --success:   #22c55e;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --radius:    8px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ---- UTILITY ---- */
.hidden { display: none !important; }
.muted  { color: var(--muted); font-size: 13px; }
.error-msg { color: var(--danger); font-size: 13px; padding: 6px 0; }

/* ---- LOGIN ---- */
.login-screen {
  display: flex; align-items: center; justify-content: center; height: 100vh;
  background: var(--bg);
}
.login-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 40px 32px; width: 360px;
}
.login-box h2 { font-size: 24px; margin-bottom: 24px; text-align: center; color: var(--accent); }

/* ---- APP LAYOUT ---- */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 200px; flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-logo { padding: 20px 16px; font-size: 20px; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--border); }
.sidebar-menu { list-style: none; padding: 8px 0; flex: 1; overflow-y: auto; }
.sidebar-menu li {
  padding: 10px 16px; cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted); transition: background .15s, color .15s;
}
.sidebar-menu li:hover { background: var(--bg3); color: var(--text); }
.sidebar-menu li.active { background: var(--accent); color: #fff; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.main-content { flex: 1; overflow-y: auto; padding: 24px 32px; }

/* ---- SECTIONS ---- */
.section h1 { font-size: 22px; margin-bottom: 20px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.section-header h1 { margin-bottom: 0; }

/* ---- STATS GRID ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 16px; }
.stat-card .stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- CHART ---- */
.chart-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-box h3 { margin-bottom: 16px; color: var(--muted); font-size: 14px; font-weight: 500; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th { background: var(--bg2); color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }
.data-table tbody tr:hover { background: var(--bg2); }

/* ---- CARDS ---- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.card-meta  { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }
.card-stat { font-size: 24px; font-weight: 700; color: var(--accent); }

/* ---- BUTTONS ---- */
.btn { padding: 7px 14px; border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; transition: background .15s; }
.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--bg3);  color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }
.actions { display: flex; gap: 8px; align-items: center; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 12px; }
.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.form-row label { width: 160px; flex-shrink: 0; color: var(--muted); }
.form-row-inline { gap: 20px; }
input, select, textarea {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 7px 10px; border-radius: var(--radius); font-size: 13px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
select[multiple] { height: auto; min-height: 80px; }
.input-sm { width: 220px; }
.filters-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.filters-row select, .filters-row input { width: auto; }

/* ---- QUICK FILTERS (папки) ---- */
.quick-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.quick-filter {
  padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--muted); cursor: pointer; font-size: 13px;
  transition: all .15s;
}
.quick-filter:hover { border-color: var(--accent); color: var(--text); }
.quick-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.quick-filter.unsub.active { background: var(--danger); border-color: var(--danger); }

/* ---- PAGINATION ---- */
.pagination { display: flex; gap: 6px; margin-top: 12px; align-items: center; }
.pagination button { padding: 4px 10px; }
.pagination .page-info { color: var(--muted); font-size: 13px; }

/* ---- BULK BAR ---- */
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg2); border-radius: var(--radius); margin-top: 8px; }

/* ---- STATUS BADGES ---- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-active   { background: #16532c; color: #86efac; }
.badge-unsub    { background: #1e293b; color: var(--muted); }
.badge-bounce   { background: #450a0a; color: #fca5a5; }
.badge-sending  { background: #1e3a5f; color: #93c5fd; }
.badge-sent     { background: #16532c; color: #86efac; }
.badge-draft    { background: #1e293b; color: var(--muted); }
.badge-paused   { background: #451a03; color: #fdba74; }
.badge-error    { background: #450a0a; color: #fca5a5; }
.badge-success  { background: #16532c; color: #86efac; }
.badge-running  { background: #1e3a5f; color: #93c5fd; }

/* ---- MODALS ---- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px; width: 460px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
}
.modal-box-wide { width: 680px; }
.modal-box h3 { margin-bottom: 20px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---- POWERMTA ---- */
.pmta-controls { display: flex; gap: 10px; margin-bottom: 16px; }
.code-output { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; font-family: monospace; font-size: 12px; color: var(--muted); white-space: pre-wrap; min-height: 200px; max-height: 500px; overflow-y: auto; }

/* ---- SETTINGS ---- */
.settings-form fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.settings-form legend { padding: 0 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; }

/* ---- WARMUP CARD ---- */
.warmup-progress { background: var(--bg3); border-radius: 4px; height: 8px; margin: 8px 0; overflow: hidden; }
.warmup-progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s; }
.warmup-phase-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; margin-bottom: 6px; }
.warmup-stats { display: flex; gap: 16px; margin: 8px 0; font-size: 12px; color: var(--muted); }
.warmup-stats b { color: var(--text); }

/* ---- WARMUP DOCS ---- */
.warmup-docs { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.warmup-docs-header { padding: 12px 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 500; user-select: none; }
.warmup-docs-header:hover { color: var(--accent); }
.warmup-docs-body { padding: 0 16px 16px; }
.warmup-tabs { display: flex; gap: 0; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.warmup-tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 16px; cursor: pointer; font-size: 13px; margin-bottom: -1px; transition: color .15s; }
.warmup-tab:hover { color: var(--text); }
.warmup-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.warmup-doc-section h4 { color: var(--text); margin: 14px 0 6px; font-size: 13px; }
.warmup-doc-section p { color: var(--muted); font-size: 13px; line-height: 1.6; margin-bottom: 8px; }
.warmup-doc-section ul { padding-left: 18px; margin: 0 0 8px; }
.warmup-doc-section ul li { color: var(--muted); font-size: 13px; line-height: 1.8; }
.warmup-doc-section ul li b { color: var(--text); }
.warmup-phases-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.warmup-phase-item { padding: 8px 12px; border-radius: 6px; border-left: 3px solid; background: var(--bg3); }
.warmup-phase-item .phase-name { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.warmup-phase-item .phase-days { font-size: 11px; color: var(--muted); }
.warmup-phase-item .phase-desc { font-size: 12px; color: var(--muted); margin-top: 4px; }
.wu-preview { background: var(--bg3); border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; font-size: 12px; color: var(--muted); min-height: 40px; }
.wu-preview b { color: var(--text); }

/* ---- TABS ---- */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 18px; cursor: pointer; font-size: 13px; margin-bottom: -1px; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel.hidden { display: none !important; }

/* ---- HTML EDITOR ---- */
.editor-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; background: var(--bg3); border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; padding: 6px 8px; }
.editor-toolbar button { background: transparent; border: 1px solid transparent; color: var(--text); padding: 3px 8px; cursor: pointer; border-radius: 4px; font-size: 13px; line-height: 1; }
.editor-toolbar button:hover { background: var(--bg2); border-color: var(--border); }
.editor-toolbar .tb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.editor-toolbar select { width: auto; padding: 3px 6px; font-size: 12px; flex-shrink: 0; }
.html-editor { min-height: 260px; max-height: 400px; overflow-y: auto; background: #fff; color: #111; border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 12px; font-size: 14px; line-height: 1.6; }
.html-editor:focus { outline: none; border-color: var(--accent); }
.html-source { font-family: monospace; font-size: 12px; background: #0a0f1e; color: #a3e635; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); min-height: 260px; resize: vertical; }

/* ---- SEGMENTER ---- */
.segment-match { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; font-size: 13px; }
.segment-match label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.seg-condition { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; background: var(--bg3); border-radius: var(--radius); padding: 8px; flex-wrap: wrap; }
.seg-condition select { width: auto; flex: 1; min-width: 190px; }
.seg-condition input, .seg-condition .seg-val-sel { flex: 1; min-width: 140px; width: auto; }
.btn-remove { flex-shrink: 0; background: var(--danger); color: #fff; border: none; border-radius: var(--radius); padding: 4px 10px; cursor: pointer; font-size: 13px; }
.segment-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

/* ---- MODAL XL ---- */
.modal-box-xl { width: 920px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { margin-bottom: 0; font-size: 18px; }
.btn-close { background: transparent; border: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 0; line-height: 1; }
.btn-close:hover { color: var(--text); }

/* ---- TEST EMAIL POPUP ---- */
.test-email-bar { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding: 10px; background: var(--bg3); border-radius: var(--radius); }
.test-email-bar input { flex: 1; }

