/* =========================================================
   Elixir TCG Admin — Shared Stylesheet
   ========================================================= */

:root {
  --bg-primary:      #0d1117;
  --bg-secondary:    #161b22;
  --bg-card:         #21262d;
  --bg-hover:        #2d333b;
  --border:          #30363d;
  --border-muted:    #21262d;
  --text-primary:    #e6edf3;
  --text-secondary:  #8b949e;
  --text-muted:      #484f58;
  --accent:          #58a6ff;
  --accent-hover:    #79bbff;
  --accent-dim:      rgba(88, 166, 255, 0.15);
  --accent-purple:   #8b5cf6;
  --accent-purple-dim: rgba(139, 92, 246, 0.15);
  --success:         #3fb950;
  --success-dim:     rgba(63, 185, 80, 0.15);
  --warning:         #d29922;
  --warning-dim:     rgba(210, 153, 34, 0.15);
  --danger:          #f85149;
  --danger-dim:      rgba(248, 81, 73, 0.15);

  --rarity-commun:      #8b949e;
  --rarity-epique:      #8b5cf6;
  --rarity-rare:        #58a6ff;
  --rarity-legendaire:  #d29922;
  --rarity-mythique:    #f85149;

  --sidebar-width: 220px;
  --topbar-height: 56px;
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.2);
  --shadow-modal: 0 8px 40px rgba(0,0,0,0.7);
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* ----- Reset & Base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

ul { list-style: none; }

button { cursor: pointer; font-family: inherit; font-size: inherit; }

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
}

img { display: block; }

/* ----- Layout ---------------------------------------------- */
.layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* ----- Sidebar --------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-logo:hover { color: var(--text-primary); text-decoration: none; }
.sidebar-logo .logo-icon {
  font-size: 1.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 6px #58a6ff88);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.sidebar-section-label {
  padding: 10px 20px 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  text-decoration: none;
  position: relative;
}
.sidebar-nav a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar-nav a .nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-info img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}
.sidebar-user-details {
  overflow: hidden;
}
.sidebar-username {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.sidebar-user-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  justify-content: center;
}
.sidebar-logout:hover {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: var(--danger);
  text-decoration: none;
}

/* ----- Main content ---------------------------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ----- Topbar ---------------------------------------------- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}
.topbar-breadcrumb a { color: var(--text-secondary); }
.topbar-breadcrumb a:hover { color: var(--accent); }
.topbar-breadcrumb .sep { color: var(--text-muted); }

/* ----- Page body ------------------------------------------- */
.page-body {
  padding: 28px;
  flex: 1;
}

/* ----- Stat cards ------------------------------------------ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--accent); }

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.stat-value.accent  { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }
.stat-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stat-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 4px;
}

/* ----- Section cards --------------------------------------- */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.section-card + .section-card { margin-top: 20px; }

.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}
.section-body { padding: 20px; }
.section-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-secondary);
}

/* ----- Dashboard grid ------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ----- Bar charts ------------------------------------------ */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: 10px;
}
.bar-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 100px;
  overflow: hidden;
  border: 1px solid var(--border-muted);
}
.bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.bar-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ----- Distribution bar (booster) -------------------------- */
.distrib-bar {
  height: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  margin: 8px 0;
  border: 1px solid var(--border);
}
.distrib-segment {
  height: 100%;
  transition: width 0.3s;
  position: relative;
}
.distrib-segment:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.distrib-segment:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ----- Tables ---------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: var(--bg-secondary);
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  user-select: none;
}
thead th.sortable {
  cursor: pointer;
}
thead th.sortable:hover { color: var(--accent); }
thead th.sort-asc::after  { content: ' ▲'; font-size: 0.6rem; }
thead th.sort-desc::after { content: ' ▼'; font-size: 0.6rem; }

tbody tr {
  border-bottom: 1px solid var(--border-muted);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: 10px 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-number {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.td-portrait {
  padding: 6px 14px;
}
.td-portrait img {
  width: 32px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  background: var(--bg-secondary);
}
.td-portrait img:hover {
  transform: scale(1.08);
  border-color: var(--accent);
}

.td-name { font-weight: 600; }
.td-rang { font-size: 0.95rem; letter-spacing: 1px; color: var(--warning); }

/* ----- Badges ---------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-commun     { background: rgba(139,148,158,0.15); color: var(--rarity-commun);     border: 1px solid rgba(139,148,158,0.3);     }
.badge-epique     { background: rgba(139, 92,246,0.15); color: var(--rarity-epique);     border: 1px solid rgba(139, 92,246,0.35);   }
.badge-rare       { background: rgba( 88,166,255,0.15); color: var(--rarity-rare);       border: 1px solid rgba( 88,166,255,0.35);   }
.badge-legendaire { background: rgba(210,153, 34,0.15); color: var(--rarity-legendaire); border: 1px solid rgba(210,153, 34,0.35);   }
.badge-mythique   { background: rgba(248, 81, 73,0.15); color: var(--rarity-mythique);   border: 1px solid rgba(248, 81, 73,0.35);   }

.badge-portrait   { background: var(--accent-dim);         color: var(--accent);         border: 1px solid rgba(88,166,255,0.35);    }
.badge-ui         { background: var(--accent-purple-dim);  color: var(--accent-purple);  border: 1px solid rgba(139,92,246,0.35);    }
.badge-orphan     { background: var(--danger-dim);         color: var(--danger);         border: 1px solid rgba(248,81,73,0.35);     }
.badge-success    { background: var(--success-dim);        color: var(--success);        border: 1px solid rgba(63,185,80,0.35);     }
.badge-warning    { background: var(--warning-dim);        color: var(--warning);        border: 1px solid rgba(210,153,34,0.35);    }
.badge-danger     { background: var(--danger-dim);         color: var(--danger);         border: 1px solid rgba(248,81,73,0.35);     }

/* ----- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #0d1117; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-secondary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: rgba(248,81,73,0.4);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(63,185,80,0.4);
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-purple {
  background: var(--accent-purple-dim);
  color: var(--accent-purple);
  border-color: rgba(139,92,246,0.4);
}
.btn-purple:hover { background: var(--accent-purple); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-lg { padding: 10px 20px; font-size: 0.95rem; }
.btn-icon { padding: 6px; border-radius: var(--radius-sm); }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ----- Forms ----------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input[readonly],
.form-select[disabled],
.form-input[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg-primary);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.form-select option { background: var(--bg-secondary); }

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.form-error {
  font-size: 0.72rem;
  color: var(--danger);
  margin-top: 2px;
}

/* Stats row total */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.stat-total-display {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  text-align: center;
}
.stat-total-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.stat-total-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ----- Search / Filter toolbar ----------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}
.toolbar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}
.toolbar-search {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px 8px 32px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
}
.toolbar-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.toolbar-search::placeholder { color: var(--text-muted); }
.toolbar-filter {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.12s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b949e'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.toolbar-filter:focus {
  outline: none;
  border-color: var(--accent);
}
.toolbar-filter option { background: var(--bg-secondary); }

/* ----- Pagination ------------------------------------------ */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.pagination-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: auto;
}
.pagination .btn { min-width: 32px; justify-content: center; }

/* ----- Image grid ------------------------------------------ */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.image-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.12s;
  cursor: default;
}
.image-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.image-card.selectable { cursor: pointer; }
.image-card.selectable:hover { border-color: var(--accent); }
.image-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.image-thumb-wrap {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-thumb-wrap.portrait-thumb { aspect-ratio: 2 / 3; }

.image-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.image-card:hover .image-thumb { transform: scale(1.04); }

.image-info {
  padding: 8px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.image-filename {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.image-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.image-actions {
  padding: 6px 10px;
  border-top: 1px solid var(--border-muted);
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  background: var(--bg-card);
}

/* ----- Filter tabs ----------------------------------------- */
.filter-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  width: fit-content;
}
.filter-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background 0.12s, color 0.12s;
}
.filter-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.filter-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ----- Drag & drop zone ------------------------------------ */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.drop-icon {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--text-muted);
}
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon { color: var(--accent); }
.drop-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.drop-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.drop-zone input[type="file"] { display: none; }

/* ----- Progress bar ---------------------------------------- */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.progress-track {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 100px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 0.3s;
}
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger  { background: var(--danger);  }

/* ----- Range slider ---------------------------------------- */
input.booster-slider {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input.booster-slider:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.slider-wrap {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.slider-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.slider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 100px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
}
.slider-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Weight sum indicator */
.weight-sum {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  margin-top: 8px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.weight-sum.ok     { background: var(--success-dim);  color: var(--success);  border-color: rgba(63,185,80,0.3);   }
.weight-sum.over   { background: var(--danger-dim);   color: var(--danger);   border-color: rgba(248,81,73,0.3);  }
.weight-sum.under  { background: var(--warning-dim);  color: var(--warning);  border-color: rgba(210,153,34,0.3); }

/* ----- Modals ---------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal.modal-lg  { max-width: 860px; }
.modal.modal-sm  { max-width: 360px; }

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ----- Lightbox -------------------------------------------- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
  animation: fadeIn 0.15s ease;
}
.lightbox-overlay.hidden { display: none; }
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 80px rgba(0,0,0,0.8);
  cursor: default;
}

/* ----- Toast notifications --------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-modal);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: toastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.removing {
  animation: toastOut 0.2s ease forwards;
}

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; max-height: 100px; }
  to   { transform: translateX(120%); opacity: 0; max-height: 0; padding: 0; }
}

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; }
.toast-message { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); }
.toast-sub     { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.toast.success { border-left: 4px solid var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error   { border-left: 4px solid var(--danger);  }
.toast.error .toast-icon   { color: var(--danger);  }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info    { border-left: 4px solid var(--accent);  }
.toast.info .toast-icon    { color: var(--accent);  }

/* ----- Loading spinner ------------------------------------- */
.spinner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13,17,23,0.6);
  border-radius: inherit;
  z-index: 10;
}
.spinner-overlay.hidden { display: none; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner.spinner-lg { width: 44px; height: 44px; border-width: 4px; }

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 24px;
  color: var(--text-muted);
}
.loading-state.hidden { display: none; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 24px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state .empty-icon { font-size: 3rem; line-height: 1; }
.empty-state p { font-size: 0.9rem; }

/* ----- Portrait preview ------------------------------------ */
.portrait-preview-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}
.portrait-preview {
  width: 80px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

/* ----- Health card ----------------------------------------- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.health-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.health-item-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.health-item-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.health-item-value.ok     { color: var(--success); }
.health-item-value.warn   { color: var(--warning); }
.health-item-value.err    { color: var(--danger);  }

/* ----- Quick actions --------------------------------------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  text-align: center;
}
.quick-action-card:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  text-decoration: none;
}
.quick-action-icon { font-size: 1.8rem; line-height: 1; }

/* ----- Import/Export --------------------------------------- */
.import-results {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: none;
}
.import-results.visible { display: block; }

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-muted);
  font-size: 0.85rem;
}
.result-row:last-child { border-bottom: none; }
.result-row .result-key { color: var(--text-muted); width: 100px; flex-shrink: 0; }
.result-row .result-val { font-weight: 700; color: var(--text-primary); }

.error-list {
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}
.error-item {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-muted);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--danger);
}
.error-item:last-child { border-bottom: none; }

/* ----- Warning box ----------------------------------------- */
.warning-box {
  background: var(--warning-dim);
  border: 1px solid rgba(210,153,34,0.4);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--warning);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  display: none;
}
.warning-box.visible { display: flex; }
.warning-box .warn-icon { flex-shrink: 0; font-size: 1.1rem; }

/* ----- Export buttons -------------------------------------- */
.export-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  padding: 20px;
}
.export-option {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  transition: border-color 0.15s;
}
.export-option:hover { border-color: var(--accent); }
.export-option-icon { font-size: 2rem; line-height: 1; }
.export-option-title { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.export-option-desc  { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }

/* ----- API Key modal --------------------------------------- */
.apikey-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  backdrop-filter: blur(6px);
}
.apikey-modal-overlay.hidden { display: none; }

.apikey-modal {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 0 40px rgba(88,166,255,0.2), var(--shadow-modal);
}
.apikey-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.apikey-modal-desc {
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}
.apikey-input-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.apikey-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-mono);
}
.apikey-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.apikey-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ----- Booster panels -------------------------------------- */
.booster-panels {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.booster-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.booster-panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.booster-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.booster-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.booster-item-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.booster-ui-preview {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border);
}
.booster-panel-body {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 32px;
}
.booster-sliders { grid-column: 1 / 2; }
.booster-preview { grid-column: 2 / 3; display: flex; flex-direction: column; gap: 10px; }
.booster-panel-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
}

/* ----- Misc helpers ---------------------------------------- */
.hidden { display: none !important; }
.text-muted    { color: var(--text-muted); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-accent   { color: var(--accent); }
.font-mono     { font-family: var(--font-mono); }
.fw-bold       { font-weight: 700; }
.fs-sm         { font-size: 0.78rem; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* Login overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 9999;
}
.login-overlay.hidden { display: none; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-modal);
}
.login-logo { font-size: 3rem; }
.login-title { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.login-desc  { font-size: 0.85rem; color: var(--text-secondary); }

/* ----- Responsive ------------------------------------------ */
@media (max-width: 900px) {
  :root { --sidebar-width: 56px; }
  .sidebar-logo span,
  .sidebar-nav a span,
  .sidebar-section-label,
  .sidebar-username,
  .sidebar-user-label,
  .sidebar-logout span { display: none; }
  .sidebar-logo { justify-content: center; padding: 16px; }
  .sidebar-nav a { justify-content: center; padding: 12px; }
  .sidebar-user-info { justify-content: center; }
  .sidebar-logout { padding: 6px; min-width: 0; }
  .sidebar-user { padding: 10px 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .booster-panel-body { grid-template-columns: 1fr; }
  .booster-sliders, .booster-preview { grid-column: 1 / 2; }
}

@media (max-width: 640px) {
  .page-body { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
