:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 255px;
  background: var(--sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  padding: 22px 20px;
  border-bottom: 1px solid #1e293b;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand span {
  font-size: 12px;
  color: #94a3b8;
  display: block;
  margin-top: 4px;
}

.nav-links {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  background: transparent;
  color: #cbd5e1;
  border: none;
  text-align: left;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e293b;
  font-size: 12px;
  color: #94a3b8;
}

/* Main Content */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill-green { background: #dcfce7; color: #15803d; }
.pill-amber { background: #fef3c7; color: #b45309; }
.pill-red { background: #fee2e2; color: #b91c1c; }
.pill-blue { background: #dbeafe; color: #1d4ed8; }
.pill-slate { background: #e2e8f0; color: #334155; }

.content {
  padding: 26px 28px;
  max-width: 1360px;
  width: 100%;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h2 {
  margin: 0;
  font-size: 22px;
}

.page-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* Cards & Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.kpi-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  margin: 8px 0 4px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s, background 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th, td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f8fafc;
}

tr:hover td {
  background: #f8fafc;
}

/* Forms */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 5px;
  color: #334155;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  margin-bottom: 10px;
}

.checkbox-row input {
  width: auto;
}

.tag {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  margin: 1px 3px 1px 0;
}

/* Step Builder */
.step-box {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 16px;
  background: #f8fafc;
  margin-bottom: 14px;
}

.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 12px;
  max-width: 860px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 200;
}

.toast.show {
  display: block;
}

.campaign-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  background: #fff;
  margin-bottom: 14px;
}

.campaign-stats-bar {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: #334155;
}
