/* === Tom Select Styles === */
@import url('https://cdn.jsdelivr.net/npm/tom-select@2.3.1/dist/css/tom-select.bootstrap5.min.css');

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

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-warning: #d97706;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --sidebar-width: 260px;
  --topbar-height: 56px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════
   APP LAYOUT — Sidebar + Main
   ═══════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* Sidebar header / logo */
.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 0.25rem;
}

.nav-group-label {
  display: block;
  padding: 0.75rem 1.25rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.25rem;
  text-decoration: none;
  color: #94a3b8;
  border-radius: 0;
  transition: all 0.15s ease;
  position: relative;
  flex-wrap: wrap;
}

.sidebar-nav a .nav-hint {
  display: block;
  width: 100%;
  font-size: 0.7rem;
  color: #475569;
  margin-left: 2.25rem;
  margin-top: -0.2rem;
  line-height: 1.3;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.05);
  color: #e2e8f0;
}

.sidebar-nav a:hover .nav-hint {
  color: #64748b;
}

.sidebar-nav a.active {
  background: rgba(37, 99, 235, 0.15);
  color: #fff;
  border-right: 3px solid var(--color-primary);
}

.sidebar-nav a.active .nav-hint {
  color: rgba(147, 197, 253, 0.7);
}

.sidebar-nav a.active .nav-icon {
  color: var(--color-primary);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-text {
  font-size: 0.875rem;
  font-weight: 500;
}

/* Sidebar footer / user */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 0.75rem;
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  margin-bottom: 0.25rem;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: capitalize;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: #64748b;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.sidebar-logout:hover {
  background: rgba(255,255,255,0.05);
  color: #f87171;
}

.sidebar-logout .nav-icon {
  width: 18px;
  height: 18px;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── Top bar (mobile only) ──────────────────────────── */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1rem;
  align-items: center;
  gap: 0.75rem;
  z-index: 50;
}

.topbar-menu {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  cursor: pointer;
  flex-shrink: 0;
}

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

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

/* ── Main content ───────────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: 1.75rem 2rem;
  max-width: 1200px;
  width: 100%;
}

/* ── Responsive (mobile) ────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.sidebar--open {
    transform: translateX(0);
    box-shadow: 4px 0 25px rgba(0,0,0,0.3);
  }

  .sidebar-overlay.sidebar-overlay--visible {
    display: block;
  }

  .topbar {
    display: flex;
  }

  .app-main {
    margin-left: 0;
  }

  .main-content {
    padding: 1rem;
  }
}

/* ═══════════════════════════════════════════════════════
   AUTH LAYOUT (no sidebar)
   ═══════════════════════════════════════════════════════ */

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ═══════════════════════════════════════════════════════
   FLASH MESSAGES
   ═══════════════════════════════════════════════════════ */

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flash-notice { background: #ecfdf5; color: var(--color-success); border: 1px solid #bbf7d0; }
.flash-alert { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }

/* ═══════════════════════════════════════════════════════
   PAGE HEADER with description
   ═══════════════════════════════════════════════════════ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.page-description {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover { background: var(--color-bg); box-shadow: var(--shadow); }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); box-shadow: 0 2px 8px rgba(37,99,235,0.25); }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════ */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}

th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfe; }

/* ── Scrollable table wrapper ───────────────────────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.table-scroll table {
  border-radius: 0;
  box-shadow: none;
}

/* ── Compact table variant ──────────────────────────── */
.table-compact th,
.table-compact td {
  padding: 0.5rem 0.75rem;
}

.table-compact th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ── Column types ───────────────────────────────────── */
.col-product {
  min-width: 200px;
}

.col-category {
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-number {
  white-space: nowrap;
  text-align: right !important;
  min-width: 70px;
}

.col-center {
  text-align: center !important;
  white-space: nowrap;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right !important;
}

/* ── Product cell (combined SKU + Name + Brand) ─────── */
.product-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.product-cell-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-cell-name:hover {
  color: var(--color-primary);
}

.product-cell-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.product-sku {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

.product-brand {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* ── Category label ─────────────────────────────────── */
.category-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ── Row action icons ───────────────────────────────── */
.row-actions {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  transition: all 0.15s;
}

.row-action:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.row-action svg {
  width: 16px;
  height: 16px;
}

/* ═══════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════ */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  color: var(--color-text);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea { min-height: 100px; resize: vertical; }

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-check input[type="checkbox"] { width: auto; }

.form-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  color: var(--color-danger);
  font-size: 0.875rem;
}

.form-errors ul { margin-left: 1rem; }

/* ═══════════════════════════════════════════════════════
   CARDS / DETAIL VIEW
   ═══════════════════════════════════════════════════════ */

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card h2 { font-size: 1.1rem; margin-bottom: 1rem; font-weight: 600; }

.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.875rem;
}

.detail-label { font-weight: 600; color: var(--color-text-muted); }

/* ═══════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════ */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: var(--color-success); }
.badge-warning { background: #fef3c7; color: var(--color-warning); }
.badge-danger { background: #fee2e2; color: var(--color-danger); }
.badge-info { background: #dbeafe; color: var(--color-primary); }
.badge-muted { background: #f1f5f9; color: var(--color-text-muted); }

/* ═══════════════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════════════ */

.text-muted { color: var(--color-text-muted); font-size: 0.85rem; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

/* ═══════════════════════════════════════════════════════
   STATS GRID
   ═══════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.stat-card:hover {
  border-color: #cbd5e1;
}

.stat-card--highlight {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.stat-card--highlight .stat-value { color: var(--color-primary); }

.stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ═══════════════════════════════════════════════════════
   BREADCRUMB
   ═══════════════════════════════════════════════════════ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.breadcrumb a { color: var(--color-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--color-border); }
.breadcrumb-current { color: var(--color-text); font-weight: 500; }

/* ═══════════════════════════════════════════════════════
   CATEGORY TREE (index)
   ═══════════════════════════════════════════════════════ */

.category-tree { display: flex; flex-direction: column; gap: 0.75rem; }

.category-tree-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.category-tree-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background: #f8fafc;
  gap: 1rem;
  flex-wrap: wrap;
}

.category-tree-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.category-icon { font-size: 1rem; }

.category-tree-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.category-tree-name:hover { color: var(--color-primary); }

.category-tree-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.category-count { font-size: 0.875rem; color: var(--color-text-muted); }

.category-children { padding: 0.875rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.category-child-row { display: flex; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap; }

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  text-decoration: none;
  transition: background 0.15s;
  flex-shrink: 0;
}

.category-chip:hover { background: #dbeafe; }
.category-chip--empty { background: var(--color-bg); border-color: var(--color-border); }

.category-chip-name { font-size: 0.8rem; font-weight: 500; color: var(--color-text); }

.category-chip-count {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--color-primary);
  color: #fff;
  border-radius: 9999px;
  padding: 0.05rem 0.35rem;
  min-width: 18px;
  text-align: center;
}

.category-chip--empty .category-chip-count { background: var(--color-text-muted); }

.category-grandchildren { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.25rem; }

.category-grandchip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.15s;
}

.category-grandchip:hover { background: #f1f5f9; color: var(--color-text); }

/* ═══════════════════════════════════════════════════════
   SUBCATEGORY GRID (show)
   ═══════════════════════════════════════════════════════ */

.subcategory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.subcategory-card {
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--color-bg);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.subcategory-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
  background: #eff6ff;
}

.subcategory-card--empty { opacity: 0.6; }

.subcategory-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.subcategory-card-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.subcategory-card-count {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-primary);
  flex-shrink: 0;
}

.subcategory-card-children { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.4rem; }

.subcategory-grandchip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  background: #fff;
  border: 1px solid var(--color-border);
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.subcategory-grandchip-count { font-weight: 700; color: var(--color-text); }

.subcategory-card-footer {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--color-border);
}

/* ═══════════════════════════════════════════════════════
   TOM SELECT CUSTOM STYLES
   ═══════════════════════════════════════════════════════ */

.ts-wrapper {
  width: 100% !important;
}

.ts-wrapper.single .ts-control {
  background: #ffffff !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius) !important;
  padding: 0.6rem 0.85rem !important;
  font-size: 0.875rem !important;
  min-height: 38px !important;
  color: var(--color-text) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.ts-wrapper.single .ts-control:hover {
  border-color: var(--color-primary) !important;
  background: #fafbfc !important;
}

.ts-wrapper.single .ts-control.dropdown-active {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
  background: #ffffff !important;
}

.ts-dropdown {
  background: #ffffff !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
              0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  margin-top: 4px !important;
  z-index: 1000 !important;
}

.ts-dropdown-content {
  background: #ffffff !important;
  max-height: 300px !important;
  overflow-y: auto !important;
}

.ts-dropdown .option {
  padding: 0.6rem 0.85rem !important;
  font-size: 0.875rem !important;
  background: #ffffff !important;
  color: var(--color-text) !important;
  cursor: pointer !important;
  transition: background 0.15s ease !important;
}

.ts-dropdown .option:hover {
  background: #f8fafc !important;
}

.ts-dropdown .option.active {
  background: #eff6ff !important;
  color: var(--color-primary) !important;
  font-weight: 500 !important;
}

.ts-dropdown .option.selected {
  background: #e0f2fe !important;
  color: var(--color-primary) !important;
}

.ts-option-parent {
  font-weight: 600 !important;
  color: var(--color-text) !important;
  background: #ffffff !important;
}

.ts-option-child {
  padding-left: 1.5rem !important;
  color: var(--color-text-muted) !important;
  font-size: 0.85rem !important;
  background: #ffffff !important;
}

.ts-dropdown .optgroup-header {
  background: #f8fafc !important;
  color: var(--color-text-muted) !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  padding: 0.5rem 0.85rem !important;
  letter-spacing: 0.05em !important;
}

.ts-dropdown .no-results {
  padding: 1rem 0.85rem !important;
  text-align: center !important;
  color: var(--color-text-muted) !important;
  font-size: 0.875rem !important;
  background: #ffffff !important;
}

.ts-wrapper.single .ts-control .item {
  color: var(--color-text) !important;
}

.ts-wrapper.single .ts-control::after {
  border-color: var(--color-text-muted) transparent transparent !important;
  border-width: 5px 5px 0 !important;
  margin-top: -3px !important;
}

.ts-dropdown .dropdown-input-wrap {
  padding: 0.5rem !important;
  background: #f8fafc !important;
  border-bottom: 1px solid var(--color-border) !important;
}

.ts-dropdown .dropdown-input {
  width: 100% !important;
  padding: 0.5rem 0.75rem !important;
  font-size: 0.875rem !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 6px !important;
  background: #ffffff !important;
  color: var(--color-text) !important;
}

.ts-dropdown .dropdown-input:focus {
  outline: none !important;
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1) !important;
}

.ts-dropdown .dropdown-input::placeholder {
  color: var(--color-text-muted) !important;
}

.ts-dropdown-content::-webkit-scrollbar { width: 8px; }
.ts-dropdown-content::-webkit-scrollbar-track { background: #f8fafc; border-radius: 4px; }
.ts-dropdown-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.ts-dropdown-content::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ═══════════════════════════════════════════════════════
   PRODUCT FILTERS SIDEBAR
   ═══════════════════════════════════════════════════════ */

.products-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .products-layout {
    grid-template-columns: 1fr;
  }
  .filters-sidebar {
    display: none;
  }
}

.filters-sidebar {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.filters-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--color-text);
}

.filters-title svg {
  width: 20px;
  height: 20px;
  margin-right: 0.5rem;
}

.filter-group {
  margin-bottom: 1.25rem;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.filter-group:last-child { margin-bottom: 0; }

.filter-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-label-icon {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.filter-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all 0.2s ease;
}

.filter-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-input::placeholder { color: var(--color-text-muted); }

.filter-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.filter-range input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.filter-range input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #eff6ff;
  border-radius: var(--radius);
}

.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  background: var(--color-surface);
  border: 1px solid #bfdbfe;
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--color-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.filter-tag-remove {
  color: var(--color-danger);
  font-weight: 700;
  cursor: pointer;
  padding: 0 0.2rem;
  text-decoration: none;
  transition: transform 0.15s;
}

.filter-tag-remove:hover { transform: scale(1.2); }

.clear-filters {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-danger);
  text-decoration: none;
  border: 1px solid var(--color-danger);
  border-radius: 6px;
  transition: all 0.2s;
  background: var(--color-surface);
}

.clear-filters:hover {
  background: #fef2f2;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.15);
}

.products-main {
  min-width: 0;
}

.products-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.products-count {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.products-sort {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.products-sort select {
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* ═══════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════ */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin-top: 1.5rem;
  padding: 1rem 0;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  transition: background 0.15s, border-color 0.15s;
}

.pagination a:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
}

.pagination .current {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.pagination .disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .gap {
  border: none;
  background: none;
}

/* ═══════════════════════════════════════════════════════
   SUPPLIER CARDS (index dashboard)
   ═══════════════════════════════════════════════════════ */

.supplier-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1rem;
}

@media (max-width: 500px) {
  .supplier-cards {
    grid-template-columns: 1fr;
  }
}

.supplier-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.15s;
}

.supplier-card:hover {
  border-color: #cbd5e1;
}

.supplier-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.supplier-card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.supplier-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.supplier-card-name:hover {
  color: var(--color-primary);
}

.supplier-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  text-align: center;
}

.supplier-stat {
  background: var(--color-bg);
  border-radius: var(--radius);
  padding: 0.5rem;
}

.supplier-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  display: block;
  line-height: 1.2;
}

.supplier-stat-value--success { color: var(--color-success); }
.supplier-stat-value--warning { color: var(--color-warning); }

.supplier-stat-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* ── Progress bar ───────────────────────────────────── */
.supplier-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.supplier-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.supplier-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.supplier-progress-fill--complete {
  background: var(--color-success);
}

.supplier-progress-text {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.supplier-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

/* button warning variant */
.btn-warning {
  background: var(--color-warning);
  color: #fff;
  border-color: var(--color-warning);
}
.btn-warning:hover { background: #b45309; }

/* ═══════════════════════════════════════════════════════
   VIEW TABS (Pendientes / Todos)
   ═══════════════════════════════════════════════════════ */

.view-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--color-border);
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.view-tab:hover {
  color: var(--color-text);
  border-bottom-color: #cbd5e1;
}

.view-tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.view-tab-badge {
  background: var(--color-warning);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  min-width: 20px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════
   FILTER BAR (chip-based supplier filter)
   ═══════════════════════════════════════════════════════ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.filter-bar-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-right: 0.25rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.filter-chip--active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.filter-chip-count {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(255,255,255,0.3);
  padding: 0.05rem 0.3rem;
  border-radius: 9999px;
  min-width: 16px;
  text-align: center;
}

.filter-chip--active .filter-chip-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════
   SECTION HEADERS (icon + title + action)
   ═══════════════════════════════════════════════════════ */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.section-header h2 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0;
}

.section-icon {
  width: 20px;
  height: 20px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   COLLAPSIBLE SECTIONS
   ═══════════════════════════════════════════════════════ */

.collapsible summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
}

.collapsible summary::-webkit-details-marker { display: none; }

.collapsible-trigger::before {
  content: "▶";
  font-size: 0.6rem;
  margin-right: 0.5rem;
  color: var(--color-text-muted);
  transition: transform 0.2s;
  display: inline-block;
}

.collapsible[open] .collapsible-trigger::before {
  transform: rotate(90deg);
}

/* ═══════════════════════════════════════════════════════
   LOG OUTPUT
   ═══════════════════════════════════════════════════════ */

.log-output {
  background: var(--color-bg);
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  overflow-x: auto;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-output--error {
  background: #fef2f2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

/* ═══════════════════════════════════════════════════════
   IMPORT PROGRESS PANEL
   ═══════════════════════════════════════════════════════ */

.import-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 300px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  transform: translateY(calc(100% + 2rem));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.import-panel--visible { transform: translateY(0); }

.import-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--color-primary);
  color: #fff;
}

.import-panel__title { font-size: 0.85rem; font-weight: 600; }

.import-panel__close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.15rem;
}

.import-panel__close:hover { color: #fff; }

.import-panel__body { padding: 1rem; }

.import-panel__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text);
}

.import-panel__stats {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.import-panel__stat-row { display: flex; justify-content: space-between; }
.import-panel__stat-row strong { color: var(--color-text); }
.import-panel__error { color: var(--color-danger); font-size: 0.8rem; }
.import-panel__actions { margin-top: 0.75rem; }

.import-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: import-spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes import-spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════
   PHOTO GALLERY
   ═══════════════════════════════════════════════════════ */

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  background: var(--color-bg);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.photo-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.photo-link {
  display: block;
  width: 100%;
  height: 100%;
}

.photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 640px) {
  .photo-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }
}
