/* =========================================================
   OrderTech Tenant Dashboard - NEBULAS UI Kit
   Apple-clean SaaS Design
   Light/Dark via data-theme="light|dark"
   Uses system font stack with modern spacing & subtle depth
   ========================================================= */

/* ---------- 1) Design Tokens ---------- */
:root {
  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "SF Pro Display", "SF Pro Text",
               "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-16: 16px;
  --fs-18: 18px;
  --fs-24: 24px;
  --lh-tight: 1.2;
  --lh-normal: 1.45;

  /* Radius */
  --r-10: 10px;
  --r-12: 12px;
  --r-16: 16px;
  --r-20: 20px;

  /* Spacing (8pt-ish) */
  --s-4: 4px;
  --s-8: 8px;
  --s-12: 12px;
  --s-16: 16px;
  --s-20: 20px;
  --s-24: 24px;
  --s-32: 32px;

  /* Motion */
  --ease: cubic-bezier(.2,.8,.2,1);
  --t-quick: 140ms;
  --t-med: 220ms;

  /* Shadow (subtle, premium) */
  --sh-1: 0 1px 1px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --sh-2: 0 2px 6px rgba(0,0,0,.06), 0 16px 40px rgba(0,0,0,.10);

  /* Focus */
  --focus: 0 0 0 4px rgba(0, 122, 255, .18);

  /* Brand Accent (OrderTech Blue) */
  --accent: #0A84FF; /* Apple-like blue */
  --accent-2: #30D158; /* success green */
  --warn: #FF9F0A;
  --danger: #FF453A;

  /* Layout */
  --sidebar-w: 272px;
  --topbar-h: 64px;
}

/* ---------- 2) Light Theme ONLY ---------- */
:root, [data-theme="light"], [data-theme="dark"], [data-bs-theme="light"], [data-bs-theme="dark"] {
  /* Force light mode colors for ALL theme attributes */
  --bg: #F5F6F8;
  --panel: rgba(255,255,255,.72);
  --panel-solid: #FFFFFF;
  --text: #0B0F17;
  --muted: rgba(11,15,23,.62);
  --border: rgba(11,15,23,.10);
  --border-strong: rgba(11,15,23,.16);
  --card: rgba(255,255,255,.80);
  --hover: rgba(11,15,23,.04);
  --glass: saturate(180%) blur(16px);
}

/* ---------- 3) Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
::selection { background: rgba(10,132,255,.25); }

/* ---------- 4) App Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--t-med) var(--ease);
}

.app:has(.sidebar.collapsed) {
  grid-template-columns: 80px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--s-16);
  border-right: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: var(--glass);
  overflow-y: auto;
  transition: width var(--t-med) var(--ease), padding var(--t-med) var(--ease);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: 80px;
  padding: var(--s-12) var(--s-8);
}

.sidebar.collapsed .sidebar-logo {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: var(--s-12) 0;
}

.sidebar.collapsed .sidebar-toggle {
  margin-left: 0;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .tenant-name,
.sidebar.collapsed .tenant-id {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .nav-item i {
  margin: 0;
}

.sidebar.collapsed .nav-item-parent .expand-icon {
  display: none;
}

.sidebar.collapsed .nav-submenu {
  display: none;
}

.sidebar.collapsed .tenant-info {
  justify-content: center;
}

.sidebar.collapsed .tenant-avatar {
  margin: 0;
}

@media (max-width: 1024px) {
  .sidebar.collapsed {
    width: 80px;
  }
}

.main,
.main-content {
  min-width: 0;
  display: block;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-24);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: var(--glass);
}

.content {
  padding: var(--s-24);
  padding-top: calc(72px + var(--s-16));
  max-width: 1240px;
}

/* ---------- 5) Typography ---------- */
.h1,
.page-title { 
  font-size: var(--fs-24); 
  line-height: var(--lh-tight); 
  margin: 0; 
  letter-spacing: -0.02em; 
  font-weight: 700;
}

.h2,
.card-title { 
  font-size: var(--fs-18); 
  line-height: var(--lh-tight); 
  margin: 0; 
  letter-spacing: -0.01em; 
  font-weight: 650;
}

.p,
.page-subtitle { 
  font-size: var(--fs-14); 
  color: var(--muted); 
  margin: 0; 
}

.kbd { 
  font-size: var(--fs-12); 
  padding: 2px 8px; 
  border: 1px solid var(--border); 
  border-radius: 999px; 
}

/* ---------- 6) Sidebar Nav ---------- */
.brand,
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-12);
  padding: 11px var(--s-12);
  margin-bottom: 11px;
}

.brand .logo,
.sidebar-logo {
  height: 100px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  display: block;
}

.brand .name,
.sidebar-title { 
  display: none;
}

.sidebar-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--t-quick) var(--ease), color var(--t-quick) var(--ease);
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--hover);
  color: var(--text);
}

.sidebar-toggle i {
  font-size: 14px;
}

.card-sub {
  font-size: var(--fs-13); 
  color: var(--muted);
}

.nav,
.sidebar-nav {
  display: grid;
  gap: 1px;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.nav a,
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  padding: 4px 12px;
  border-radius: 12px;
  color: var(--muted);
  transition: background var(--t-quick) var(--ease), color var(--t-quick) var(--ease);
  text-decoration: none;
  font-size: var(--fs-14);
}

.nav a:hover,
.nav-item:hover { 
  background: var(--hover); 
  color: var(--text); 
}

.nav a[aria-current="page"],
.nav a.active,
.nav-item.active {
  background: rgba(10,132,255,.12);
  color: var(--text);
  border: 1px solid rgba(10,132,255,.22);
}

.nav-item i {
  font-size: 18px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: var(--s-12) 0;
}

/* Submenu Expandable */
.nav-item-parent {
  cursor: pointer;
  position: relative;
  display: flex !important;
  align-items: center !important;
}

.nav-item-parent > span {
  flex: 1;
}

.nav-item-parent .expand-icon {
  margin-left: auto;
  font-size: 12px;
  transition: transform var(--t-med) var(--ease);
  opacity: 0.6;
}

.nav-item-parent:hover .expand-icon {
  opacity: 1;
}

.nav-item-parent.expanded .expand-icon {
  transform: rotate(180deg);
}

.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--t-med) var(--ease);
  padding-left: 24px;
  display: block;
}

.nav-submenu.expanded {
  max-height: 500px;
  padding-top: 2px;
  padding-bottom: 2px;
}

.nav-submenu .nav-item {
  padding: 5px 12px;
  font-size: var(--fs-13);
  margin-bottom: 0;
}

.nav-submenu .nav-item i {
  font-size: 16px;
  width: 16px;
  height: 16px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--s-12);
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
}

.tenant-info {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  padding: var(--s-8);
  border-radius: 12px;
}

.tenant-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(10,132,255,.18), rgba(10,132,255,.05));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--fs-13);
  border: 1px solid var(--border);
}

.tenant-name {
  font-size: var(--fs-14);
  font-weight: 600;
  color: var(--text);
}

.tenant-id {
  font-size: var(--fs-12);
  color: var(--muted);
}

/* ---------- 7) Controls ---------- */
.search,
.searchbar {
  display: flex;
  align-items: center;
  gap: var(--s-8);
  width: min(520px, 50vw);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
}

.search input,
.searchbar input {
  border: 0; 
  outline: 0; 
  background: transparent;
  width: 100%;
  color: var(--text);
}

.search:focus-within,
.searchbar:focus-within {
  border-color: rgba(10,132,255,.55);
  box-shadow: var(--focus);
}

.icon-btn {
  width: 40px; 
  height: 40px;
  display: grid; 
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 0 rgba(255,255,255,.04);
  transition: transform var(--t-quick) var(--ease), background var(--t-quick) var(--ease);
  cursor: pointer;
}

.icon-btn:hover { 
  background: var(--hover); 
}

.icon-btn:active { 
  transform: translateY(1px); 
}

/* ---------- 8) Buttons ---------- */
.btn,
.btn-secondary,
.btn-danger,
.btn-ghost {
  height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  cursor: pointer;
  font-size: var(--fs-14);
  font-weight: 600;
  transition: transform var(--t-quick) var(--ease), background var(--t-quick) var(--ease), border var(--t-quick) var(--ease);
}

.btn:hover,
.btn-secondary:hover { 
  background: var(--hover); 
}

.btn:active,
.btn-secondary:active { 
  transform: translateY(1px); 
}

.btn:focus-visible { 
  outline: none; 
  box-shadow: var(--focus); 
  border-color: rgba(10,132,255,.45); 
}

.btn.primary,
.btn-primary {
  border-color: rgba(10,132,255,.40);
  background: linear-gradient(180deg, rgba(10,132,255,.95), rgba(10,132,255,.78));
  color: white;
  box-shadow: 0 10px 24px rgba(10,132,255,.20);
}

.btn.primary:hover,
.btn-primary:hover {
  filter: brightness(1.03);
}

.btn.secondary {
  /* Uses default btn styles */
}

.btn-danger {
  border-color: rgba(255,69,58,.40);
  background: rgba(255,69,58,.12);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--hover);
}

.btn.sm {
  height: 32px;
  padding: 0 12px;
  font-size: var(--fs-13);
}

/* ---------- 9) Cards / Panels ---------- */
.grid,
.stats-grid,
.dashboard-grid {
  display: grid;
  gap: var(--s-16);
}

.grid-3,
.stats-grid { 
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  align-items: start;
}

@media (max-width: 1100px) { 
  .grid-3,
  .stats-grid { 
    grid-template-columns: 1fr; 
  } 
}

.card,
.stat-card {
  border-radius: var(--r-20);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
  padding: var(--s-20);
  transition: transform var(--t-quick) var(--ease), box-shadow var(--t-quick) var(--ease);
}

.card:hover,
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-12);
  margin-bottom: var(--s-12);
}

/* Fix for stats cards - no bottom margin needed */
.stats-grid .card .card-header {
  margin-bottom: var(--s-8);
}

.card-title { 
  font-weight: 650; 
  letter-spacing: -0.01em;
  font-size: var(--fs-16);
}

.card-sub { 
  font-size: var(--fs-13); 
  color: var(--muted); 
}

.card-body {
  padding: 0;
}

/* Banner Card (Digital Signage) */
.banner-card {
  border-radius: var(--r-16);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--sh-1);
  transition: transform var(--t-quick) var(--ease), box-shadow var(--t-quick) var(--ease);
}

.banner-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
}

/* KPI / Stats */
.kpi,
.stat-content {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-16);
}

/* Compact KPI for stats grid */
.stats-grid .card .kpi {
  align-items: center;
  margin-top: var(--s-8);
}

.kpi .value,
.stat-value { 
  font-size: 28px; 
  letter-spacing: -0.02em; 
  font-weight: 720; 
  color: var(--text);
}

.kpi .meta,
.stat-label { 
  font-size: var(--fs-13); 
  color: var(--muted); 
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(10,132,255,.12);
  border: 1px solid rgba(10,132,255,.22);
}

/* ---------- 10) Badges ---------- */
.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: var(--fs-12);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  font-weight: 600;
}

.badge-dot { 
  width: 8px; 
  height: 8px; 
  border-radius: 999px; 
  background: var(--muted); 
}

.badge-online,
.badge-success,
.chip.ok { 
  border-color: rgba(48,209,88,.35); 
  background: rgba(48,209,88,.12);
  color: var(--text);
}

.badge-online .badge-dot,
.badge-success .badge-dot { 
  background: var(--accent-2); 
}

.badge-offline,
.badge-warning { 
  border-color: rgba(255,159,10,.35); 
  background: rgba(255,159,10,.12);
  color: var(--text);
}

.badge-offline .badge-dot,
.badge-warning .badge-dot { 
  background: var(--warn); 
}

.badge-error,
.badge-danger,
.chip.danger { 
  border-color: rgba(255,69,58,.35); 
  background: rgba(255,69,58,.12);
  color: var(--text);
}

.badge-error .badge-dot,
.badge-danger .badge-dot { 
  background: var(--danger); 
}

.badge.success {
  border-color: rgba(48,209,88,.35); 
  background: rgba(48,209,88,.12);
  color: var(--text);
}

.badge.danger {
  border-color: rgba(255,69,58,.35); 
  background: rgba(255,69,58,.12);
  color: var(--text);
}

.badge-info { 
  border-color: rgba(10,132,255,.35); 
  background: rgba(10,132,255,.12);
  color: var(--text);
}

/* ---------- 11) Table ---------- */
.table,
.table-container table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--r-16);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--sh-1);
}

.table th, 
.table td {
  padding: 12px 14px;
  font-size: var(--fs-13);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  color: var(--muted);
  font-weight: 650;
  text-align: left;
  background: rgba(255,255,255,.06);
  text-transform: uppercase;
  font-size: var(--fs-12);
  letter-spacing: 0.05em;
}

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

.table tr:last-child td { 
  border-bottom: 0; 
}

.table-container {
  overflow-x: auto;
  border-radius: var(--r-16);
}

/* ---------- 12) Forms ---------- */
.field,
.form-group {
  display: grid;
  gap: 6px;
  margin-bottom: var(--s-16);
}

.label,
.form-label { 
  font-size: var(--fs-13); 
  color: var(--muted);
  font-weight: 600;
}

.input, 
.form-input,
select, 
.select,
.select-input,
textarea,
.textarea {
  height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline: none;
  font-size: var(--fs-14);
  transition: border var(--t-quick) var(--ease), box-shadow var(--t-quick) var(--ease);
}

textarea,
.textarea { 
  min-height: 96px; 
  height: auto; 
  resize: vertical; 
}

.input:focus, 
.form-input:focus,
select:focus, 
.select:focus,
textarea:focus,
.textarea:focus {
  border-color: rgba(10,132,255,.55);
  box-shadow: var(--focus);
}

.input::placeholder,
.textarea::placeholder,
input::placeholder,
select::placeholder,
textarea::placeholder {
  color: rgba(11,15,23,.25);
  opacity: 1;
}

/* File Upload */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: var(--r-16);
  padding: var(--s-24);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-quick) var(--ease);
  background: rgba(255,255,255,.03);
}

.file-upload:hover {
  border-color: rgba(10,132,255,.55);
  background: rgba(10,132,255,.06);
}

.file-upload-icon {
  font-size: 48px;
  color: var(--muted);
  margin-bottom: var(--s-12);
}

.file-upload-text {
  color: var(--muted);
  font-size: var(--fs-14);
}

/* ---------- 13) Modal ---------- */
.modal-backdrop,
.modal-overlay {
  position: fixed; 
  inset: 0;
  background: rgba(0,0,0,.42);
  display: grid;
  place-items: center;
  padding: var(--s-24);
  z-index: 50;
}

.modal-backdrop.hidden,
.modal-overlay.hidden {
  display: none;
}

.modal {
  width: min(720px, 100%);
  border-radius: var(--r-20);
  border: 1px solid var(--border);
  background: var(--panel-solid);
  box-shadow: var(--sh-2);
  overflow: hidden;
  max-height: 90vh;
}

.modal-head, 
.modal-header,
.modal-foot,
.modal-footer {
  padding: var(--s-16) var(--s-20);
  border-bottom: 1px solid var(--border);
}

.modal-head .title,
.modal-header .title,
.modal-title {
  font-size: var(--fs-18);
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.modal-foot,
.modal-footer { 
  border-bottom: 0; 
  border-top: 1px solid var(--border); 
  display:flex; 
  justify-content:flex-end; 
  gap: var(--s-12); 
}

.modal-body,
.modal .content { 
  padding: var(--s-20);
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: var(--s-8);
  border-radius: 10px;
  transition: background var(--t-quick) var(--ease);
}

.modal-close:hover {
  background: var(--hover);
}

/* ---------- 14) Toast ---------- */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(420px, calc(100vw - 40px));
  border-radius: var(--r-16);
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: var(--glass);
  box-shadow: var(--sh-2);
  padding: 12px 14px;
  z-index: 60;
}

/* ---------- 15) Page Header ---------- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--s-16);
  gap: var(--s-16);
}

.header-left {
  flex: 1;
}

.header-right {
  display: flex;
  gap: var(--s-12);
  align-items: center;
}

/* ---------- 16) Device List ---------- */
.device-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
}

.device-item {
  display: flex;
  align-items: center;
  gap: var(--s-16);
  padding: var(--s-16);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-16);
  transition: all var(--t-quick) var(--ease);
}

.device-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-1);
}

.device-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(10,132,255,.12);
  border: 1px solid rgba(10,132,255,.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.device-info {
  flex: 1;
}

.device-name {
  font-weight: 600;
  color: var(--text);
  font-size: var(--fs-14);
  margin-bottom: 4px;
}

.device-meta {
  font-size: var(--fs-13);
  color: var(--muted);
}

.device-status {
  flex-shrink: 0;
}

/* ---------- 17) Alerts ---------- */
.alert {
  padding: var(--s-16);
  border-radius: var(--r-16);
  margin-bottom: var(--s-16);
  display: flex;
  align-items: flex-start;
  gap: var(--s-12);
  border: 1px solid var(--border);
}

.alert-success {
  background: rgba(48,209,88,.12);
  border-color: rgba(48,209,88,.35);
}

.alert-warning {
  background: rgba(255,159,10,.12);
  border-color: rgba(255,159,10,.35);
}

.alert-danger {
  background: rgba(255,69,58,.12);
  border-color: rgba(255,69,58,.35);
}

.alert-info {
  background: rgba(10,132,255,.12);
  border-color: rgba(10,132,255,.35);
}

/* ---------- 18) Utilities ---------- */
.hidden { 
  display: none !important; 
}

.text-center { 
  text-align: center; 
}

.text-right { 
  text-align: right; 
}

.mt-1 { margin-top: var(--s-8); }
.mt-2 { margin-top: var(--s-16); }
.mt-3 { margin-top: var(--s-24); }
.mb-1 { margin-bottom: var(--s-8); }
.mb-2 { margin-bottom: var(--s-16); }
.mb-3 { margin-bottom: var(--s-24); }

.flex { 
  display: flex; 
}

.flex-col { 
  flex-direction: column; 
}

.items-center { 
  align-items: center; 
}

.justify-between { 
  justify-content: space-between; 
}

.gap-1 { gap: var(--s-8); }
.gap-2 { gap: var(--s-16); }
.gap-3 { gap: var(--s-24); }

.spacer {
  flex: 1 1 auto;
}

.muted {
  color: var(--muted);
}

/* ---------- 19) Responsive Sidebar ---------- */
@media (max-width: 980px) {
  .app { 
    grid-template-columns: 1fr; 
  }
  
  .sidebar { 
    position: relative; 
    height: auto; 
    border-right: 0; 
    border-bottom: 1px solid var(--border); 
  }
  
  :root { 
    --sidebar-w: 1fr; 
  }
  
  .main,
  .main-content {
    grid-template-rows: auto 1fr;
  }
  
  .topbar {
    position: relative;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 1000;
    height: 100vh;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .content {
    padding: var(--s-16);
  }
  
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .stats-grid,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  
  .search,
  .searchbar {
    width: 100%;
  }
  
  .topbar {
    padding: 0 var(--s-16);
    flex-wrap: wrap;
    gap: var(--s-12);
  }
}

/* Mobile sidebar backdrop */
.sidebar-dim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  display: none;
  z-index: 999;
}

.sidebar-dim.show {
  display: block;
}

/* ---------- 20) Activation Code Display ---------- */
#generatedCodeSection {
  margin-top: var(--s-16);
  padding: var(--s-20);
  background: rgba(10,132,255,.08);
  border: 1px solid rgba(10,132,255,.22);
  border-radius: var(--r-16);
  text-align: center;
}

#generatedCode {
  font-size: 32px;
  font-weight: 720;
  letter-spacing: 0.05em;
  color: var(--text);
  margin: var(--s-12) 0;
  font-family: var(--font-sans);
}

/* Copy button for activation code */
.copy-btn {
  margin-top: var(--s-12);
}

/* ---------- 21) Color Picker ---------- */
input[type="color"] {
  width: 64px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
}

/* ---------- 22) Progress Bar ---------- */
.progress {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,.06);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress .bar {
  height: 100%;
  background: linear-gradient(90deg, rgba(10,132,255,.95), rgba(10,132,255,.78));
  transition: width var(--t-med) var(--ease);
}
