*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --primary: #D72631;
  --primary-hover: #B71F28;
  --primary-light: #FFF1F2;
  --primary-muted: rgba(215,38,49,0.08);
  --accent-blue: #1F3A93;
  --accent-blue-light: #EEF2FB;
  --bg: #F7F8FA;
  --white: #FFFFFF;
  --card: #FFFFFF;
  --border: #E8EBF0;
  --border-strong: #D6DAE2;
  --text-primary: #1A1D26;
  --text-secondary: #5E6278;
  --text-muted: #A1A5B7;
  --green: #16A34A;
  --green-bg: rgba(22,163,74,0.10);
  --red: #DC2626;
  --red-bg: rgba(220,38,38,0.10);
  --orange: #F59E0B;
  --orange-bg: rgba(245,158,11,0.10);
  --blue: #3B82F6;
  --blue-bg: rgba(59,130,246,0.10);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --transition: 180ms ease;
  --sidebar-w: 248px;
}

html, body { height: 100%; }
body {
  font-family: var(--font); font-size: 14px;
  color: var(--text-primary); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- LOGIN ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1A1D26 0%, #2C0F12 50%, #1A1D26 100%);
  padding: 40px 20px;
}
.login-box {
  background: var(--card); border-radius: var(--radius-xl); padding: 40px; width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); border: 1px solid var(--border);
}
.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #D72631, #FF6B7A);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px; margin: 0 auto 16px;
}
.login-box h1 { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }
.login-box label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.login-box input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font); background: var(--white); color: var(--text-primary);
  margin-bottom: 16px; outline: none; transition: border-color var(--transition);
}
.login-box input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%; padding: 11px; background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background var(--transition);
}
.login-btn:hover { background: var(--primary-hover); }
.login-error {
  color: var(--red); font-size: 12.5px; text-align: center;
  margin-bottom: 12px; padding: 8px; background: var(--red-bg); border-radius: var(--radius);
}

/* ---------- APP LAYOUT ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; user-select: none; position: sticky; top: 0; height: 100vh;
}
.sb-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.sb-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #D72631, #FF6B7A);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.sb-brand { font-size: 16px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.3px; line-height: 1.1; }
.sb-tag { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.sb-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 14px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 20px;
  font-size: 13.5px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--primary-muted); color: var(--text-primary); }
.nav-item.active {
  background: var(--primary-light); color: var(--primary); font-weight: 600;
  border-left-color: var(--primary);
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }

.sb-footer {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sb-avatar {
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, #D72631, #FF6B7A); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.sb-user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.sb-user-email { font-size: 11px; color: var(--text-muted); }
.sb-logout {
  margin-left: auto; cursor: pointer; color: var(--text-muted);
  background: none; border: none; padding: 6px; border-radius: var(--radius);
}
.sb-logout:hover { color: var(--red); background: var(--red-bg); }

/* MAIN */
.main { display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--white); border-bottom: 1px solid var(--border);
  min-height: 60px; position: sticky; top: 0; z-index: 5;
}
.bc-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px 28px; flex: 1; }

.flash {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 13.5px; font-weight: 500;
}
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error,
.flash-warning { background: var(--orange-bg); color: var(--orange); }
.flash-info { background: var(--blue-bg); color: var(--blue); }

/* CARDS / KPI TILES */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* SECTIONS */
.section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.section-h { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 15px; font-weight: 700; }
.section-body { padding: 20px; }

/* TABLES */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:hover td { background: var(--bg); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tr.row-total td { background: var(--bg); font-weight: 700; }
table.tbl tr.row-total td.num { color: var(--text-primary); }

.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.muted { color: var(--text-muted); }

/* BADGES */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; line-height: 1.5;
}
.badge.live { background: var(--green-bg); color: var(--green); }
.badge.paused { background: var(--orange-bg); color: var(--orange); }
.badge.closed { background: var(--red-bg); color: var(--red); }
.badge.draft { background: var(--blue-bg); color: var(--blue); }
.badge.kill { background: var(--red-bg); color: var(--red); }
.badge.scale { background: var(--green-bg); color: var(--green); }
.badge.hold { background: var(--blue-bg); color: var(--blue); }
.badge.watch { background: var(--orange-bg); color: var(--orange); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--white); color: var(--text-primary); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--transition); text-decoration: none;
}
.btn:hover { background: var(--bg); border-color: var(--border-strong); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.success { background: var(--green); color: #fff; border-color: var(--green); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* FORMS */
.form-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.form-field input, .form-field select, .form-field textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font); background: var(--white); color: var(--text-primary);
  outline: none; transition: border-color var(--transition);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); }

/* UPLOAD AREA */
.upload-area {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 40px 20px; text-align: center; transition: all var(--transition);
  background: var(--bg);
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-muted); }
.upload-area input[type="file"] { display: block; margin: 12px auto; }
.upload-icon { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--text-muted); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state h3 { font-size: 15px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* CAMPAIGN NAME — small, mono-ish, ellipsis */
.campaign-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--text-secondary);
  max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
