:root {
  --bg: #0a0a0a;
  --card: #141414;
  --card-hover: #1a1a1a;
  --border: #262626;
  --text: #fafafa;
  --muted: #888;
  --primary: #d4a017;
  --primary-soft: rgba(212, 160, 23, 0.1);
}

html.light {
  --bg: #fafafa;
  --card: #ffffff;
  --card-hover: #f4f4f4;
  --border: #e5e5e5;
  --text: #0a0a0a;
  --muted: #666;
  --primary: #b88a13;
  --primary-soft: rgba(184, 138, 19, 0.08);
}

html, body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  font-family: 'Cairo', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

.bg-bg { background: var(--bg); }
.bg-card { background: var(--card); }
.bg-card-hover { background: var(--card-hover); }
.border-border { border-color: var(--border); }
.text-primary { color: var(--primary); }
.text-muted { color: var(--muted); }
.bg-primary { background: var(--primary); }
.bg-primary-soft { background: var(--primary-soft); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Sidebar */
.sidebar {
  background: var(--card);
  border-color: var(--border);
  transition: transform 0.2s ease;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); box-shadow: -4px 0 24px rgba(0,0,0,0.3); }
  .sidebar.open { transform: translateX(0); }
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease;
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: inherit;
  width: 100%;
  text-align: right;
}

.nav-link:hover { background: var(--card-hover); }

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 1.25rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover { border-color: rgba(212, 160, 23, 0.3); }

.card-compact { padding: 0.875rem 1rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

.btn:hover { background: var(--card-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary); opacity: 0.9; }

.btn-danger {
  background: transparent;
  color: #ef4444;
  border-color: transparent;
}
.btn-danger:hover { background: rgba(239,68,68,0.1); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover { background: var(--card-hover); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

/* Inputs */
.input, .select {
  width: 100%;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--card-hover);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-danger { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Stat cards */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.875rem;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--card) 0%, var(--card) 60%, var(--primary-soft) 100%);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.text-gradient-gold {
  background: linear-gradient(135deg, var(--primary), #f0c14b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Tables */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: auto;
  background: var(--card);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data th {
  background: var(--card-hover);
  padding: 0.75rem;
  text-align: right;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

table.data tbody tr:hover { background: var(--card-hover); }

/* Toast */
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.875rem 1.125rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  animation: toast-in 0.2s ease;
}

.toast-error { border-color: #ef4444; }
.toast-success { border-color: #22c55e; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Utility */
.muted { color: var(--muted); }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* Drag-drop */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 0.875rem;
  padding: 2.5rem;
  text-align: center;
  transition: all 0.15s;
  cursor: pointer;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  flex-wrap: wrap;
  padding: 1rem 0;
}

.page-btn {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.page-btn:hover:not(:disabled) { border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--card) 0%, var(--card-hover) 50%, var(--card) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: 0.5rem;
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Manifest metadata list */
.manifest-meta {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
}

.manifest-meta-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.manifest-meta-row:last-child {
  border-bottom: none;
}

.manifest-meta-row:nth-child(even) {
  background: var(--card-hover);
}

.manifest-meta-key {
  color: var(--muted);
  font-size: 0.8125rem;
  flex-shrink: 0;
  min-width: 7rem;
}

.manifest-meta-val {
  font-weight: 600;
  word-break: break-word;
  flex: 1;
  text-align: left;
}

/* Image preview */
.img-thumb {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}
