:root {
  --bg: #090b10;
  --bg-secondary: #10141d;
  --surface: rgba(20, 25, 36, 0.92);
  --surface-strong: rgba(15, 19, 28, 0.96);
  --line: rgba(154, 170, 201, 0.14);
  --text: #f4f7ff;
  --muted: #94a0ba;
  --accent: #68e1fd;
  --accent-2: #7d8cff;
  --danger: #ff6c8a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(104, 225, 253, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(125, 140, 255, 0.14), transparent 26%),
    linear-gradient(180deg, #090b10 0%, #0b0e14 38%, #090b10 100%);
}
body.modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button {
  border: 0;
  cursor: pointer;
  color: #071019;
  background: linear-gradient(135deg, var(--accent), #8eecff);
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 10px 30px rgba(104, 225, 253, 0.22);
}
button:hover { transform: translateY(-1px); }
.secondary-button {
  background: linear-gradient(135deg, rgba(125, 140, 255, 0.22), rgba(104, 225, 253, 0.18));
  color: var(--text);
  box-shadow: none;
  border: 1px solid rgba(125, 140, 255, 0.24);
}
.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.danger-button {
  background: linear-gradient(135deg, rgba(255, 108, 138, 0.94), rgba(255, 145, 99, 0.9));
  color: white;
  box-shadow: 0 10px 30px rgba(255, 108, 138, 0.18);
}
.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  font-size: 1.25rem;
  line-height: 1;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  box-shadow: none;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 13px 14px;
  border-radius: 14px;
  outline: none;
}
input::placeholder, textarea::placeholder { color: #73819c; }
.dashboard-shell {
  padding: 24px;
  max-width: 1680px;
  margin: 0 auto;
}
.panel-surface {
  background: linear-gradient(180deg, var(--surface), var(--surface-strong));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 24px;
  margin-bottom: 18px;
}
.topbar h1, .panel-header h2, .modal-header h2 { margin: 0; }
.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}
.subtle-copy, .helper-copy, .metric-card span, .activity-item p, small, .empty-state, .empty-table {
  color: var(--muted);
}
.top-actions, .button-row, .compact-row, .file-input-row, .panel-header, .spaced-header, .modal-header, .upload-box, .panel-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}
.top-actions, .upload-box { flex-wrap: wrap; justify-content: flex-end; }
.panel-tools { flex-wrap: wrap; justify-content: flex-end; }
.scheduler-chip {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 600;
}
.scheduler-chip.paused {
  color: #ffc873;
  border-color: rgba(255, 178, 77, 0.28);
  background: rgba(255, 178, 77, 0.08);
}
.scheduler-chip.running {
  color: #87ebff;
  border-color: rgba(104, 225, 253, 0.28);
  background: rgba(104, 225, 253, 0.08);
}
.scheduler-chip.idle { color: #b7c0d8; }
.tabs-bar {
  display: flex;
  gap: 10px;
  padding: 12px;
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab-button {
  min-width: 150px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  box-shadow: none;
}
.tab-button.active {
  background: linear-gradient(135deg, rgba(104, 225, 253, 0.18), rgba(125, 140, 255, 0.2));
  color: var(--text);
  border-color: rgba(104, 225, 253, 0.18);
}
.tab-view { display: block; }
.tab-view.hidden { display: none !important; }
.metrics-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}
.four-col-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card { padding: 18px; min-height: 132px; }
.metric-card p, .metric-card strong, .metric-card span { display: block; }
.metric-card p { margin: 0; color: var(--muted); }
.metric-card strong { margin: 10px 0 8px; font-size: 2.1rem; }
.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
}
.campaigns-grid, .logs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  gap: 18px;
}
.full-panel, .dominant-panel, .compact-panel { padding: 20px; }
.contacts-table-wrap { max-height: 560px; }
.tall-list { max-height: 420px; }
.medium-list { max-height: 260px; }
.table-wrap, .activity-list { overflow: auto; }
.panel-header, .modal-header, .spaced-header { justify-content: space-between; margin-bottom: 14px; }
.activity-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.activity-item strong { display: block; margin-bottom: 4px; }
.activity-item p, .helper-copy { margin: 0; line-height: 1.5; }
.activity-item:last-child { border-bottom: 0; }

.campaign-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.status-running {
  color: #8df5bf;
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.12);
}

.status-paused {
  color: #ffd27f;
  border-color: rgba(251, 191, 36, 0.26);
  background: rgba(251, 191, 36, 0.12);
}

.status-completed {
  color: #8fd4ff;
  border-color: rgba(59, 130, 246, 0.24);
  background: rgba(59, 130, 246, 0.12);
}

.status-idle {
  color: #c6d0e3;
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(148, 163, 184, 0.1);
}

.queue-item p:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.campaign-item { align-items: flex-start; }
.campaign-main {
  display: grid;
  gap: 10px;
  width: 100%;
}
.campaign-progress {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}
.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(104, 225, 253, 0.18);
  background: rgba(255, 255, 255, 0.05);
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 220ms ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
  color: var(--muted);
}
.button-stack { display: grid; gap: 8px; min-width: 110px; }
.file-input-row { flex: 1 1 420px; flex-wrap: wrap; }
#csvFileInput { display: none; }
.file-button, .file-name {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  border-radius: 14px;
}
.file-button {
  padding: 0 16px;
  background: rgba(125, 140, 255, 0.18);
  border: 1px solid rgba(125, 140, 255, 0.24);
  color: var(--text);
  cursor: pointer;
}
.file-name {
  flex: 1 1 220px;
  padding: 0 14px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255,255,255,0.04);
}
.stack-form { display: grid; gap: 12px; }
.field-block { display: grid; gap: 8px; }
.field-label { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.estimate-box { display: grid; gap: 6px; }
.estimate-box strong { font-size: 1.05rem; }
.two-column-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode-block { display: grid; gap: 12px; }
.throughput-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.result-box {
  min-height: 96px;
  margin: 16px 0 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(104, 225, 253, 0.16);
  background: rgba(104, 225, 253, 0.05);
  overflow: auto;
  color: #cfeeff;
}
.import-progress {
  margin: 16px 0 0;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.phase-label {
  font-size: 0.85rem;
  color: var(--accent);
}
.progress-pct {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.import-progress .progress-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(154, 170, 201, 0.14);
}
.import-progress .progress-fill {
  border-radius: 3px;
}
.import-log {
  margin: 12px 0 0;
  max-height: 220px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}
.import-log .log-line {
  white-space: nowrap;
}
.import-log .log-line.log-ok { color: #6ce9a6; }
.import-log .log-line.log-warn { color: #ffc66d; }
.import-log .log-line.log-err { color: var(--danger); }
.import-log .log-line.log-info { color: var(--accent); }
.table-wrap table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { position: sticky; top: 0; background: #111623; z-index: 1; }
.tier-pill, .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
}
.tier-a { background: rgba(39, 213, 154, 0.14); color: #57f0bb; }
.tier-b { background: rgba(125, 140, 255, 0.16); color: #aab2ff; }
.tier-c { background: rgba(255, 178, 77, 0.16); color: #ffc873; }
.tier-d { background: rgba(255, 108, 138, 0.16); color: #ff9db2; }
.status-pending { background: rgba(255, 178, 77, 0.16); color: #ffc873; }
.status-sending { background: rgba(104, 225, 253, 0.14); color: #87ebff; }
.status-failed { background: rgba(255, 108, 138, 0.16); color: #ff9db2; }
.status-sent { background: rgba(39, 213, 154, 0.14); color: #57f0bb; }
.status-skipped { background: rgba(154, 170, 201, 0.16); color: #c6d0e4; }
.status-active { background: rgba(39, 213, 154, 0.14); color: #57f0bb; }
.status-unsubscribed { background: rgba(255, 108, 138, 0.16); color: #ff9db2; }
.notice {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  min-width: 260px;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(17, 22, 35, 0.96);
  box-shadow: var(--shadow);
}
.notice.success { color: #8ef2cf; }
.notice.error { color: #ff8ba5; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
}
.modal.hidden, .hidden { display: none !important; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2,4,8,0.72);
  backdrop-filter: blur(8px);
}
.modal-card {
  position: relative;
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 22, 35, 0.98), rgba(12, 16, 26, 0.98));
  box-shadow: var(--shadow);
}
.narrow-modal { width: min(520px, calc(100vw - 32px)); }
.empty-state, .empty-table { padding: 12px 0; }
.variable-list { display: grid; gap: 10px; }
.variable-row { display: grid; grid-template-columns: minmax(150px, 0.9fr) minmax(0, 1.4fr) auto; gap: 10px; }
.variable-key[readonly] { background: rgba(255,255,255,0.02); color: #b7c0d8; }
.variable-remove[disabled] { opacity: 0.4; cursor: default; }
.panel-inline {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
}
.compact-header { align-items: flex-start; }

@media (max-width: 1380px) {
  .four-col-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .live-grid, .campaigns-grid, .logs-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .dashboard-shell { padding: 16px; }
  .topbar { flex-direction: column; }
  .top-actions, .upload-box, .panel-tools { justify-content: stretch; }
  .top-actions > button, .upload-box > button, .scheduler-chip, .panel-tools > button { width: 100%; }
  .panel-tools > input { width: 100%; }
  .two-column-grid, .variable-row, .throughput-grid, .four-col-grid { grid-template-columns: 1fr; }
  .panel-header, .spaced-header, .activity-item, .file-input-row { flex-direction: column; align-items: stretch; }
  .progress-meta { flex-direction: column; align-items: flex-start; }
  .button-stack { min-width: 0; }
  th, td { padding: 12px 8px; }
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.chart-box {
  min-height: 360px;
}

.chart-shell {
  display: grid;
  gap: 12px;
}

.chart-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 0.88rem;
  color: var(--muted);
}

.chart-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.chart-stage {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: radial-gradient(circle at top left, rgba(104,225,253,0.10), transparent 28%), rgba(7, 11, 18, 0.92);
  border: 1px solid rgba(255,255,255,0.06);
}

.outgoing-chart {
  width: 100%;
  height: 320px;
  display: block;
}

.chart-grid-line {
  stroke: rgba(148, 163, 184, 0.12);
  stroke-width: 1;
  stroke-dasharray: 4 8;
}

.chart-axis-line,
.chart-axis-tick {
  stroke: rgba(148, 163, 184, 0.22);
  stroke-width: 1;
}

.chart-axis-label {
  fill: rgba(226, 232, 240, 0.64);
  font-size: 11px;
}

.chart-axis-label-x {
  font-size: 10px;
}

.chart-series-dot {
  opacity: 0.88;
}

.chart-hover-band {
  cursor: crosshair;
}

.chart-hover-band:hover {
  fill: rgba(255,255,255,0.02);
}

.chart-focus-line {
  stroke: rgba(255,255,255,0.22);
  stroke-width: 1;
  stroke-dasharray: 4 5;
}

.chart-tooltip {
  position: absolute;
  min-width: 196px;
  max-width: 220px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(4, 8, 15, 0.94);
  border: 1px solid rgba(125, 140, 255, 0.24);
  box-shadow: 0 18px 48px rgba(0,0,0,0.42);
  backdrop-filter: blur(10px);
  pointer-events: none;
  z-index: 2;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.chart-tooltip span {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.chart-tooltip i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.report-table-wrap table td {
  vertical-align: top;
}

.five-col-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.chart-panel { margin-bottom: 18px; padding: 20px; }
.report-cards-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 16px; }
.compact-metric-card { min-height: 132px; }
.reports-layout { display: grid; gap: 18px; }
.report-summary-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.03);
}
.report-summary { line-height: 1.7; font-size: 0.98rem; }
.table-action-button { min-height: 40px; padding: 8px 12px; }
.report-row-active { background: rgba(104, 225, 253, 0.08); }
.status-failed {
  color: #ffb2bf;
  border-color: rgba(255, 108, 138, 0.28);
  background: rgba(255, 108, 138, 0.12);
}
.report-table-wrap th, .report-table-wrap td { white-space: nowrap; }
.webhooks-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.webhook-status-box {
  padding: 1rem;
  font-size: 0.92rem;
  line-height: 1.6;
}
.webhook-status-box .status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.webhook-status-box .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.webhook-status-box .status-dot.green { background: #34d399; }
.webhook-status-box .status-dot.red { background: var(--danger); }
.webhook-status-box .status-dot.yellow { background: #fbbf24; }
.webhook-status-box .webhook-url {
  font-family: monospace;
  font-size: 0.82rem;
  background: var(--bg);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-top: 0.5rem;
  word-break: break-all;
  color: var(--accent);
  border: 1px solid var(--line);
}
.webhook-table-container {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}
.webhook-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.webhook-table th,
.webhook-table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.webhook-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--surface-strong);
  z-index: 1;
}
.webhook-table tr:hover td { background: rgba(104, 225, 253, 0.04); }
.webhook-table .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.webhook-table .badge.delivered { background: rgba(52, 211, 153, 0.2); color: #34d399; }
.webhook-table .badge.opened { background: rgba(104, 225, 253, 0.2); color: var(--accent); }
.webhook-table .badge.clicked { background: rgba(125, 140, 255, 0.2); color: var(--accent-2); }
.webhook-table .badge.bounced { background: rgba(255, 108, 138, 0.2); color: var(--danger); }
.webhook-table .badge.failed { background: rgba(255, 108, 138, 0.2); color: var(--danger); }
.webhook-table .badge.sent { background: rgba(251, 191, 36, 0.2); color: #fbbf24; }
.webhook-table .empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

@media (max-width: 1400px) {
  .five-col-grid, .report-cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .five-col-grid, .report-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .five-col-grid, .report-cards-grid { grid-template-columns: minmax(0, 1fr); }
}
