:root {
  --blue-1: #0072FF;
  --blue-2: #00D2FF;
  --gold-1: #F2994A;
  --gold-2: #F2C94C;
  --bg: #f4f7fb;
  --bg-2: #eef2f8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.08);
  --sidebar: #0b1220;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --danger: #dc2626;
  --success: #059669;
  --grad-blue: linear-gradient(135deg, #0072FF 0%, #00D2FF 100%);
  --grad-gold: linear-gradient(135deg, #F2994A 0%, #F2C94C 100%);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.admin-body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--blue-1); text-decoration: none; }
a:hover { color: #0056cc; }

.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 260px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-shrink: 0;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-brand img { height: 36px; width: auto; }
.admin-brand-text { font-weight: 700; letter-spacing: .04em; }
.admin-brand-text small {
  display: block;
  color: var(--sidebar-muted);
  font-weight: 500;
  letter-spacing: 0;
  margin-top: .15rem;
}
.admin-nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.admin-nav a {
  color: var(--sidebar-text);
  padding: .7rem .85rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 500;
}
.admin-nav a:hover, .admin-nav a.active {
  background: rgba(0,114,255,.18);
  color: #fff;
}
.admin-nav .nav-icon {
  width: 1.25rem;
  text-align: center;
  opacity: .85;
}
.admin-sidebar-foot {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: .85rem;
  font-size: .85rem;
  color: var(--sidebar-muted);
}
.admin-sidebar-foot a { color: #cbd5e1; }
.admin-sidebar-foot a:hover { color: var(--gold-2); }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.admin-topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}
.admin-topbar .meta { color: var(--muted); font-size: .9rem; }
.admin-content { padding: 1.5rem; }

.alert {
  padding: .85rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: .95rem;
}
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--grad-blue);
}
.stat-card.gold::before { background: var(--grad-gold); }
.stat-label { color: var(--muted); font-size: .85rem; margin-bottom: .35rem; }
.stat-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { margin: 0; font-size: 1.05rem; }
.panel-body { padding: 0; }
.panel-body.padded { padding: 1.25rem; }

.table-wrap { overflow-x: auto; }
table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.admin-table th, .admin-table td {
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table th {
  background: var(--bg-2);
  color: var(--text);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.admin-table tr:hover td { background: #f8fbff; }
.admin-table .muted { color: var(--muted); }
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #075985;
}
.badge-new { background: #fef3c7; color: #92400e; }
.badge-active, .badge-contacted { background: #dbeafe; color: #1e40af; }
.badge-closed, .badge-done { background: #d1fae5; color: #065f46; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
}
.toolbar form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.toolbar label { font-size: .9rem; color: var(--muted); }
select,
input[type=email],
input[type=password],
input[type=text],
input[type=tel],
input[type=search],
input[type=number],
input[type=url],
textarea {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: .65rem .85rem;
  font: inherit;
  width: 100%;
  max-width: 100%;
}
textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.45;
}
select:focus,
input:focus,
textarea:focus {
  outline: 2px solid rgba(0,114,255,.25);
  border-color: var(--blue-1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: none;
  border-radius: 10px;
  padding: .65rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary {
  background: var(--grad-blue);
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(0,114,255,.25);
}
.btn-primary:hover { filter: brightness(1.05); color: #fff !important; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-gold {
  background: var(--grad-gold);
  color: #0b1220 !important;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(0,114,255,.18), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(242,153,74,.16), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem 1.75rem;
}
.login-card .logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.login-card .logo img { height: 42px; }
.login-card h1 { margin: 0 0 .35rem; font-size: 1.4rem; }
.login-card .sub { color: var(--muted); margin: 0 0 1.25rem; font-size: .95rem; }
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: .4rem;
  color: #334155;
}
.form-group input { width: 100%; }
.login-card .btn { width: 100%; margin-top: .35rem; }
.login-foot {
  margin-top: 1.25rem;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}
.login-foot a { color: var(--blue-1, #0072ff); text-decoration: none; font-weight: 600; }
.login-foot a:hover { text-decoration: underline; }
.login-foot-sep { margin: 0 .35rem; color: var(--muted); }
.alert-info {
  background: rgba(0,114,255,.08);
  border: 1px solid rgba(0,114,255,.22);
  color: #1e3a5f;
  border-radius: 10px;
  padding: .85rem 1rem;
  font-size: .92rem;
  line-height: 1.45;
}


.empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 1rem; }
}

/* Invoices / billing */

.badge-paid, .badge-issued { background: #d1fae5; color: #065f46; }
.badge-void { background: #e2e8f0; color: #475569; }
.badge-created, .badge-failed, .badge-refunded { background: #e2e8f0; color: #334155; }
.invoice-doc { max-width: 820px; margin: 0 auto; color: #0f172a; }
.invoice-header { display: flex; justify-content: space-between; gap: 1.5rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.invoice-brand { display: flex; gap: 1rem; align-items: flex-start; }
.invoice-logo { height: 48px; width: auto; }
.invoice-company { font-weight: 800; font-size: 1.05rem; color: #0072FF; }
.invoice-addr { max-width: 280px; line-height: 1.45; margin: .25rem 0; }
.invoice-meta { text-align: right; }
.invoice-meta h1 { margin: 0 0 .5rem; font-size: 1.35rem; letter-spacing: .04em; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.invoice-parties h3 { margin: 0 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; }
.invoice-table th { background: #f8fafc; }
.invoice-foot { margin-top: 1.5rem; font-size: .8rem; border-top: 1px dashed #e2e8f0; padding-top: .75rem; }
.invoice-summary-wrap { display: flex; justify-content: flex-end; margin-top: 1rem; }
.invoice-summary { width: 320px; max-width: 100%; border-collapse: collapse; }
.invoice-summary td { padding: .35rem .5rem; border-bottom: 1px solid #e2e8f0; font-size: .92rem; }
.invoice-summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-summary tr.invoice-grand td { border-bottom: none; border-top: 2px solid #0f172a; padding-top: .55rem; font-size: 1.02rem; }
.invoice-table td, .invoice-table th { vertical-align: top; }

@media print {
  .admin-sidebar, .admin-topbar, .toolbar, .no-print, .alert { display: none !important; }
  .admin-shell { display: block; }
  .admin-main { margin: 0; padding: 0; }
  .admin-content { padding: 0; }
  .panel, .invoice-panel { border: none; box-shadow: none; }
  .invoice-doc { max-width: none; }
}


/* Forms / customers */
.form-check {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  cursor: pointer;
}
.form-check input { width: auto; margin: 0; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.help { color: var(--muted); font-size: .85rem; margin-top: .25rem; }


/* CMS form layout */
.form-grid { display: grid; gap: 1rem; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-group { min-width: 0; }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; }
.cms-form { max-width: 920px; }
.cms-section {
  margin: 0 0 1.25rem;
  padding: 1.1rem 1.15rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfcfe;
}
.cms-section > h3 {
  margin: 0 0 .85rem;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748b;
}
.cms-section .form-group:last-child { margin-bottom: 0; }
.cms-checks {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.5rem;
  align-items: center;
  padding-top: .15rem;
}
.cms-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .85rem 0 .15rem;
  margin-top: .5rem;
  background: linear-gradient(180deg, rgba(244,247,251,0), var(--bg) 28%);
}
.plan-row {
  margin-bottom: .85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
}
.cms-danger {
  margin-top: 1.5rem;
  padding: 1.1rem 1.15rem;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff7f7;
}
.cms-danger h3 {
  margin: 0 0 .65rem;
  font-size: .95rem;
  color: #991b1b;
}
@media (max-width: 900px) {
  .form-grid.two,
  .form-grid.three { grid-template-columns: 1fr; }
}

/* Affiliate dashboard share rows */
.aff-copy-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.aff-copy-row input {
  flex: 1;
  min-width: 0;
}
.aff-copy-row .btn { flex-shrink: 0; white-space: nowrap; }

