/**
 * Referrer System — polished UI (single stylesheet)
 */
:root {
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.08);
  --primary-border: rgba(37, 99, 235, 0.2);
  --success: #0d9488;
  --success-light: rgba(13, 148, 136, 0.1);
  --danger: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.08);
  --warning: #ca8a04;
  --warning-light: rgba(202, 138, 4, 0.1);
  --info: #0284c7;
  --info-light: rgba(2, 132, 199, 0.08);
  --text: #334155;
  --text-muted: #64748b;
  --heading: #0f172a;
  --sidebar-bg: linear-gradient(180deg, #1e3a5f 0%, #0f172a 100%);
  --sidebar-text: rgba(255, 255, 255, 0.9);
  --sidebar-text-dim: rgba(255, 255, 255, 0.65);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --header-height: 72px;
}

.btn-logout-top {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s;
  border: 1px solid var(--border);
  margin-left: 0.5rem;
}

.btn-logout-top:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.2);
  transform: translateY(-1px);
}

.dash-user {
  cursor: default;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--heading);
  font-weight: 600;
  margin: 0 0 0.5em 0;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

h5 {
  font-size: 0.875rem;
}

/* ---- Layout (legacy) ---- */
.app-wrap {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar-bg);
  padding: 1.5rem 0;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  margin: 0 1rem 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar a {
  display: block;
  color: #cbd5e1;
  text-decoration: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar a.nav-logout {
  color: #fbbf24;
  margin-top: 1.5rem;
}

.main {
  flex: 1;
  padding: 1.75rem 2rem;
  min-width: 0;
}

/* ---- Panels ---- */
.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.2s;
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

.panel h2 {
  margin-bottom: 1rem;
}

.panel h3 {
  margin-bottom: 0.75rem;
}

.panel--no-pad {
  padding: 0;
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

/* ---- Tables ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 0.875rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  background: var(--bg-subtle);
  color: var(--heading);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tbody tr {
  transition: background 0.15s;
}

.table tbody tr:hover {
  background: var(--surface-hover);
}

.table th:first-child,
.table td:first-child {
  padding-left: 1.5rem;
}

.table th:last-child,
.table td:last-child {
  padding-right: 1.5rem;
}

.table-img {
  height: 32px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: var(--radius-sm);
}

/* ---- Forms ---- */
.form label,
.form-section .form-row label,
.form-card .form-row label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--heading);
  font-size: 0.875rem;
}

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="number"],
.form input[type="url"],
.form select,
.form-section select,
.form-card select {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form input:focus,
.form select:focus,
.form-section select:focus,
.form-card select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form .form-row {
  margin-bottom: 1.125rem;
}

/* Select (dropdown) – native appearance so dropdown always works */
.form select,
.form-section select,
.form-card select {
  cursor: pointer;
  min-height: 2.75rem;
  padding-right: 2rem;
}

.form select:hover,
.form-section select:hover,
.form-card select:hover {
  border-color: #cbd5e1;
}

.form select option,
.form-section select option,
.form-card select option {
  padding: 0.5rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 0.55rem 1.125rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
  text-align: center;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}

.badge-success {
  background: rgba(13, 148, 136, 0.12);
  color: #0d9488;
}

.badge-danger {
  background: var(--danger-light);
  color: #b91c1c;
}

.badge-warning {
  background: var(--warning-light);
  color: #a16207;
}

.badge-info {
  background: var(--info-light);
  color: #0284c7;
}

/* ---- Alerts ---- */
.alert {
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #f0fdfa;
  border-color: #99f6e4;
  color: #0f766e;
}

/* ---- Auth (professional layout) ---- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  padding: 0;
  background: #0b1120;
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(37, 99, 235, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(147, 51, 234, 0.12) 0%, transparent 50%);
  position: relative;
  overflow: hidden;
}

.auth-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

@media (min-width: 900px) {
  .auth-wrap {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
}

.auth-brand {
  display: none;
  padding: 3rem 3.5rem;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 1;
}

@media (min-width: 900px) {
  .auth-brand {
    display: flex;
  }
}

.auth-brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin-bottom: 2rem;
  padding: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.auth-brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.auth-brand h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem 0;
  line-height: 1.2;
}

.auth-brand p {
  font-size: 1rem;
  color: rgba(255,255,255,0.6);
  margin: 0;
  line-height: 1.6;
  max-width: 320px;
}

.auth-form-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  min-height: 100vh;
}

@media (min-width: 900px) {
  .auth-form-wrap {
    min-height: auto;
    padding: 3rem 4rem;
  }
}

.auth-panel {
  width: 100%;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2.5rem 2rem;
  position: relative;
}

@media (min-width: 480px) {
  .auth-panel {
    padding: 3rem 2.5rem;
  }
}

.auth-panel-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 1.5rem;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.auth-panel .auth-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

@media (min-width: 900px) {
  .auth-panel-logo-wrap {
    display: none;
  }
}

.auth-panel h3 {
  text-align: left;
  margin-bottom: 1.75rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.025em;
}

.auth-panel .form-row {
  margin-bottom: 1.25rem;
}

.auth-panel label {
  display: block;
  font-weight: 600;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.9);
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}

.auth-panel input[type="text"],
.auth-panel input[type="email"],
.auth-panel input[type="password"],
.auth-panel input[type="tel"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.6);
  color: #fff;
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-panel input::placeholder {
  color: rgba(255,255,255,0.35);
}

.auth-panel input:hover {
  border-color: rgba(255,255,255,0.18);
}

.auth-panel input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.7);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-panel .btn-primary {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-top: 0.5rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.auth-panel .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
}

.auth-panel .btn-primary:active {
  transform: translateY(0);
}

.auth-footer {
  text-align: center;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.9375rem;
  color: rgba(255,255,255,0.55);
}

.auth-footer a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.auth-footer a:hover {
  color: #93c5fd;
}

.auth-panel .alert {
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.auth-panel .alert-danger {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #fca5a5;
}

.auth-panel .alert-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.btn-home-fixed {
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  z-index: 100;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.8125rem;
  text-decoration: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.btn-home-fixed:hover {
  background: rgba(30, 41, 59, 0.95);
  color: #e2e8f0;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  border-color: rgba(255,255,255,0.15);
}

body.auth-page {
  background: #0b1120;
}

/* ---- Stats (legacy) ---- */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
}

.stat {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 1.25rem;
}

.stat h5 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem 0;
  color: var(--text-muted);
}

.stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--heading);
}

/* ---- Page header ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h2 {
  margin: 0;
}

/* ---- Input group ---- */
.input-group {
  display: flex;
  align-items: stretch;
  max-width: 400px;
}

.input-group input {
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
}

.input-group .input-prefix {
  padding: 0.6rem 0.875rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.input-group .btn {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: none;
}

.input-group.input-group--with-prefix input {
  border-radius: 0;
}

.input-group.input-group--with-prefix .input-prefix {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.copy-wrap .input-group {
  max-width: 100%;
}

.copy-wrap .input-group input {
  border-radius: var(--radius-sm);
  border-right: 1px solid var(--border);
}

.copy-wrap .input-group .btn {
  border-radius: var(--radius-sm);
  border-left: 1px solid var(--border);
  margin-left: 0.35rem;
}

/* ---- Tracking (referral /r/{code}) ---- */
.tracking-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: radial-gradient(circle at top left, #f0f4ff 0%, #f8fafc 40%, #eff6ff 100%);
  position: relative;
  overflow: hidden;
}

.tracking-wrap::before {
  content: '';
  position: absolute;
  width: 1000px;
  height: 1000px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.03) 0%, transparent 70%);
  top: -400px;
  right: -300px;
  pointer-events: none;
}

.tracking-panel {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--border-light);
  padding: 2.5rem 2rem;
  text-align: center;
}

.tracking-panel .icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  line-height: 1;
  position: relative;
}

.tracking-panel .icon.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 10px 20px -5px rgba(16, 185, 129, 0.4);
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.tracking-panel .icon.error {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.12) 0%, rgba(220, 38, 38, 0.05) 100%);
  color: var(--danger);
}

.tracking-panel h2 {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.tracking-panel .tracking-sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.tracking-ref-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f1f5f9;
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 2rem;
  border: 1px dashed #cbd5e1;
  letter-spacing: 0.05em;
}

.tracking-divider {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 1.5rem 0 1rem 0;
}

.tracking-platforms {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tracking-platform-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.125rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: left;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    opacity: 0.5;
    padding: 1.5rem 1rem 0.5rem 1rem;
    margin-top: 0.5rem;
}

.sidebar-nav a.active {
    background: linear-gradient(90deg, var(--primary) 0%, rgba(37, 99, 235, 0.1) 100%);
    color: #fff;
    border-left: 3px solid var(--primary);
}

.sidebar-nav a i {
    font-size: 1.1rem;
    width: 1.5rem;
}

.tracking-platform-link:hover {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateX(4px);
  box-shadow: 0 8px 20px -8px rgba(37, 99, 235, 0.15);
}

.tracking-platform-link img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.platform-icon-wrap {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.platform-info {
  flex: 1;
}

.platform-arrow {
  opacity: 0.3;
  transition: all 0.2s;
}

.tracking-platform-link:hover .platform-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.tracking-platform-link .platform-name {
  flex: 1;
}

.tracking-platform-link .platform-arrow {
  font-size: 1rem;
  color: var(--text-muted);
}

.tracking-platform-link:hover .platform-arrow {
  color: var(--primary);
}

.tracking-platform-placeholder {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tracking-actions {
  margin-top: 1.5rem;
}

.tracking-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.tracking-actions a:hover {
  background: var(--bg-subtle);
  border-color: var(--border);
  color: var(--text);
}

.tracking-error-actions {
  margin-top: 1.5rem;
}

.tracking-error-actions .btn-tracking-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s;
}

.tracking-error-actions .btn-tracking-primary:hover {
  background: var(--primary-hover);
  color: #fff;
}

/* ---- Misc ---- */
.text-muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.code {
  background: var(--bg-subtle);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  font-family: ui-monospace, monospace;
}

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

.form-inline {
  display: inline;
}

.panel-form-max {
  max-width: 520px;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.25rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.25rem;
}

.small {
  font-size: 0.8125rem;
}

/* Secondary button */
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
  color: var(--heading);
}

/* Page subtitle */
.page-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
  font-weight: 400;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 2px dashed var(--border);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light) 0%, rgba(37, 99, 235, 0.05) 100%);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 0.5rem 0;
}

.empty-state-desc {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0 auto 1.5rem;
  max-width: 360px;
  line-height: 1.5;
}

.empty-state .btn {
  min-width: 140px;
}

/* Form sections (add/edit system, add referrer) */
.form-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 2rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.2s;
  min-width: 0;
}

.form-card:hover {
  box-shadow: var(--shadow-md);
}

.form-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 1.25rem 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-card-title i {
  color: var(--primary);
  font-size: 1.25rem;
}

.form-card--basic .form-card-title i {
  color: var(--primary);
}

.form-card--commission .form-card-title i {
  color: var(--success);
}

.form-card--sync .form-card-title i {
  color: var(--text-muted);
}

.form-section {
  margin-bottom: 1.75rem;
}

.form-section:last-of-type {
  margin-bottom: 0;
}

.form-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.form-section-title i {
  font-size: 1rem;
  color: var(--text-muted);
}

.form-section-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: -0.25rem 0 1rem 0;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
}

.form-grid .form-row {
  margin-bottom: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
}

.form-actions .btn-primary {
  min-width: 140px;
}

.logo-preview {
  height: 56px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  padding: 6px;
  background: var(--surface-hover);
  margin-bottom: 0.75rem;
}

/* File upload */
.form input[type="file"] {
  width: 100%;
  max-width: 320px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.form input[type="file"]:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.form input[type="file"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form input[type="file"]::file-selector-button {
  padding: 0.4rem 0.75rem;
  margin-right: 0.75rem;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.form input[type="file"]::file-selector-button:hover {
  background: var(--primary-hover);
}

.file-upload-zone {
  position: relative;
  display: block;
  max-width: 320px;
  padding: 1.25rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.file-upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-upload-zone input[type="file"] {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-upload-zone .file-upload-icon {
  font-size: 1.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

.file-upload-zone:hover .file-upload-icon {
  color: var(--primary);
}

.file-upload-zone .file-upload-text {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.file-upload-zone:hover .file-upload-text {
  color: var(--primary);
}

.file-upload-zone .file-upload-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Referrer form card hero */
.form-card--hero {
  max-width: 560px;
  padding: 2.25rem;
}

.form-card-hero-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary-light) 0%, rgba(37, 99, 235, 0.08) 100%);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

.form-card--hero .form-card-title {
  border: none;
  padding: 0 0 0.5rem 0;
  margin-bottom: 0.5rem;
}

.form-card--hero .form-section-desc {
  margin-bottom: 1.25rem;
}

/* System add/edit expanded layout — full width, no side margins */
.system-form-wrap {
  width: 100%;
  max-width: none;
}

.system-form-wrap .form-card {
  max-width: none;
}

.form-card--wide {
  max-width: none;
  padding: 2rem 2.25rem;
}

.form-card--wide .form-card-title {
  font-size: 1.2rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  margin-bottom: 0;
  line-height: 1.4;
}

.form-grid .form-row .form-hint {
  margin-bottom: 0;
}

.commission-example {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success);
  margin-top: 0.75rem;
}

.commission-example strong {
  color: var(--heading);
}

.api-ref-card {
  background: linear-gradient(135deg, var(--bg-subtle) 0%, var(--surface-hover) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.api-ref-card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.api-ref-card-title i {
  color: var(--primary);
}

.api-ref-card p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
  line-height: 1.5;
}

/* Conversion edit page */
.conversion-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  width: 100%;
  max-width: none;
}

@media (max-width: 768px) {
  .conversion-edit-grid {
    grid-template-columns: 1fr;
  }
}

.detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-item dt {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 6rem;
}

.detail-item dd {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--heading);
}

.form-card--info {
  background: linear-gradient(135deg, var(--info-light) 0%, var(--surface-hover) 100%);
  border-color: rgba(2, 132, 199, 0.2);
}

.form-card--info .form-card-title {
  border-bottom-color: rgba(2, 132, 199, 0.2);
}

.form-card--info .form-card-title i {
  color: var(--info);
}

.form-section-desc.mb-0 {
  margin-bottom: 0;
}

.api-ref-card code {
  display: block;
  font-size: 0.75rem;
  background: var(--surface);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 0.5rem;
  overflow-x: auto;
}

.breadcrumb-links {
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.breadcrumb-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb-links a:hover {
  color: var(--primary);
}

.breadcrumb-links span {
  color: var(--text-muted);
  margin: 0 0.35rem;
}

.sync-subsection {
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-top: 1rem;
  border: 1px solid var(--border-light);
}

.sync-subsection .form-section-title {
  margin-bottom: 1rem;
}

/* Systems cards grid */
.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.system-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.system-summary-item {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.system-summary-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.system-summary-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.system-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
}

.system-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, rgba(37, 99, 235, 0.5) 100%);
  opacity: 0;
  transition: opacity 0.2s;
}

.system-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.system-card:hover {
  transform: translateY(-8px);
  border-color: var(--primary);
  box-shadow: 0 20px 25px -5px rgba(37, 99, 235, 0.1), 0 10px 10px -5px rgba(37, 99, 235, 0.04);
}

.system-card:hover::after {
  opacity: 0.05;
}

.system-card:hover::before {
  opacity: 1;
}

.system-card-head {
  padding: 1.5rem 1.25rem 1rem;
  text-align: center;
  background: linear-gradient(to bottom, var(--bg-subtle) 0%, #fff 100%);
  border-bottom: 1px dashed var(--border-light);
  position: relative;
}

.system-status-dot {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px rgba(16, 185, 129, 0.1), 0 0 12px #10b981;
  z-index: 2;
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.system-status-dot.inactive {
  background: #cbd5e1;
  box-shadow: 0 0 0 3px #fff;
  animation: none;
}

.system-card-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin: 0 auto 0.75rem;
  display: block;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 6px;
  border: 1px solid var(--border-light);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.system-card:hover .system-card-logo {
  transform: scale(1.1) rotate(3deg);
}

.system-card-logo-placeholder {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary-light) 0%, rgba(37, 99, 235, 0.06) 100%);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.system-card-name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--heading);
  margin: 0 0 0.35rem 0;
  letter-spacing: -0.01em;
}

.system-card-url {
  font-size: 0.8125rem;
  color: var(--text-muted);
  word-break: break-all;
  line-height: 1.4;
}

.system-card-body {
  padding: 1.25rem 1.25rem;
  flex: 1;
}

.system-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.system-card-commission {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--heading);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
}

.system-card-meta .badge {
  margin-right: 0.25rem;
}

.system-card-footer {
  padding: 0 1.25rem 1.25rem;
  margin-top: auto;
}

.system-card-footer .btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

/* ========== Dashboard layout ========== */
.dash-layout {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-subtle) 100%);
}

.dash-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.03em;
  transition: color 0.2s;
}

.dash-logo-img {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
}

.dash-logo-text {
  white-space: nowrap;
}

.dash-logo:hover {
  color: var(--primary-hover);
}

.dash-logo:hover .dash-logo-img {
  opacity: 0.9;
}

/* Mobile: header and logo */
@media (max-width: 768px) {
  .dash-header {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    gap: 0.5rem;
  }

  .dash-header-left {
    gap: 0.5rem;
    min-width: 0;
  }

  .dash-logo-text {
    display: none;
  }

  .dash-logo-img {
    height: 32px;
  }

  .dash-search {
    max-width: 120px;
    min-width: 0;
  }

  .dash-header-right .dash-user .dash-user-info {
    display: none;
  }

  .dash-header-right .dash-user>i.bi-chevron-down {
    display: none;
  }

  .dash-header-right a:not(.dash-user):not(.btn-logout-top) span,
  .dash-header-right a:not(.dash-user):not(.btn-logout-top) {
    padding: 0.5rem;
  }

  .dash-header-right a[href="#"] {
    font-size: 0;
    padding: 0.5rem;
  }

  .dash-header-right a[href="#"] i {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .dash-search {
    display: none;
  }
}

.dash-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.25rem;
  transition: background 0.2s, color 0.2s;
}

.dash-toggle:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

.dash-search {
  width: 100%;
  max-width: 280px;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--bg-subtle);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.65rem center;
  transition: border-color 0.2s, background 0.2s;
}

.dash-search::placeholder {
  color: var(--text-muted);
}

.dash-search:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--surface);
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dash-header-right a,
.dash-header-right button {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.dash-header-right a:hover,
.dash-header-right button:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.dash-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
}

.dash-user:hover {
  background: var(--bg-subtle);
}

.dash-user>i {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dash-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.dash-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--heading);
}

.dash-user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.dash-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.dash-body {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
}

.dash-sidebar {
  width: 268px;
  min-width: 268px;
  background: var(--sidebar-bg);
  padding: 1.25rem 0;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width 0.2s, min-width 0.2s;
}

.dash-sidebar.sidebar-collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

/* Sidebar drawer close button — visible on mobile only */
.sidebar-drawer-close {
  display: none;
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-size: 1.25rem;
  z-index: 1;
  transition: background 0.2s;
}

.sidebar-drawer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Mobile: sidebar as overlay drawer */
@media (max-width: 1024px) {
  .dash-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    min-width: 0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out, visibility 0.25s;
    visibility: hidden;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  body.sidebar-drawer-open .dash-sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar-drawer-close {
    display: flex;
  }

  .sidebar-user {
    padding-top: 3rem;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 250;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
  }

  body.sidebar-drawer-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  body.sidebar-drawer-open {
    overflow: hidden;
  }
}

.sidebar-user {
  padding: 0 1.25rem 1.125rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-user .dash-avatar {
  width: 44px;
  height: 44px;
  font-size: 1.05rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-user-name {
  color: #fff;
  font-weight: 600;
  font-size: 0.9375rem;
}

.sidebar-user-role {
  color: var(--sidebar-text-dim);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.sidebar-nav {
  padding: 0 0.75rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin-bottom: 0.15rem;
  transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-nav a i {
  font-size: 1.15rem;
  opacity: 0.95;
}

.sidebar-nav a.nav-logout {
  color: #fcd34d;
  margin-top: 0.5rem;
}

.sidebar-nav a.nav-logout:hover {
  background: rgba(252, 211, 77, 0.15);
  color: #fcd34d;
}

.dash-main {
  flex: 1 1 0%;
  min-width: 0;
  overflow: auto;
  padding: 1.25rem 0.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.dash-main--full,
.dash-main.dash-main--full>* {
  max-width: none;
  width: 100%;
}

/* ---- Dashboard redesign ---- */
.dash-hero {
  margin-bottom: 1.75rem;
  max-width: none;
}

.dash-hero h2 {
  margin: 0 0 0.25rem 0;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash-hero .dash-hero-sub {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Stat cards — redesigned (stacked, icon on top), full width */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
  width: 100%;
  max-width: none;
}

@media (max-width: 900px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  background: currentColor;
  opacity: 0.03;
  border-radius: 50%;
  transition: transform 0.5s;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.stat-card:hover::after {
  transform: scale(1.5);
}

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.stat-card:nth-child(1) .stat-card-icon {
  background: linear-gradient(135deg, var(--primary-light) 0%, rgba(37, 99, 235, 0.12) 100%);
  color: var(--primary);
}

.stat-card:nth-child(2) .stat-card-icon {
  background: linear-gradient(135deg, var(--info-light) 0%, rgba(2, 132, 199, 0.12) 100%);
  color: var(--info);
}

.stat-card:nth-child(3) .stat-card-icon {
  background: linear-gradient(135deg, var(--warning-light) 0%, rgba(202, 138, 4, 0.12) 100%);
  color: var(--warning);
}

.stat-card:nth-child(4) .stat-card-icon {
  background: linear-gradient(135deg, var(--success-light) 0%, rgba(13, 148, 136, 0.12) 100%);
  color: var(--success);
}

.stat-card-body {
  width: 100%;
}

.stat-card-body h6 {
  margin: 0 0 0.4rem 0;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-card-body .value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

/* Dashboard panel (recent activity, etc.) */
.dash-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: none;
}

.dash-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle);
}

.dash-panel-header h3 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
}

.dash-panel-header .dash-panel-action {
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.2s;
}

.dash-panel-header .dash-panel-action:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.dash-panel-body {
  padding: 0;
  overflow-x: auto;
}

.dash-panel-body .table {
  margin: 0;
}

.dash-panel-body .table th,
.dash-panel-body .table td {
  padding: 0.875rem 1.5rem;
}

.dash-panel-body .table-empty {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* Admin: referrer cards (card layout) */
.referrers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
}
.referrer-card {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.referrer-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
}
.referrer-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.25rem 0;
}
.referrer-card-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #3b82f6 50%, #0ea5e9 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.referrer-card-avatar .status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--surface);
}
.referrer-card-avatar:not(.active) .status-indicator {
  background: var(--text-muted);
}
.referrer-card-info {
  min-width: 0;
  flex: 1;
}
.referrer-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--heading);
  margin-bottom: 0.2rem;
  line-height: 1.3;
}
.referrer-card-id {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
}
.role-badge i {
  font-size: 0.75rem;
  opacity: 0.9;
}
.referrer-card-divider {
  margin: 1rem 1.25rem 0;
  border: none;
  border-top: 1px solid var(--border-light);
}
.referrer-card-body {
  padding: 0.75rem 1.25rem 0;
}
.referrer-card-phone {
  font-size: 0.9375rem;
  color: var(--text);
}
.referrer-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1rem 1.25rem 1.25rem;
}
.status-badge-modern {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 500;
}
.status-badge-modern .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.status-badge-modern.active {
  color: var(--success);
}
.status-badge-modern.inactive,
.status-badge-modern.pending {
  color: var(--text-muted);
}
.status-badge-modern.inactive .dot,
.status-badge-modern.pending .dot {
  background: var(--text-muted);
}
.referrer-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.referrer-actions .btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.referrer-actions .btn-icon:hover {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
  color: var(--primary);
}
.referrer-actions .btn-icon--danger:hover {
  background: var(--danger-light);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--danger);
}
.referrer-actions .btn-icon--success:hover {
  background: var(--success-light);
  border-color: rgba(13, 148, 136, 0.3);
  color: var(--success);
}
.referrer-actions form {
  display: inline-flex;
}
.referrer-actions button.btn-icon {
  cursor: pointer;
  font: inherit;
}
.referrers-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
}
.referrers-empty .bi-people {
  font-size: 3rem;
  color: var(--text-muted);
  opacity: 0.5;
}
.referrers-empty h4 {
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 1.125rem;
}
.referrers-empty p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0;
}
.referrers-empty .btn {
  margin-top: 1rem;
}

@media (max-width: 480px) {
  .referrers-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  .referrer-card-header,
  .referrer-card-footer {
    padding-left: 1rem;
  }
  .referrer-card-divider { margin-left: 1rem; margin-right: 1rem; }
  .referrer-card-body { padding-left: 1rem; }
}

/* Referrer: referral link hero card */
.ref-link-card {
  background: linear-gradient(145deg, var(--surface) 0%, var(--bg-subtle) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
  position: relative;
  overflow: hidden;
}

.ref-link-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--info) 100%);
}

.ref-link-card h5 {
  margin: 0 0 0.75rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--heading);
}

.ref-link-card .input-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ref-link-card .input-group input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
}

.ref-link-card .input-group .btn {
  flex-shrink: 0;
}

.ref-link-card .ref-link-hint {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.ref-link-card .ref-link-hint code {
  background: var(--bg-subtle);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8em;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.panel-heading h3 {
  margin: 0;
  font-size: 1.125rem;
}

.panel-action {
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.panel-action:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.panel-body-table {
  margin: 0 -1.5rem -1.5rem;
  padding: 0 1.5rem 1.5rem;
  overflow-x: auto;
}

/* Sync Toggle Styles */
.sync-type-toggle {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.sync-option {
  flex: 1;
  cursor: pointer;
}

.sync-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.sync-option-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
  text-align: center;
}

.sync-option-content i {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.sync-option-content span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sync-option input:checked+.sync-option-content {
  border-color: var(--primary);
  background: var(--primary-light);
}

.sync-option input:checked+.sync-option-content i,
.sync-option input:checked+.sync-option-content span {
  color: var(--primary);
}

.sync-option:hover .sync-option-content {
  border-color: #cbd5e1;
}

.form-row--full {
  grid-column: 1 / -1;
}

.page-subtitle b {
  color: var(--primary);
}

/* ---- Modern UI Components (Floating Labels, Switches, etc.) ---- */

/* Floating Labels */
.form-floating {
  position: relative;
  margin-bottom: 1.25rem;
}

.form-floating>.form-control,
.form-floating>.form-select {
  height: calc(3.5rem + 2px);
  padding: 1rem 0.75rem;
  line-height: 1.25;
}

.form-floating>label {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 1rem 0.75rem;
  overflow: hidden;
  text-align: start;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid transparent;
  transform-origin: 0 0;
  transition: opacity .1s ease-in-out, transform .1s ease-in-out;
  color: var(--text-muted);
  opacity: 0.65;
}

.form-floating>.form-control::placeholder {
  color: transparent;
}

.form-floating>.form-control:focus,
.form-floating>.form-control:not(:placeholder-shown) {
  padding-top: 1.625rem;
  padding-bottom: 0.625rem;
}

.form-floating>.form-control:focus~label,
.form-floating>.form-control:not(:placeholder-shown)~label {
  opacity: 0.65;
  transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

.form-control {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--surface);
  background-clip: padding-box;
  border: 1px solid var(--border);
  appearance: none;
  border-radius: var(--radius-sm);
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.form-control:focus {
  color: var(--text);
  background-color: var(--surface);
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 0.25rem var(--primary-light);
}

/* Custom Switches */
.form-switch {
  padding-left: 2.5em;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-switch .form-check-input {
  width: 2em;
  margin-left: -2.5em;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");
  background-position: left center;
  border-radius: 2em;
  transition: background-position .15s ease-in-out;
}

.form-check-input {
  width: 1.15em;
  height: 1.15em;
  margin-top: 0.175em;
  vertical-align: top;
  background-color: var(--surface);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: 1px solid var(--border);
  appearance: none;
  print-color-adjust: exact;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.form-check-input[type=checkbox] {
  border-radius: 0.25em;
}

.form-switch .form-check-input:checked {
  background-position: right center;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23ffffff'/%3e%3c/svg%3e");
}

.form-check-label {
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

/* File Input */
.file-input-group {
  margin-bottom: 1.25rem;
}

.file-input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-control[type=file] {
  overflow: hidden;
}

.form-control[type=file]:not(:disabled):not([readonly]) {
  cursor: pointer;
}

.form-control::file-selector-button {
  padding: 0.375rem 0.75rem;
  margin: -0.65rem -1rem;
  margin-inline-end: 1rem;
  color: var(--text);
  background-color: var(--bg-subtle);
  pointer-events: none;
  border-color: inherit;
  border-style: solid;
  border-width: 0;
  border-inline-end-width: 1px;
  border-radius: 0;
  transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

/* Form Grid & Cards update */
.system-form-wrap {
  width: 100%;
}

.form-card {
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.form-card-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.75rem;
  font-size: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
  width: 100%;
}

.form-grid-2 .form-col {
  min-width: 0;
}

@media (max-width: 992px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .dash-main {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

.form-select {
  display: block;
  width: 100%;
  padding: 0.375rem 2.25rem 0.375rem 0.75rem;
  -moz-padding-start: calc(0.75rem - 3px);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
  appearance: none;
}

.form-select:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 0.25rem var(--primary-light);
}

/* ========== Modern Utility Classes & Glassmorphism ========== */
.glass {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s, box-shadow 0.3s;
}

.glass:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.12);
}

.glass-dark {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.grid { display: grid; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.rounded-2xl { border-radius: 1rem; }
.rounded-3xl { border-radius: 1.5rem; }
.rounded-full { border-radius: 9999px; }

.p-2 { padding: 0.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.text-white { color: #fff; }
.text-slate-200 { color: #e2e8f0; }
.text-slate-300 { color: #cbd5e1; }
.text-slate-400 { color: #94a3b8; }
.text-slate-500 { color: #64748b; }
.text-slate-600 { color: #475569; }
.text-blue-400 { color: #60a5fa; }
.text-emerald-400 { color: #34d399; }
.text-red-400 { color: #f87171; }
.text-orange-400 { color: #fb923c; }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.avatar-initials {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  text-transform: uppercase;
}

.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-md { width: 44px; height: 44px; font-size: 0.875rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.125rem; }

.badge-role {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.text-gradient-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-icon-pill {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid var(--border-light);
}

.btn-icon-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.1);
  color: var(--primary);
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-up {
  animation: fadeInUp 0.5s forwards ease-out;
}

/* ========== Advanced Chat UI System ========== */
:root {
  --chat-sidebar-width: 320px;
  --bubble-me: #1e293b;
  --bubble-them: #ffffff;
}

.chat-container {
  display: flex;
  height: calc(100vh - 140px);
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(20px);
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  overflow: hidden;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.1);
}

.chat-sidebar {
  width: var(--chat-sidebar-width);
  border-right: 1px solid rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.2);
}

.chat-sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  padding: 1.25rem 1.5rem;
  display: flex;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 1px solid rgba(0,0,0,0.02);
  position: relative;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.4);
}

.chat-item.active {
  background: #fff;
  box-shadow: inset 4px 0 0 var(--primary);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: url("https://www.transparenttextures.com/patterns/cubes.png");
}

.chat-header {
  padding: 1.25rem 2rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-messages {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message-bubble {
  max-width: 70%;
  padding: 1rem 1.25rem;
  border-radius: 20px;
  font-size: 0.9rem;
  position: relative;
  line-height: 1.5;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.message-me {
  align-self: flex-end;
  background: var(--bubble-me);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-them {
  align-self: flex-start;
  background: var(--bubble-them);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(0,0,0,0.05);
}

.message-time {
  font-size: 0.7rem;
  margin-top: 0.5rem;
  opacity: 0.6;
  display: block;
}

.chat-input-area {
  padding: 1.5rem 2rem;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.05);
}

.chat-input-wrapper {
  display: flex;
  gap: 1rem;
  background: var(--bg-subtle);
  padding: 0.5rem;
  border-radius: 20px;
  align-items: center;
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.75rem 1rem;
  outline: none;
  font-size: 0.9rem;
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-send:hover {
  transform: scale(1.05);
  background: var(--primary-hover);
}

.chat-badge {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 800;
}
