/* ─── Reset + Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0a0a;
  --surface:  #111111;
  --surface2: #181818;
  --border:   #222222;
  --border2:  #2a2a2a;
  --text:     #e8e8e8;
  --text-muted: #666666;
  --text-dim:   #444444;
  --accent:   #c9993a;
  --accent-dim: rgba(201,153,58,0.15);
  --accent-hover: #d4aa52;
  --green:    #22c55e;
  --red:      #ef4444;
  --amber:    #f59e0b;
  --blue:     #3b82f6;
  --font-ui:  -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --radius:   6px;
  --radius-lg: 10px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-ui); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ─── Shell Layout ──────────────────────────────────────────────────────────── */
#shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0 0 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  border-radius: 4px;
  flex-shrink: 0;
}
.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}

#sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

#gmail-status-badge {
  margin: auto 16px 0;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Main Content ──────────────────────────────────────────────────────────── */
#app {
  padding: 32px 36px;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Spreadsheet Table ─────────────────────────────────────────────────────── */
.sheet-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  max-height: calc(100vh - 220px);
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
}

.sheet-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.sheet-table thead th {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  user-select: none;
}

.sheet-row-num {
  background: var(--surface2) !important;
  border-right: 1px solid var(--border) !important;
  color: var(--text-dim) !important;
  text-align: center !important;
  width: 36px;
  min-width: 36px;
  font-size: 11px !important;
  user-select: none;
}

.sheet-table tbody .sheet-row {
  border-bottom: 1px solid var(--border);
  transition: background 0.08s;
}
.sheet-table tbody .sheet-row:hover { background: rgba(255,255,255,0.02); }
.sheet-table tbody .sheet-row:last-child { border-bottom: none; }

.sheet-cell {
  padding: 0;
  border-right: 1px solid var(--border);
  position: relative;
  height: 34px;
  max-width: 200px;
}

.sheet-cell-ro {
  padding: 7px 10px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-cell-ed {
  cursor: cell;
}
.sheet-cell-ed:hover { background: rgba(201,153,58,0.04); }

.sheet-cell-active {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
  background: var(--surface2) !important;
}

.sheet-val {
  display: block;
  padding: 7px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 100%;
  color: var(--text);
}

.sheet-input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 7px 10px;
  box-sizing: border-box;
}

.sheet-select {
  width: 100%;
  height: 100%;
  background: var(--surface2);
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.sheet-select option { background: var(--surface2); }

.sheet-check-col {
  width: 36px;
  text-align: center;
  padding: 0 6px;
}
.sheet-check-col input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}
.row-selected {
  background: rgba(163, 230, 53, 0.06) !important;
}
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
}
.bulk-toolbar.hidden { display: none; }
.sheet-del-col {
  width: 40px;
  text-align: center;
  padding: 0 6px;
}
.sheet-del-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}
.sheet-row:hover .sheet-del-btn { opacity: 1; }
.sheet-del-btn:hover { color: var(--red); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.12s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border2);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: border-color 0.12s, color 0.12s;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}
.btn-danger-ghost {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.3);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
}
.btn-danger-ghost:hover { border-color: var(--red); background: rgba(239,68,68,0.08); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 16px;
  border-radius: var(--radius);
  transition: color 0.12s, background 0.12s;
}
.btn-icon:hover { color: var(--text); background: var(--surface2); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* ─── Filter Bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select,
.filter-bar input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
}
.filter-bar select:focus,
.filter-bar input:focus { border-color: var(--accent); }
.filter-bar select option { background: var(--surface); }

/* ─── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
}
thead th {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 11px 14px;
  color: var(--text);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Status Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-active   { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge-stopped  { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-pending  { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-positive { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-negative { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-auto     { background: rgba(107,114,128,0.2); color: #9ca3af; }
.badge-bounced  { background: rgba(239,68,68,0.1);   color: #f87171; }
.badge-sent     { background: rgba(34,197,94,0.1);   color: #4ade80; }
.badge-failed   { background: rgba(239,68,68,0.1);   color: #f87171; }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  font-family: var(--font-mono);
}
.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }

/* ─── Form Elements ─────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.form-row label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-row input,
.form-row textarea,
.form-row select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.12s;
  resize: vertical;
}
.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus { border-color: var(--accent); }
.form-row select option { background: var(--surface2); }
.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
#modal-overlay, #modal-edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.hidden { display: none !important; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

/* ─── Template Cards ────────────────────────────────────────────────────────── */
.template-grid {
  display: grid;
  gap: 20px;
}
.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}
.template-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.step-chip {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(201,153,58,0.3);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.day-label {
  font-size: 12px;
  color: var(--text-muted);
}
.template-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}
.template-card textarea {
  width: 100%;
  min-height: 140px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  resize: vertical;
  transition: border-color 0.12s;
  line-height: 1.6;
}
.template-card textarea:focus { border-color: var(--accent); }
.template-card input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
  margin-bottom: 10px;
}
.template-card input[type="text"]:focus { border-color: var(--accent); }
.subject-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
  display: block;
}
.ab-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}
.ab-row > div { display: flex; flex-direction: column; }
.preview-frame {
  width: 100%;
  min-height: 200px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: #fff;
  margin-top: 8px;
}
.warn-banner {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--amber);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-top: 8px;
}

/* ─── Scheduler Page ────────────────────────────────────────────────────────── */
.scheduler-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}
.cron-display {
  font-family: var(--font-mono);
  font-size: 22px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.next-run-label {
  font-size: 13px;
  color: var(--text-muted);
}
.countdown {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
}
.run-now-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.time-picker-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.time-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 20px;
  font-family: var(--font-mono);
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  text-align: center;
  min-width: 64px;
}
.time-select:focus { outline: none; border-color: var(--accent); }
.time-colon {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 2px;
}
.day-picker {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.day-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}
.day-btn:hover { border-color: var(--accent); color: var(--accent); }
.day-btn.selected { background: var(--accent); border-color: var(--accent); color: #000; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Analytics ─────────────────────────────────────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 50px;
  gap: 10px;
  align-items: center;
}
.bar-label { font-size: 12px; color: var(--text-muted); text-align: right; }
.bar-track {
  background: var(--surface2);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.bar-fill.green { background: var(--green); }
.bar-fill.red   { background: var(--red); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.blue  { background: var(--blue); }
.bar-count { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

.ab-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ab-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  position: relative;
}
.ab-card.winner {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.ab-card-variant {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.ab-card-variant.a { color: var(--blue); }
.ab-card-variant.b { color: var(--accent); }
.ab-stat { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.winner-badge {
  position: absolute;
  top: -8px;
  right: 10px;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}

.funnel-chart { display: flex; flex-direction: column; gap: 6px; }
.funnel-row {
  display: grid;
  grid-template-columns: 60px 1fr 50px;
  gap: 10px;
  align-items: center;
}

/* ─── Settings Page ─────────────────────────────────────────────────────────── */
.settings-section {
  margin-bottom: 32px;
}
.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.gmail-connect-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.gmail-icon {
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.gmail-info { flex: 1; }
.gmail-info strong { font-size: 14px; }
.gmail-info small { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.connected-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  margin-right: 5px;
}

/* ─── Log Table ─────────────────────────────────────────────────────────────── */
.log-table th, .log-table td { font-family: var(--font-mono); font-size: 12px; }

/* ─── CSV Import section ────────────────────────────────────────────────────── */
.import-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
}
.import-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.import-tab.active { background: var(--surface2); color: var(--text); }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  max-width: 360px;
  animation: toast-in 0.2s ease;
}
.toast.success { border-color: rgba(34,197,94,0.4); color: var(--green); }
.toast.error   { border-color: rgba(239,68,68,0.4);  color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Loading ───────────────────────────────────────────────────────────────── */
.loading-spinner {
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

/* ─── Empty State ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state p { font-size: 14px; margin-bottom: 4px; color: var(--text-muted); }
.empty-state small { font-size: 12px; }

/* ─── Divider ───────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ─── Sheet Tabs (Google Sheets style) ──────────────────────────────────────── */
.sheet-tabs-bar {
  display: flex;
  align-items: stretch;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 36px;
  scrollbar-width: thin;
}
.sheet-tabs-bar::-webkit-scrollbar { height: 3px; }
.sheet-tabs-bar::-webkit-scrollbar-track { background: transparent; }
.sheet-tabs-bar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.sheet-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  transition: background 0.1s, color 0.1s;
  min-height: 36px;
  position: relative;
}
.sheet-tab:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sheet-tab.active {
  background: var(--surface);
  color: var(--text);
  border-top: 2px solid var(--accent);
  font-weight: 500;
}
.sheet-tab-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.sheet-tab-rename {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-size: 12px;
  outline: none;
  width: 80px;
  font-family: var(--font-ui);
}
.sheet-tab-del {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  padding: 1px 2px;
  border-radius: 2px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
}
.sheet-tab:hover .sheet-tab-del { opacity: 1; }
.sheet-tab-del:hover { color: var(--red); }

.sheet-tab-add {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 16px;
  color: var(--text-dim);
  cursor: pointer;
  background: transparent;
  border: none;
  transition: color 0.1s;
  min-height: 36px;
}
.sheet-tab-add:hover { color: var(--accent); }

/* ─── Variant rows in templates ──────────────────────────────────────────────── */
.variants-group {
  margin-bottom: 12px;
}
.variant-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.variant-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  font-family: var(--font-mono);
  width: 18px;
  flex-shrink: 0;
}
.variant-row input[type="text"] {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
}
.variant-row input[type="text"]:focus { border-color: var(--accent); }
.variant-row textarea {
  flex: 1;
  min-height: 120px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 9px 10px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  resize: vertical;
  transition: border-color 0.12s;
  line-height: 1.6;
}
.variant-row textarea:focus { border-color: var(--accent); }
.variant-del-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  flex-shrink: 0;
  transition: color 0.1s, background 0.1s;
}
.variant-del-btn:hover { color: var(--red); background: rgba(239,68,68,0.08); }
.btn-add-variant {
  background: transparent;
  border: 1px dashed var(--border2);
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
  margin-top: 4px;
}
.btn-add-variant:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Add step banner ────────────────────────────────────────────────────────── */
.add-step-banner {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.add-step-banner:hover { border-color: var(--accent); color: var(--accent); }
.step-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius);
  transition: color 0.1s, background 0.1s;
}
.step-delete-btn:hover { color: var(--red); background: rgba(239,68,68,0.08); }

/* ─── Signature preview ──────────────────────────────────────────────────────── */
.sig-preview-frame {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: #fff;
  margin-top: 8px;
}
.sig-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.6;
}
.sig-hint code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* ─── Sheet wrap + tabs together ────────────────────────────────────────────── */
.sheet-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.sheet-container .sheet-wrap {
  border: none;
  border-radius: 0;
  max-height: calc(100vh - 260px);
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #shell { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  #app { padding: 20px 16px; }
  .scheduler-layout, .analytics-grid { grid-template-columns: 1fr; }
}

/* ─── Deliverability Score ──────────────────────────────────────────────────── */
.deliverability-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.score-circle {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.score-svg {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}
.score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.score-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.score-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.score-components { flex: 1; min-width: 200px; }
.score-bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 50px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.score-bar-label { font-size: 12px; color: var(--text-muted); }
.score-bar-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.score-bar-pts { font-size: 11px; color: var(--text-dim); text-align: right; }
.delivery-tips {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: var(--radius);
  border-left: 3px solid var(--amber);
}
.tips-title { font-size: 12px; font-weight: 600; color: var(--amber); margin-bottom: 8px; }
.tip { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* ─── Warm-up ───────────────────────────────────────────────────────────────── */
.warmup-status-box { flex: 1; min-width: 240px; }
.warmup-progress-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}
.warmup-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.warmup-chart { flex-shrink: 0; }
