:root {
  --bg-root: #090b12;
  --bg-surface: #111420;
  --bg-elevated: #181c2c;
  --bg-hover: #20253a;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --violet: #8b5cf6;
  --violet-soft: rgba(139, 92, 246, 0.16);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.15);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.15);
  --rose: #ef4444;
  --rose-soft: rgba(239, 68, 68, 0.16);
  --sky: #0ea5e9;
  --sky-soft: rgba(14, 165, 233, 0.16);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --sidebar-w: 264px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-root);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--violet); text-decoration: none; }
img { max-width: 100%; display: block; }
.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.tiny { font-size: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.min-w-0 { min-width: 0; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-md { display: flex; flex-direction: column; gap: 16px; }
.row-gap-xs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-gap-sm { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* AUTH GATE */
.auth-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(600px circle at 15% 15%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(500px circle at 85% 80%, rgba(245, 158, 11, 0.14), transparent 60%),
    var(--bg-root);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand h1 { font-size: 20px; font-weight: 800; margin-top: 4px; }
.brand-shield {
  width: 52px; height: 52px; border-radius: 16px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 24px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(245, 158, 11, 0.25));
  border: 1px solid rgba(139, 92, 246, 0.45);
}
.brand-shield.sm { width: 38px; height: 38px; border-radius: 11px; font-size: 18px; }
.auth-hint { color: var(--text-muted); font-size: 13px; }
.auth-step { display: flex; flex-direction: column; gap: 14px; }
.auth-footer-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* SHELL LAYOUT */
.app-shell { display: flex; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: 40;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.brand-inline { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-title { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 10px 12px 4px; }
.nav-item {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left; font-weight: 500; font-size: 13.5px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text); }
.nav-item.active { background: var(--violet-soft); color: #fff; border-color: rgba(139, 92, 246, 0.35); font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.admin-summary { display: flex; align-items: center; gap: 10px; }

.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 64px; padding: 0 20px;
  background: rgba(17, 20, 32, 0.88); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.page-title { font-size: 17px; font-weight: 700; }
.main-content { flex: 1; padding: 20px; max-width: 1440px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* FORMS & BUTTONS (48px touch comfort) */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--bg-root); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--violet); }
.check-row {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px;
  background: var(--bg-root); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.check-row input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--violet); }

.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: transform 0.08s, background 0.15s, border-color 0.15s; white-space: nowrap;
}
.btn:active, .icon-btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-lg { min-height: 48px; font-size: 14.5px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 12.5px; }
.btn-xs { min-height: 32px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--violet); color: #fff; }
.btn-primary:hover { background: #7c3aed; }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-success { background: var(--emerald); color: #052e16; }
.btn-danger { background: var(--rose); color: #fff; }
.btn-danger-soft { background: var(--rose-soft); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--bg-elevated); }
.btn-link { background: none; border: none; color: var(--violet); font-weight: 600; cursor: pointer; padding: 4px 0; font-size: 13px; }
.icon-btn { min-width: 44px; padding: 0; background: var(--bg-elevated); color: var(--text); border-color: var(--border); font-size: 16px; }

/* CARDS, KPI & LAUNCHPAD */
.panel { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; }
.kpi-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-val { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11.5px; color: var(--text-muted); }

.launchpad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.launch-tile {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px; text-align: left; cursor: pointer; color: var(--text);
  display: flex; align-items: center; gap: 12px; min-height: 76px;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}
.launch-tile:hover { transform: translateY(-2px); background: var(--bg-elevated); border-color: var(--violet); }
.launch-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 20px; background: var(--violet-soft);
}

/* TOOLBARS & TABS */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search-box { flex: 1; min-width: 220px; max-width: 420px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tab-btn {
  min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-muted);
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab-btn.active { background: var(--violet-soft); color: #fff; border-color: rgba(139, 92, 246, 0.45); }

/* BADGES & AVATARS */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
}
.badge-violet { background: var(--violet-soft); color: #c4b5fd; }
.badge-gold { background: var(--gold-soft); color: #fcd34d; }
.badge-green { background: var(--emerald-soft); color: #6ee7b7; }
.badge-red { background: var(--rose-soft); color: #fca5a5; }
.badge-sky { background: var(--sky-soft); color: #7dd3fc; }
.badge-muted { background: var(--bg-elevated); color: var(--text-muted); }

.avatar-circle {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--violet-soft); color: #e9d5ff; display: grid; place-items: center; font-weight: 700;
}
.avatar-circle.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.user-chip {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--bg-root); flex-shrink: 0; }
.thumb-wide { width: 88px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--bg-root); flex-shrink: 0; }

/* DATA TABLE & MOBILE CARD RESPONSIVENESS */
.table-wrap { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); background: var(--bg-elevated); padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.item-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}

/* DRAWER / MODAL */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 7, 12, 0.72); backdrop-filter: blur(4px);
  display: flex; justify-content: flex-end;
}
.drawer-panel {
  width: 100%; max-width: 500px; height: 100%;
  background: var(--bg-surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.drawer-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.drawer-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg-elevated); }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* ALERTS, TOASTS & SKELETON */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--border); background: var(--bg-elevated); }
.alert.error { background: var(--rose-soft); border-color: rgba(239, 68, 68, 0.35); color: #fecaca; }
.alert.info { background: var(--sky-soft); border-color: rgba(14, 165, 233, 0.35); color: #bae6fd; }
.toast-root { position: fixed; top: 16px; right: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-weight: 600; font-size: 13px; }
.toast.success { border-left: 4px solid var(--emerald); }
.toast.error { border-left: 4px solid var(--rose); }
.empty-state { padding: 36px 20px; text-align: center; color: var(--text-muted); }

/* MOBILE ADAPTATION */
.mobile-only { display: none; }
.mobile-bottom-nav { display: none; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); z-index: 35; }

@media (max-width: 959px) {
  .mobile-only { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 14px 14px 86px; }
  .topbar { padding: 0 12px; }
  .mobile-bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 32;
    height: 64px; padding-bottom: env(safe-area-inset-bottom);
    background: rgba(17, 20, 32, 0.96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); justify-content: space-around; align-items: center;
  }
  .mb-nav-btn {
    flex: 1; height: 100%; border: none; background: transparent; color: var(--text-muted);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; font-weight: 600; cursor: pointer;
  }
  .mb-nav-btn.active { color: var(--violet); }
  .mb-nav-btn span:first-child { font-size: 18px; }
}

@media (max-width: 720px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .data-table td { border: none; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: right; }
  .data-table td::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--text-muted); text-align: left; }
}
