/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #0f172a;
  --surface:  #1e293b;
  --surface2: #263348;
  --border:   #334155;
  --primary:  #4f46e5;
  --primary-h:#6366f1;
  --success:  #059669;
  --warning:  #d97706;
  --danger:   #dc2626;
  --text:     #f1f5f9;
  --muted:    #94a3b8;
  --radius:   8px;
}
html { font-size: 16px; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; line-height: 1.6; min-height: 100vh; }

/* ─── Layout ───────────────────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 100; }
.main-area { margin-left: 240px; flex: 1; min-height: 100vh; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 28px; display: flex; align-items: center; justify-content: space-between; }
.page-content { padding: 28px; max-width: 1200px; }

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; text-decoration: none; }
.sidebar-logo .logo-icon { width: 36px; height: 36px; background: var(--primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; color: #fff; }
.sidebar-logo .logo-text { font-weight: 700; font-size: 17px; color: var(--text); }
.sidebar-logo .logo-sub  { font-size: 11px; color: var(--muted); }
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 12px 20px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 20px; color: var(--muted); text-decoration: none; font-size: 14px; transition: background .15s, color .15s; border-left: 3px solid transparent; }
.nav-link:hover, .nav-link.active { background: var(--surface2); color: var(--text); border-left-color: var(--primary); }
.nav-link .icon { width: 18px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar-user-name { font-weight: 600; color: var(--text); }
.sidebar-user-role { font-size: 11px; color: var(--muted); }

/* ─── Topbar ───────────────────────────────────────────────────────────────── */
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.btn-logout { background: none; border: 1px solid var(--border); color: var(--muted); padding: 6px 14px; border-radius: var(--radius); cursor: pointer; font-size: 13px; text-decoration: none; transition: color .15s, border-color .15s; }
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.card-muted { font-size: 12px; color: var(--muted); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ─── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: var(--surface2); color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

/* ─── Badges ───────────────────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 100px; }
.badge-success { background: rgba(5,150,105,.2); color: #34d399; }
.badge-warning { background: rgba(217,119,6,.2); color: #fbbf24; }
.badge-danger  { background: rgba(220,38,38,.2); color: #f87171; }
.badge-primary { background: rgba(79,70,229,.2); color: #818cf8; }
.badge-muted   { background: rgba(148,163,184,.1); color: var(--muted); }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: opacity .15s; }
.btn:hover { opacity: .88; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-ghost   { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-sm      { padding: 5px 10px; font-size: 12px; }

/* ─── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-control { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: var(--radius); font-size: 14px; transition: border-color .2s; }
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control::placeholder { color: var(--muted); }
select.form-control option { background: var(--surface); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ─── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 20px; border-left: 4px solid; }
.alert-success { background: rgba(5,150,105,.1); border-color: var(--success); color: #6ee7b7; }
.alert-error   { background: rgba(220,38,38,.1);  border-color: var(--danger);  color: #fca5a5; }
.alert-warning { background: rgba(217,119,6,.1);  border-color: var(--warning); color: #fcd34d; }
.alert-info    { background: rgba(79,70,229,.1);  border-color: var(--primary); color: #a5b4fc; }

/* ─── Section header ───────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-title { font-size: 20px; font-weight: 700; }

/* ─── Toggle switch ────────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 24px; cursor: pointer; transition: background .2s; }
.toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ─── Login page ───────────────────────────────────────────────────────────── */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 40px; width: 100%; max-width: 420px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon { font-size: 40px; }
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p { font-size: 13px; color: var(--muted); }

/* ─── Purchase / landing ───────────────────────────────────────────────────── */
.purchase-hero { text-align: center; padding: 80px 24px 60px; }
.purchase-hero h1 { font-size: 42px; font-weight: 800; background: linear-gradient(135deg, #818cf8, #4f46e5); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.purchase-hero p { font-size: 18px; color: var(--muted); max-width: 600px; margin: 12px auto 0; }
.modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 0 24px 60px; max-width: 1200px; margin: 0 auto; }
.module-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px 24px; transition: border-color .2s, transform .2s; cursor: pointer; }
.module-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.module-card.selected { border-color: var(--primary); background: rgba(79,70,229,.08); }
.module-card .mod-icon { font-size: 36px; margin-bottom: 12px; }
.module-card h3 { font-size: 18px; font-weight: 700; }
.module-card p { font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.module-card .price { font-size: 22px; font-weight: 700; color: var(--primary); }
.module-card .price small { font-size: 13px; color: var(--muted); font-weight: 400; }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; padding: 20px 0; }
.page-link { padding: 6px 12px; border-radius: 6px; background: var(--surface2); color: var(--text); text-decoration: none; font-size: 14px; border: 1px solid var(--border); }
.page-link.active { background: var(--primary); border-color: var(--primary); }
.page-link:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ─── Misc ─────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-success { color: #34d399; }
.text-danger  { color: #f87171; }
.mb-0 { margin-bottom: 0; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.justify-between { justify-content: space-between; }
