:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:      #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --border:         rgba(11,11,11,0.10);
  --series-1:       #2a78d6;   /* blue — sent/opens/primary series */
  --series-3:       #1baf7a;   /* aqua — clicks */
  --series-2:       #eb6834;   /* orange — revenue */
  --status-good:    #0ca30c;
  --status-critical:#d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;
    --series-3:       #199e70;
    --series-2:       #d95926;
    --status-good:    #0ca30c;
    --status-critical:#e66767;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

.loading-notice { padding: 24px; color: var(--text-secondary); }

header.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
header.app-header h1 {
  font-size: 18px;
  margin: 0;
  flex: 0 0 auto;
}
header.app-header select,
header.app-header button {
  font-size: 14px;
}
header.app-header .spacer { flex: 1 1 auto; }

main.app-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 64px 20px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 16px 0 6px 0;
}
label:first-child { margin-top: 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--gridline);
  border-radius: 6px;
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: inherit;
}

textarea { min-height: 220px; font-family: ui-monospace, monospace; font-size: 13px; }

button {
  font-family: inherit;
  padding: 9px 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--series-1);
  color: white;
  cursor: pointer;
  font-weight: 600;
}
button.secondary {
  background: var(--surface-1);
  color: var(--text-primary);
  border-color: var(--gridline);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.error-banner {
  background: color-mix(in srgb, var(--status-critical) 12%, var(--surface-1));
  border: 1px solid var(--status-critical);
  color: var(--status-critical);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

table.campaign-list { width: 100%; border-collapse: collapse; }
table.campaign-list th, table.campaign-list td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--gridline);
  font-size: 14px;
}
table.campaign-list th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.campaign-list tr { cursor: pointer; }
table.campaign-list tr:hover td { background: var(--page-plane); }

.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-draft { background: var(--gridline); color: var(--text-secondary); }
.status-sending { background: color-mix(in srgb, var(--series-1) 18%, var(--surface-1)); color: var(--series-1); }
.status-completed { background: color-mix(in srgb, var(--status-good) 18%, var(--surface-1)); color: var(--status-good); }
.status-failed { background: color-mix(in srgb, var(--status-critical) 18%, var(--surface-1)); color: var(--status-critical); }

.progress-track {
  height: 10px;
  background: var(--gridline);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-fill {
  height: 100%;
  background: var(--series-1);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.stat-tile .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.stat-tile .stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: proportional-nums;
}
.stat-tile .stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .bar-label {
  flex: 0 0 220px;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row .bar-track { flex: 1 1 auto; background: var(--gridline); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--series-3); border-radius: 4px 0 0 4px; }
.bar-row .bar-count { flex: 0 0 32px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--gridline); }
.tabs button {
  background: none; border: none; color: var(--text-secondary);
  padding: 8px 14px; font-weight: 600; border-radius: 0;
}
.tabs button.active { color: var(--series-1); border-bottom: 2px solid var(--series-1); }

.note { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
