:root {
  --bg-deep: #050814;
  --bg-sidebar: #090e21;
  --bg-panel: rgba(15, 22, 46, 0.88);
  --bg-surface: rgba(10, 15, 34, 0.9);
  --border: rgba(139, 92, 246, 0.24);
  --border-soft: rgba(148, 163, 184, 0.16);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --purple: #7c3aed;
  --violet: #a855f7;
  --blue: #3b82f6;
  --cyan: #38bdf8;
  --emerald: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
}

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

html, body {
  min-height: 100%;
  background: radial-gradient(circle at 20% 10%, #141c44 0%, #060a18 52%, #040610 100%);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.bg-orb {
  position: fixed;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  filter: blur(130px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.3;
}

.bg-orb-top {
  top: -150px;
  right: -120px;
  background: radial-gradient(circle, #7c3aed, transparent 70%);
}

.bg-orb-bottom {
  bottom: -150px;
  left: -120px;
  background: radial-gradient(circle, #2563eb, transparent 70%);
}

/* Login Screen */
.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 430px;
  padding: 34px;
  border-radius: 24px;
  background: rgba(12, 18, 40, 0.92);
  border: 1px solid rgba(139, 92, 246, 0.36);
  box-shadow: 0 24px 64px rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.login-brand h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
}

.login-brand p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.brand-logo {
  width: 42px;
  height: 42px;
  display: inline-flex;
  filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.55));
}

.login-form,
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #cbd5e1;
}

.field input,
.field select,
.field textarea,
.filter-controls input,
.filter-controls select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(6, 10, 25, 0.88);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.22);
}

.secure-pill {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
  font-size: 0.82rem;
  font-weight: 600;
}

.secure-pill svg {
  width: 16px;
  height: 16px;
}

/* Admin Shell */
.admin-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: rgba(8, 12, 30, 0.96);
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}

.sidebar-brand-text strong {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
}

.sidebar-brand-text span {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
}

.side-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.side-link:hover {
  color: var(--text-primary);
  background: rgba(139, 92, 246, 0.12);
}

.side-link.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, #6d28d9, #3b82f6);
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.4);
}

.side-link.danger-link:hover {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
}

.count-badge {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.35);
  color: #e9d5ff;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.secure-box {
  padding: 16px;
  border-radius: 16px;
  text-align: center;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.32);
}

.secure-shield {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.secure-shield svg {
  width: 22px;
  height: 22px;
}

.secure-box strong {
  display: block;
  font-size: 0.9rem;
  color: #ffffff;
}

.secure-box span {
  font-size: 0.78rem;
  color: #94a3b8;
}

.version-note {
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* Main Workspace */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(8, 12, 28, 0.78);
  backdrop-filter: blur(12px);
}

.mobile-menu-btn {
  display: none;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 8px;
  cursor: pointer;
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6ee7b7;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
}

.admin-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
}

.admin-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #3b82f6);
  font-weight: 700;
}

.admin-main {
  padding: 24px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.view-section {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Welcome Banner */
.welcome-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 28px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.25), transparent 55%),
    linear-gradient(125deg, #1b1750 0%, #2b1d70 50%, #10326b 100%);
  border: 1px solid rgba(139, 92, 246, 0.42);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.5);
}

.welcome-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed, #3b82f6);
  color: #ffffff;
}

.welcome-icon svg {
  width: 28px;
  height: 28px;
}

.welcome-banner h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.welcome-banner p {
  color: #cbd5e1;
  font-size: 0.94rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 18px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.purple {
  background: rgba(139, 92, 246, 0.2);
  color: #c4b5fd;
}

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.stat-icon.emerald {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.stat-label {
  display: block;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.stat-value {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Panel Card */
.panel-card {
  padding: 22px 24px;
  border-radius: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-header.wrap {
  flex-wrap: wrap;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
}

.title-icon svg {
  width: 18px;
  height: 18px;
}

.scanner-chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93c5fd;
}

/* Drag & Drop Upload Zone */
.drop-zone {
  padding: 36px 24px;
  border-radius: 18px;
  border: 2px dashed rgba(139, 92, 246, 0.48);
  background: rgba(8, 12, 30, 0.72);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drop-zone.is-dragover {
  border-color: #38bdf8;
  background: rgba(59, 130, 246, 0.14);
}

.drop-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, 0.18);
  color: #a78bfa;
}

.drop-icon svg {
  width: 28px;
  height: 28px;
}

.drop-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.drop-or {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.drop-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Metadata Upload Form */
.upload-meta-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.zip-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.32);
}

.zip-summary-meta {
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-top: 3px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.full-span {
  grid-column: 1 / -1;
}

.icon-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-preview-box {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
}

.icon-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.progress-wrap {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(6, 10, 25, 0.8);
  border: 1px solid var(--border-soft);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  margin-bottom: 8px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8b5cf6, #38bdf8);
  transition: width 0.2s ease;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost-sm,
.btn-danger-sm,
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.16s ease;
}

.btn-primary {
  padding: 11px 20px;
  border: 1px solid rgba(167, 139, 250, 0.45);
  background: linear-gradient(135deg, #6d28d9, #3b82f6);
  color: #ffffff;
  font-size: 0.92rem;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.35);
}

.btn-primary svg {
  width: 17px;
  height: 17px;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary.full-width {
  width: 100%;
}

.btn-secondary {
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  border-color: var(--cyan);
}

.btn-danger {
  padding: 10px 18px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: #dc2626;
  color: #ffffff;
  font-size: 0.9rem;
}

.btn-ghost-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: transparent;
  color: #cbd5e1;
}

.btn-danger-sm {
  padding: 7px 13px;
  font-size: 0.82rem;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.btn-link {
  padding: 6px 14px;
  font-size: 0.84rem;
  border: 1px solid rgba(139, 92, 246, 0.4);
  background: rgba(124, 58, 237, 0.18);
  color: #e9d5ff;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.apps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.apps-table th,
.apps-table td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.apps-table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.table-app-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}

.table-app-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  font-weight: 700;
  color: #ffffff;
}

.table-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.status-badge.published {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-badge.draft {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-action-btn {
  padding: 6px 9px;
  border-radius: 9px;
  border: 1px solid var(--border-soft);
  background: rgba(15, 23, 42, 0.9);
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.icon-action-btn:hover {
  border-color: var(--cyan);
  color: #ffffff;
}

.icon-action-btn.danger:hover {
  border-color: var(--red);
  color: #fca5a5;
}

.filter-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-controls input {
  width: 210px;
}

.filter-controls select {
  width: auto;
}

/* Categories & Settings & Security */
.categories-admin-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.mini-card {
  padding: 18px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
}

.mini-card h4 {
  font-size: 1rem;
  margin-bottom: 6px;
  color: #e2e8f0;
}

.mini-card p {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  font-size: 0.84rem;
}

/* Alerts & Toast */
.alert-error {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.38);
  color: #fca5a5;
  font-size: 0.86rem;
}

.alert-success {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.38);
  color: #6ee7b7;
  font-size: 0.86rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 60;
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #f8fafc;
  font-weight: 600;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 20px;
  background: #0c132b;
  border: 1px solid var(--border);
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-card.modal-lg {
  max-width: 720px;
}

.modal-card.modal-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.details-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.details-kv {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(6, 10, 25, 0.85);
  border: 1px solid var(--border-soft);
}

.details-kv span {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.details-kv strong {
  font-size: 0.86rem;
  word-break: break-all;
}

.file-tree-box {
  max-height: 240px;
  overflow-y: auto;
  padding: 12px;
  border-radius: 12px;
  background: #060916;
  border: 1px solid var(--border-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.file-tree-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

/* Responsive */
@media (max-width: 960px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 45;
    transition: left 0.22s ease;
  }

  .sidebar.is-open {
    left: 0;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.65);
    z-index: 40;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}
