@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

:root {
  --green-900: #064e3b;
  --green-800: #065f46;
  --green-700: #047857;
  --green-600: #059669;
  --green-500: #10b981;
  --green-400: #34d399;
  --green-100: #d1fae5;
  --green-50:  #ecfdf5;
  --slate-950: #0a0f1e;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --white: #ffffff;
  --red-500: #ef4444;
  --red-100: #fee2e2;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --purple-500: #8b5cf6;
  --purple-100: #ede9fe;

  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.08);
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--slate-50);
  color: var(--slate-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── LAYOUT ─────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--slate-900);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--slate-800);
}

.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 36px; height: 36px;
  background: var(--green-600);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.logo-text { color: var(--white); font-weight: 600; font-size: 1rem; line-height: 1.2; }
.logo-sub { color: var(--slate-400); font-size: .72rem; font-weight: 400; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-section { margin-bottom: 24px; }
.nav-section-label {
  color: var(--slate-500);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--slate-400);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 400;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--slate-800); color: var(--white); }
.nav-item.active { background: var(--green-800); color: var(--green-400); font-weight: 500; }
.nav-item .icon { width: 18px; height: 18px; opacity: .7; flex-shrink: 0; }
.nav-item.active .icon { opacity: 1; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--slate-800);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--slate-800);
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--green-700);
  display: flex; align-items: center; justify-content: center;
  color: var(--white); font-weight: 600; font-size: .8rem;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: var(--white); font-size: .82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--slate-400); font-size: .72rem; text-transform: capitalize; }

.main-content {
  margin-left: 248px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 1.25rem; font-weight: 600; color: var(--slate-900); }
.page-subtitle { font-size: .82rem; color: var(--slate-500); margin-top: 1px; }

.page-body { padding: 28px 32px; flex: 1; }

/* ─── CARDS ─────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--slate-100);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: .95rem; font-weight: 600; color: var(--slate-900); }
.card-body { padding: 22px; }

/* ─── STATS ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: .75rem; font-weight: 500; color: var(--slate-500); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--slate-900); line-height: 1; }
.stat-sub { font-size: .78rem; color: var(--slate-400); margin-top: 4px; }
.stat-icon { float: right; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.stat-green .stat-icon { background: var(--green-50); }
.stat-green .stat-value { color: var(--green-700); }

/* ─── BUTTONS ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: .875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn-primary { background: var(--green-600); color: var(--white); }
.btn-primary:hover { background: var(--green-700); }
.btn-secondary { background: var(--slate-100); color: var(--slate-700); border: 1px solid var(--slate-200); }
.btn-secondary:hover { background: var(--slate-200); }
.btn-danger { background: var(--red-100); color: var(--red-500); }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: transparent; color: var(--slate-600); }
.btn-ghost:hover { background: var(--slate-100); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ─── FORMS ─────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--slate-700);
  margin-bottom: 6px;
}
.form-label .req { color: var(--red-500); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: .88rem;
  color: var(--slate-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
.form-control::placeholder { color: var(--slate-400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: .75rem; color: var(--slate-400); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── TABLE ─────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--slate-200);
  background: var(--slate-50);
  white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--slate-100); color: var(--slate-700); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--slate-50); }

/* ─── BADGES ─────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-gray { background: var(--slate-100); color: var(--slate-500); }
.badge-blue { background: var(--blue-100); color: var(--blue-500); }
.badge-amber { background: var(--amber-100); color: #b45309; }
.badge-purple { background: var(--purple-100); color: var(--purple-500); }
.badge-green { background: var(--green-100); color: var(--green-700); }
.badge-emerald { background: #d1fae5; color: var(--green-800); }
.badge-red { background: var(--red-100); color: var(--red-500); }

/* ─── ALERTS ─────────────────────────────── */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start; }
.alert-error { background: var(--red-100); color: #991b1b; border-left: 3px solid var(--red-500); }
.alert-success { background: var(--green-50); color: var(--green-800); border-left: 3px solid var(--green-500); }
.alert-info { background: var(--blue-100); color: #1e40af; border-left: 3px solid var(--blue-500); }
.alert-warning { background: var(--amber-100); color: #92400e; border-left: 3px solid var(--amber-500); }

/* ─── PUBLIC / FULL-PAGE ─────────────────── */
.public-shell {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--slate-900) 0%, var(--green-900) 100%);
  display: flex;
  flex-direction: column;
}

.public-nav {
  padding: 20px 32px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.public-nav .nav-logo {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
}
.public-nav .nav-logo-text { color: var(--white); font-weight: 600; font-size: 1rem; }
.public-nav .nav-logo-sub { color: rgba(255,255,255,.4); font-size: .75rem; }

.public-hero {
  padding: 48px 32px 36px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}
.public-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  margin-bottom: 12px;
}
.public-hero p { color: rgba(255,255,255,.6); font-size: 1rem; line-height: 1.6; }

.public-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px;
  max-width: 520px;
  margin: 0 auto 48px;
  width: calc(100% - 48px);
}

/* ─── LOGIN PAGE ─────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  background: var(--slate-900);
}
.login-left {
  flex: 1;
  background: linear-gradient(160deg, var(--green-900) 0%, var(--slate-900) 100%);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(16,185,129,.06);
  top: -100px; right: -100px;
}
.login-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(16,185,129,.04);
  bottom: -80px; left: -80px;
}
.login-right {
  width: 460px;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
}
.login-form-wrap { width: 100%; max-width: 360px; }
.login-title { font-size: 1.6rem; font-weight: 700; color: var(--slate-900); margin-bottom: 6px; }
.login-sub { font-size: .88rem; color: var(--slate-500); margin-bottom: 32px; }

/* ─── VOUCHER CODE ─────────────────────────── */
.voucher-code {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: .12em;
  color: var(--green-700);
  background: var(--green-50);
  border: 1.5px solid var(--green-200);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  display: inline-block;
}

/* ─── DEVICE SEARCH ─────────────────────────── */
.device-card {
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--white);
}
.device-card:hover { border-color: var(--green-400); background: var(--green-50); }
.device-card.selected { border-color: var(--green-500); background: var(--green-50); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.device-card-name { font-weight: 600; color: var(--slate-900); margin-bottom: 4px; }
.device-card-mfr { font-size: .8rem; color: var(--slate-500); margin-bottom: 8px; }
.device-card-meta { display: flex; gap: 12px; }
.device-chip {
  background: var(--slate-100); color: var(--slate-600);
  border-radius: 99px; padding: 2px 10px; font-size: .73rem; font-weight: 500;
}
.device-chip-green { background: var(--green-50); color: var(--green-700); }

/* ─── STEP INDICATOR ─────────────────────────── */
.steps { display: flex; gap: 0; margin-bottom: 32px; }
.step {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--slate-100);
  border-radius: 0;
  position: relative;
}
.step:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.step:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.step.active { background: var(--green-600); }
.step.done { background: var(--green-800); }
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  color: var(--white);
  font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step:not(.active):not(.done) .step-num { background: var(--slate-300); color: var(--slate-600); }
.step-label { font-size: .78rem; font-weight: 500; color: var(--white); }
.step:not(.active):not(.done) .step-label { color: var(--slate-500); }
.step-arrow {
  position: absolute; right: -10px; top: 0; bottom: 0;
  width: 20px; z-index: 1;
}

/* ─── MISC ─────────────────────────────── */
.mono { font-family: var(--font-mono); font-size: .85em; }
.text-muted { color: var(--slate-400); }
.text-sm { font-size: .82rem; }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.divider { border: none; border-top: 1px solid var(--slate-200); margin: 24px 0; }

.amount-display {
  font-size: 2rem; font-weight: 700; color: var(--green-700);
  font-variant-numeric: tabular-nums;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--slate-400);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--slate-500); margin-bottom: 6px; }

/* ─── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .login-left { display: none; }
  .login-right { width: 100%; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

/* ─── ANIMATIONS ─────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .25s ease forwards; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.pulse { animation: pulse 2s infinite; }
