/* ═══════════════════════════════════════════════════════════
   Variables
═══════════════════════════════════════════════════════════ */
:root {
  --bg:           #090b10;
  --surface:      #10131c;
  --surface2:     #171b27;
  --surface3:     #1e2233;
  --border:       #222638;
  --border-light: #2c3048;
  --header-bg:    rgba(9, 11, 16, .96);
  --accent:       #00e676;
  --accent-dim:   #00c965;
  --accent-pale:  rgba(0, 230, 118, .08);
  --accent-glow:  rgba(0, 230, 118, .15);
  --text:         #d8dced;
  --text-muted:   #5e6480;
  --text-dim:     #333654;
  --danger:       #ff4d6d;
  --warn:         #ffb347;
  --font-body:    'Manrope', system-ui, sans-serif;
  --font-display: 'Syne', 'Manrope', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Courier New', monospace;
  --radius:       6px;
  --radius-lg:    10px;
  --radius-xl:    14px;
  --shadow:       0 4px 32px rgba(0,0,0,.5);
  --shadow-card:  0 1px 3px rgba(0,0,0,.3), 0 4px 20px rgba(0,0,0,.18);
  --shadow-lift:  0 16px 52px rgba(0,0,0,.6), 0 4px 12px rgba(0,0,0,.3);
  --ease:         cubic-bezier(.4, 0, .2, 1);
}

[data-theme="light"] {
  --bg:           #f0f1f6;
  --surface:      #ffffff;
  --surface2:     #e9eaf2;
  --surface3:     #e0e2ee;
  --border:       #d8dae8;
  --border-light: #e4e6f2;
  --header-bg:    rgba(240, 241, 246, .96);
  --accent:       #006e36;
  --accent-dim:   #005c2c;
  --accent-pale:  rgba(0, 110, 54, .07);
  --accent-glow:  rgba(0, 110, 54, .12);
  --text:         #161829;
  --text-muted:   #525672;
  --text-dim:     #a4a8c4;
  --danger:       #c62828;
  --warn:         #d84315;
  --shadow:       0 4px 24px rgba(0,0,0,.08);
  --shadow-card:  0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lift:  0 12px 40px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.07);
}

/* ═══════════════════════════════════════════════════════════
   Reset
═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════
   Header
═══════════════════════════════════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

/* Green hairline at very top of header */
.header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 30%, var(--accent-dim) 70%, transparent 100%);
  opacity: .6;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.03em;
  color: var(--text);
  text-decoration: none;
}
.header-logo svg { color: var(--accent); flex-shrink: 0; }
.header-logo span { opacity: .9; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user {
  color: var(--text-dim);
  font-size: .78rem;
  font-family: var(--font-mono);
  letter-spacing: .02em;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 5px 8px;
  line-height: 0;
  transition: color .15s, border-color .15s, background .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-light); background: var(--surface2); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="light"] .theme-toggle .icon-sun  { display: inline; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ═══════════════════════════════════════════════════════════
   Main
═══════════════════════════════════════════════════════════ */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 28px 120px;
}

/* ═══════════════════════════════════════════════════════════
   Buttons
═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: .825rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease), opacity .15s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: .01em;
}

.btn-primary {
  background: var(--accent);
  color: #060810;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  box-shadow: 0 0 24px var(--accent-glow), 0 4px 12px rgba(0,230,118,.1);
}
.btn-primary:disabled {
  opacity: .3;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border-light); color: var(--text); background: var(--surface2); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(255, 77, 109, .3);
}
.btn-danger:hover { background: rgba(255,77,109,.08); border-color: var(--danger); }

.btn-sm { padding: 5px 12px; font-size: .775rem; }
.btn-full { width: 100%; justify-content: center; }

/* ═══════════════════════════════════════════════════════════
   Custom Checkbox
═══════════════════════════════════════════════════════════ */
.card-checkbox-wrap,
.select-all-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.card-checkbox-wrap input[type="checkbox"],
.select-all-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--border-light);
  border-radius: 4px;
  background: var(--surface2);
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
  position: relative;
}

input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: 2px solid #060810;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}
input[type="checkbox"]:indeterminate + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 3px; top: 6px;
  width: 9px; height: 2px;
  background: var(--accent);
}
input[type="checkbox"]:disabled + .checkbox-custom { opacity: .25; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════
   Alerts
═══════════════════════════════════════════════════════════ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 16px;
}
.alert-error { background: rgba(255,77,109,.1); border: 1px solid rgba(255,77,109,.25); color: #ff8fa3; }

.page-error {
  background: rgba(255,77,109,.06);
  border: 1px solid rgba(255,77,109,.2);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}
.page-error-inner {
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.page-error-inner svg { flex-shrink: 0; margin-top: 2px; }
.page-error-inner strong { color: #ff8fa3; display: block; margin-bottom: 4px; font-family: var(--font-display); }
.page-error-inner p { color: var(--text-muted); font-size: .85rem; font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════
   Auth / Login
═══════════════════════════════════════════════════════════ */
.auth-wrap {
  display: flex;
  min-height: calc(100vh - 58px);
}

/* Left brand panel */
.auth-brand {
  flex: 0 0 420px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 52px 48px;
  position: relative;
  overflow: hidden;
}
.auth-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(0,230,118,.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 80% 20%, rgba(0,230,118,.04) 0%, transparent 70%);
  pointer-events: none;
}
.auth-brand-geo {
  position: absolute;
  right: -30px; top: -30px;
  width: 220px; height: 220px;
  border: 1px solid var(--border);
  border-radius: 50%;
  opacity: .5;
}
.auth-brand-geo::after {
  content: '';
  position: absolute;
  inset: 30px;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  opacity: .7;
}
.auth-brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -.03em;
  position: relative;
}
.auth-brand-headline {
  position: relative;
}
.auth-brand-headline h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.04em;
  color: var(--text);
  margin-bottom: 14px;
}
.auth-brand-headline p {
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.65;
  max-width: 280px;
}
.auth-brand-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  width: 100%;
}
.auth-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.auth-stat-val {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -.02em;
}
.auth-stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  letter-spacing: .03em;
}

/* Right form panel */
.auth-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 360px;
}
.auth-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-subtitle {
  color: var(--text-muted);
  font-size: .825rem;
  margin-bottom: 36px;
  font-family: var(--font-mono);
  letter-spacing: .02em;
}
.auth-icon { display: none; }

.auth-form { text-align: left; }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-family: var(--font-display);
}
.form-group input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: .9rem;
  padding: 11px 14px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-group input::placeholder { color: var(--text-dim); }
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-pale);
}

@media (max-width: 800px) {
  .auth-wrap { flex-direction: column; }
  .auth-brand { flex: none; min-height: 240px; padding: 32px 28px; border-right: none; border-bottom: 1px solid var(--border); }
  .auth-brand-stats { flex-direction: row; flex-wrap: wrap; }
  .auth-brand-headline h2 { font-size: 1.4rem; }
}

/* ═══════════════════════════════════════════════════════════
   Toolbar
═══════════════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 160px;
  max-width: 280px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}
#search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .825rem;
  padding: 7px 10px 7px 32px;
  outline: none;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
#search-input::placeholder { color: var(--text-dim); }
#search-input:focus {
  border-color: var(--border-light);
  background: var(--surface3);
}

/* Toolbar divider */
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.filter-group {
  display: flex;
  gap: 2px;
}

.filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .775rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
  white-space: nowrap;
  letter-spacing: .01em;
}
.filter-btn:hover { color: var(--text); background: var(--surface2); }
.filter-btn.active {
  background: var(--surface3);
  color: var(--text);
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface3);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: .65rem;
  padding: 1px 5px;
  margin-left: 4px;
  color: var(--text-muted);
}
.filter-btn.active .filter-count { color: var(--text-muted); }

.toolbar-right { display: flex; align-items: center; gap: 8px; }

.sort-label { font-size: .75rem; color: var(--text-dim); white-space: nowrap; font-family: var(--font-display); font-weight: 600; letter-spacing: .02em; }
.sort-select {
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .775rem;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.sort-select:focus { border-color: var(--border-light); }

.category-wrap { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   Products Grid
═══════════════════════════════════════════════════════════ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 1200px) { .products-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px)  { .products-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .products-grid { grid-template-columns: 1fr; } }

/* ── Product Card ── */
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0;
  overflow: hidden;
  position: relative;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .2s;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  animation: card-in .36s var(--ease) both;
  animation-delay: min(calc(var(--i, 0) * 28ms), 420ms);
}
.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lift);
  border-color: var(--border-light);
}

/* Processed indicator — green left edge */
.product-card.card-done::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--accent);
  opacity: .75;
  z-index: 1;
}
.product-card.card-done:hover::after { opacity: 1; }

/* Checkbox floating over photo */
.card-checkbox-wrap {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 4;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(8px);
  border-radius: 6px;
  padding: 3px;
}

.slider-wrap { position: relative; cursor: pointer; }

/* ── Inline card navigation arrows ── */
.card-arr {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.9);
  font-size: 1.2rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
  z-index: 3;
  padding: 0;
  backdrop-filter: blur(4px);
}
.slider-wrap:hover .card-arr { opacity: 1; }
.card-arr:hover { background: rgba(0,0,0,.75); }
.card-arr-prev { left: 6px; }
.card-arr-next { right: 6px; }

/* ── Card dots indicator ── */
.card-dots-wrap {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 3;
  pointer-events: none;
}
.card-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  transition: background .15s, width .15s;
}
.card-dot.active { background: #fff; width: 10px; border-radius: 2px; }

/* ── Lightbox ── */
#lb-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.lb-modal {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  max-width: min(92vw, 860px);
  gap: 14px;
}
.lb-close {
  position: absolute; top: -44px; right: 0;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.7); font-size: 1.2rem; cursor: pointer;
  padding: 6px 10px; line-height: 1;
  transition: color .15s, background .15s;
  border-radius: var(--radius);
}
.lb-close:hover { color: #fff; background: rgba(255,255,255,.15); }
.lb-img-wrap {
  max-height: 78vh;
  display: flex; align-items: center; justify-content: center;
}
.lb-img-wrap img {
  max-width: min(88vw, 820px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 8px;
  display: block;
  transition: opacity .2s;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: #fff; font-size: 2rem; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  z-index: 2; padding: 0; line-height: 1;
  backdrop-filter: blur(4px);
}
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: -58px; }
.lb-next { right: -58px; }
.lb-footer { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#lb-dots { display: flex; gap: 6px; }
.lb-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  transition: background .15s, width .15s;
}
.lb-dot.active { background: #fff; width: 18px; border-radius: 3px; }
.lb-counter { font-size: .75rem; color: rgba(255,255,255,.35); font-family: var(--font-mono); letter-spacing: .05em; }

@media (max-width: 600px) {
  .lb-prev { left: -38px; }
  .lb-next { right: -38px; }
  .lb-nav { width: 34px; height: 34px; font-size: 1.5rem; }
}

.card-photo {
  aspect-ratio: 1;
  border-radius: 0;
  overflow: hidden;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s var(--ease);
}
.product-card:hover .card-photo img { transform: scale(1.03); }
.card-photo.no-img { }

.photo-placeholder {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* Card info area */
.card-info { flex: 1; padding: 12px 14px 5px; }

.card-name {
  font-size: .855rem;
  font-weight: 700;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  margin-bottom: 7px;
  letter-spacing: -.01em;
  color: var(--text);
}

.card-category {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--accent);
  background: var(--accent-pale);
  border-radius: 3px;
  padding: 2px 6px;
  margin-bottom: 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.card-articul {
  display: block;
  font-size: .68rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-bottom: 2px;
  letter-spacing: .02em;
}

.card-size {
  font-size: .78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: -.01em;
}

.card-status { min-height: 22px; padding: 0 14px 11px; }

/* ═══════════════════════════════════════════════════════════
   Pagination
═══════════════════════════════════════════════════════════ */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 8px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: .75rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
  letter-spacing: .02em;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: .775rem;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover:not(.disabled):not(.active) {
  background: var(--surface2);
  border-color: var(--border-light);
  color: var(--text);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #060810;
  font-weight: 700;
  cursor: default;
}
.page-btn.disabled { opacity: .25; cursor: not-allowed; }
.page-ellipsis {
  color: var(--text-dim);
  font-size: .85rem;
  padding: 0 4px;
  line-height: 34px;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: .65rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.badge-ok {
  background: var(--accent-pale);
  color: var(--accent);
  border: 1px solid rgba(0,230,118,.2);
}
[data-theme="light"] .badge-ok { border-color: rgba(0,110,54,.2); }
.badge-skip {
  background: rgba(94, 100, 128, .08);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Loading state ── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 110px 24px;
  color: var(--text-dim);
  font-size: .825rem;
  font-family: var(--font-mono);
  letter-spacing: .04em;
}

.spinner-lg { width: 32px; height: 32px; border-width: 2px; }

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 110px 24px;
  color: var(--text-dim);
  text-align: center;
}
.empty-state svg { color: var(--text-dim); opacity: .3; }
.empty-state p { font-size: .875rem; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: .02em; }

/* ═══════════════════════════════════════════════════════════
   Control Bar (sticky bottom)
═══════════════════════════════════════════════════════════ */
.control-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(10, 12, 18, .98);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}
[data-theme="light"] .control-bar {
  background: rgba(240, 241, 246, .98);
}
.control-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 20%, var(--accent) 80%, transparent 100%);
  opacity: .25;
}

.control-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.select-all-label {
  font-size: .825rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-display);
  letter-spacing: .01em;
}

.selection-count {
  color: var(--text-dim);
  font-size: .775rem;
  font-family: var(--font-mono);
  white-space: nowrap;
  letter-spacing: .02em;
}

.control-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.quota-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .775rem;
}
.quota-label {
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .7rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.quota-val { font-family: var(--font-mono); color: var(--text-muted); }
.quota-val.quota-warn  { color: var(--warn); }
.quota-val.quota-error { color: var(--danger); }

.btn-icon {
  background: none; border: none; cursor: pointer; padding: 3px 5px;
  color: var(--text-dim); border-radius: 4px; line-height: 0;
  transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--text-muted); background: var(--surface2); }

/* API key modal */
#key-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 300; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.key-modal {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); width: 420px; max-width: calc(100vw - 32px);
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.key-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: .9rem;
  font-family: var(--font-display);
  letter-spacing: -.01em;
}
.key-modal-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.key-input {
  width: 100%; padding: 10px 13px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: .875rem; font-family: var(--font-mono);
  box-sizing: border-box; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.key-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-pale); }
.key-error { color: var(--danger); font-size: .8rem; min-height: 1em; margin: 0; }
.key-modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   Progress Modal
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px 24px 0;
}
.modal-header h2 {
  font-size: 1rem;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -.02em;
}

.modal-current {
  padding: 12px 24px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: .825rem;
  font-family: var(--font-mono);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
svg.spin { animation: spin .8s linear infinite; }

.progress-wrap { padding: 12px 24px; }
.progress-bar-track {
  background: var(--surface2);
  border-radius: 3px;
  height: 6px;
  position: relative;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width .4s var(--ease);
  box-shadow: 0 0 12px var(--accent-glow);
}
.progress-bar-label {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-dim);
  letter-spacing: .03em;
}

.progress-log {
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.progress-log::-webkit-scrollbar { width: 3px; }
.progress-log::-webkit-scrollbar-track { background: transparent; }
.progress-log::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.log-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: .775rem;
  background: var(--surface2);
  border-left: 2px solid transparent;
}
.log-ok    { border-left-color: var(--accent); }
.log-skip  { border-left-color: var(--text-dim); opacity: .6; }
.log-error { border-left-color: var(--danger); }

.log-icon  { font-size: .85rem; flex-shrink: 0; }
.log-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.log-saved { font-family: var(--font-mono); color: var(--accent); font-weight: 600; white-space: nowrap; font-size: .75rem; }
.log-reason  { font-family: var(--font-mono); color: var(--text-dim); white-space: nowrap; font-size: .75rem; }
.log-gallery { font-family: var(--font-mono); color: var(--text-dim); white-space: nowrap; margin-left: .25rem; font-size: .75rem; }

.modal-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  margin: 8px 0 0;
}
.summary-stat {
  background: var(--surface2);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border-right: 1px solid var(--border);
}
.summary-stat:last-child { border-right: none; }
.summary-val {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: -.02em;
}
.summary-key {
  font-size: .65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-family: var(--font-display);
  font-weight: 700;
}

.modal-error {
  margin: 8px 24px;
  padding: 10px 14px;
  background: rgba(255,77,109,.08);
  border: 1px solid rgba(255,77,109,.2);
  border-radius: var(--radius);
  color: #ff8fa3;
  font-size: .85rem;
  font-family: var(--font-mono);
}

.modal-footer {
  padding: 14px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   Responsive
═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .main { padding: 16px 14px 130px; }
  .control-bar-inner { gap: 10px; padding: 10px 14px; }
  .control-bar-right { flex-wrap: wrap; gap: 10px; }
  .quota-info { display: none; }
  .modal-summary { grid-template-columns: repeat(2, 1fr); }
  .toolbar { padding: 6px 10px; }
}
