:root {
  --bg: #FFFFFF;
  --bg-soft: #FAF7FB;
  --surface: #FFFFFF;
  --surface-muted: #F7F4F9;
  --text: #111114;
  --text-muted: #6B6B7A;
  --text-soft: #9090A0;
  --border: #EEEAF0;
  --border-strong: #DFD9E4;
  --accent-1: #FF6FB5;
  --accent-2: #B86CFF;
  --accent-gradient: linear-gradient(135deg, #FF6FB5 0%, #B86CFF 100%);
  --accent-glow: rgba(184, 108, 255, 0.18);
  --danger: #D83A6A;
  --success: #4CAF7A;
  --warning: #E0963E;

  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.04);
  --shadow-md: 0 8px 24px rgba(184, 108, 255, 0.08);
  --shadow-lg: 0 20px 40px rgba(184, 108, 255, 0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ================= Top bar ================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 14px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(6px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 24px; height: 24px;
  border-radius: 8px;
  background: var(--accent-gradient);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.brand-name {
  font-size: 16px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
.brand-tag {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 10px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}
.nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-muted); color: var(--text); }
.nav-link.is-active {
  color: var(--text);
  background: var(--surface-muted);
  font-weight: 500;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.locale-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}
.locale-btn {
  background: none;
  border: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.locale-btn.is-active {
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
}
.user-email { font-size: 13px; color: var(--text-muted); }
.logout-form { margin: 0; }

/* ================= Buttons ================= */
.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .05s, box-shadow .15s, background .15s, color .15s, border-color .15s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px var(--accent-glow); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-muted); border-color: var(--border-strong); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ================= Cards ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card-title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 24px; letter-spacing: -0.015em; }

/* ================= Forms ================= */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field--inline { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 0; flex-wrap: wrap; }
.field-label { font-size: 12px; color: var(--text-muted); font-weight: 500; letter-spacing: .02em; text-transform: uppercase; }
.field-sep { color: var(--text-muted); }
input[type=email], input[type=password], input[type=text], input[type=number], input[type=date], select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-inline {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-error {
  background: #fdecef;
  color: #9a2444;
  border: 1px solid #f5c8d2;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.form-notice {
  background: #effaf3;
  color: #1e6b41;
  border: 1px solid #cdeadb;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* ================= Auth pages ================= */
.auth-body {
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(255,111,181,.18), transparent 60%),
    radial-gradient(500px 400px at 90% 90%, rgba(184,108,255,.18), transparent 60%),
    var(--bg-soft);
  min-height: 100vh;
}
.auth-body .main { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 64px); }
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-title { margin: 0 0 20px; font-size: 22px; letter-spacing: -0.015em; }
.auth-hello { color: var(--text-muted); margin: 0 0 20px; font-size: 14px; }
.auth-email { margin: 0 0 16px; font-size: 14px; color: var(--text); background: var(--surface-muted); padding: 10px 14px; border-radius: var(--radius-sm); }
.auth-form .field { margin-bottom: 14px; }
.auth-form button { margin-top: 8px; }
.auth-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.auth-link:hover { color: var(--accent-2); }

/* ================= Dashboard ================= */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.summary-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  margin: 0;
}
.summary-card__label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.summary-card__value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.summary-card--accent {
  background: var(--accent-gradient);
  color: #fff;
  border: 0;
  box-shadow: var(--shadow-md);
}
.summary-card--accent .summary-card__label { color: rgba(255,255,255,.8); }
.summary-card--accent .btn-primary {
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(6px);
  box-shadow: none;
  border: 1px solid rgba(255,255,255,.3);
}
.summary-card--accent .btn-primary:hover:not(:disabled) {
  background: rgba(255,255,255,.26);
  transform: translateY(-1px);
}
.summary-card__action { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.hint { font-size: 12px; color: rgba(255,255,255,.75); }

.report-card .filters { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 16px; }
.filters__row { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; margin-bottom: 12px; }
.filters__row:last-child { margin-bottom: 0; }
.filters--inline { display: inline-flex; gap: 8px; }
.presets { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { background: var(--border); }
.chip.is-on {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
}
.utm-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.metrics-toggles {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0;
  margin-bottom: 8px;
}
.metric-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.metric-toggle.is-on { color: var(--text); }
.metric-toggle input { display: none; }
.metric-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.cache-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0 0;
  margin: 0 0 -4px;
}
.cache-note__updated {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.chart-wrap {
  position: relative;
  height: 320px;
  margin-bottom: 20px;
}
.chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-sm);
  z-index: 2;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.summary-card__value.is-loading {
  color: var(--text-soft);
  opacity: 0.55;
}
.summary-card--accent .summary-card__value.is-loading { color: rgba(255,255,255,.65); }

/* ================= Tables ================= */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table thead th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border-strong);
}
.data-table tfoot th {
  font-weight: 600;
  border-top: 1px solid var(--border-strong);
}
.data-table tbody tr:hover { background: var(--surface-muted); }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }
.data-table .muted { color: var(--text-muted); }

.row-actions { text-align: right; }
.row-actions form { display: inline; margin-left: 6px; }

/* ================= Badges ================= */
.status-badge, .role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .01em;
}
.status-pending { background: #fff4e0; color: #8a5500; }
.status-processing { background: #e6efff; color: #244a99; }
.status-completed { background: #e3f7ec; color: #146b3e; }
.status-disabled { background: #f3eef1; color: #6b4455; }
.role-superadmin { background: var(--accent-gradient); color: #fff; }
.role-admin { background: #efe8f8; color: #4a2277; }
.role-partner { background: var(--surface-muted); color: var(--text-muted); }

/* ================= Modal ================= */
.modal {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 90vw;
}
.modal::backdrop { background: rgba(17,17,20,.45); backdrop-filter: blur(3px); }
.modal__form { padding: 28px; }
.modal__title { margin: 0 0 20px; font-size: 20px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.muted { color: var(--text-muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--surface-muted); padding: 2px 6px; border-radius: 4px; }

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .brand-tag { display: none; }
  .main { padding: 20px 16px 60px; }
  .summary-card__value { font-size: 26px; }
  .form-inline { flex-direction: column; align-items: stretch; }
}
