:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e5ea;
  --text: #1c1f26;
  --muted: #6b7280;
  --accent: #3454d1;
  --accent-tint: #eaefff;
  --green: #1c8a5a;
  --green-tint: #e6f6ee;
  --amber: #b9770e;
  --amber-tint: #fdf1de;
  --red: #c0392b;
  --red-tint: #fbeae8;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

.clickable { cursor: pointer; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
}
.sidebar-logo { font-weight: 800; font-size: 16px; padding: 0 10px 18px; }
.sidebar-org { font-size: 12px; color: var(--muted); padding: 0 10px 14px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.navitem {
  padding: 9px 10px; border-radius: 8px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px;
}
.navitem:hover { background: var(--bg); }
.navitem.active { background: var(--accent-tint); color: var(--accent); }
.sidebar-spacer { flex: 1; }
.sidebar-user { padding: 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 10px; }

.main { flex: 1; padding: 28px 36px; max-width: 1080px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 20px; margin: 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); font-weight: 600; color: var(--text);
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2a44b0; }
.btn-danger { color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 4px; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-active { background: var(--green-tint); color: var(--green); }
.badge-paused { background: var(--amber-tint); color: var(--amber); }
.badge-draft { background: var(--border); color: var(--muted); }
.badge-archived { background: var(--border); color: var(--muted); }
.badge-failed { background: var(--red-tint); color: var(--red); }
.badge-connected { background: var(--green-tint); color: var(--green); }
.badge-expired { background: var(--amber-tint); color: var(--amber); }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.error-banner { background: var(--red-tint); color: var(--red); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; font-size: 13px; }

/* Auth screen */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-box { width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 32px; }
.auth-box h1 { font-size: 18px; margin: 0 0 4px; }
.auth-box .page-sub { margin-bottom: 20px; }
.auth-toggle { display: flex; gap: 4px; background: var(--bg); border-radius: 8px; padding: 3px; margin-bottom: 18px; }
.auth-toggle button { flex: 1; padding: 8px; border: none; border-radius: 6px; background: transparent; font-weight: 700; color: var(--muted); }
.auth-toggle button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* Connections */
.connection-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.connection-row:last-child { border-bottom: none; }
.connection-platform { font-weight: 700; }
.connection-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Table-ish lists */
.list-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row-name { font-weight: 700; flex: 1; }
.list-row-meta { font-size: 12px; color: var(--muted); }
.list-row-stat { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }

/* Wizard */
.wizard-steps { display: flex; gap: 8px; margin-bottom: 22px; }
.wizard-step { flex: 1; text-align: center; padding: 8px 4px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--bg); }
.wizard-step.active { background: var(--accent-tint); color: var(--accent); }
.wizard-step.done { color: var(--green); }
.wizard-actions { display: flex; justify-content: space-between; margin-top: 20px; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; font-weight: 600; font-size: 13px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.creative-preview { width: 100%; max-width: 320px; border-radius: 8px; border: 1px solid var(--border); margin-top: 8px; }
.review-block { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.review-block:last-child { border-bottom: none; }
.review-block .label { color: var(--muted); font-weight: 600; }

/* Misc */
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c1f26; color: #fff; padding: 10px 18px; border-radius: 8px; font-weight: 600; z-index: 50; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,22,28,0.5); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal { width: 460px; max-width: 92vw; max-height: 86vh; overflow-y: auto; background: var(--panel); border-radius: 12px; padding: 24px; }
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.spend-bar-bg { background: var(--border); border-radius: 6px; height: 6px; overflow: hidden; margin-top: 6px; }
.spend-bar-fill { background: var(--accent); height: 100%; }
.inline-note { background: var(--accent-tint); color: var(--accent); padding: 10px 14px; border-radius: 8px; font-size: 12px; margin-bottom: 16px; }
