/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════════ */
:root {
  /* Vivero theme — #2D6A4F palette (Ant Design) */
  --vivero-primary:   #2d6a4f;
  --vivero-primary-d: #194533;
  --vivero-accent:    #628573;
  --vivero-light:     #c8d9d1;
  --vivero-bg:        #f2f6f4;

  /* Pet Shop theme — #23849C palette (Ant Design) */
  --pet-primary:      #23849c;
  --pet-primary-d:    #145f75;
  --pet-accent:       #4097a8;
  --pet-light:        #b2cdcf;
  --pet-bg:           #eef5f6;

  /* Regalería theme — warm purple #7952B3 */
  --reg-primary:      #7952b3;
  --reg-primary-d:    #5a3a8c;
  --reg-accent:       #9b7cc8;
  --reg-light:        #e8dff5;
  --reg-bg:           #f5f2fa;

  /* Pedidos theme — warm amber */
  --ped-primary:   #b45309;
  --ped-primary-d: #92400e;
  --ped-accent:    #d97706;
  --ped-light:     #fef3c7;
  --ped-bg:        #fffbeb;

  /* Stock theme — indigo */
  --stk-primary:   #4338ca;
  --stk-primary-d: #3730a3;
  --stk-accent:    #6366f1;
  --stk-light:     #e0e7ff;
  --stk-bg:        #eef2ff;

  /* Caja theme — emerald green */
  --caja-primary:   #059669;
  --caja-primary-d: #047857;
  --caja-accent:    #10b981;
  --caja-light:     #d1fae5;
  --caja-bg:        #ecfdf5;

  /* Dashboard theme — slate blue */
  --dash-primary:   #1e40af;
  --dash-primary-d: #1e3a8a;
  --dash-accent:    #3b82f6;
  --dash-light:     #dbeafe;
  --dash-bg:        #eff6ff;

  /* Neutral palette */
  --gray-50:   #f9fafb;
  --gray-100:  #f3f4f6;
  --gray-200:  #e5e7eb;
  --gray-300:  #d1d5db;
  --gray-500:  #6b7280;
  --gray-700:  #374151;
  --gray-900:  #111827;
  --white:     #ffffff;
  --danger:    #dc2626;
  --danger-bg: #fee2e2;

  /* Shared */
  --radius:    8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.10);
  --shadow:    0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.18);
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition: 200ms ease;

  /* Active theme (defaults to vivero) */
  --primary:   var(--vivero-primary);
  --primary-d: var(--vivero-primary-d);
  --accent:    var(--vivero-accent);
  --light:     var(--vivero-light);
  --bg:        var(--vivero-bg);
}

body.theme-vivero {
  --primary:   var(--vivero-primary);
  --primary-d: var(--vivero-primary-d);
  --accent:    var(--vivero-accent);
  --light:     var(--vivero-light);
  --bg:        var(--vivero-bg);
}

body.theme-petshop {
  --primary:   var(--pet-primary);
  --primary-d: var(--pet-primary-d);
  --accent:    var(--pet-accent);
  --light:     var(--pet-light);
  --bg:        var(--pet-bg);
}

body.theme-regaleria {
  --primary:   var(--reg-primary);
  --primary-d: var(--reg-primary-d);
  --accent:    var(--reg-accent);
  --light:     var(--reg-light);
  --bg:        var(--reg-bg);
}

body.theme-pedidos {
  --primary:   var(--ped-primary);
  --primary-d: var(--ped-primary-d);
  --accent:    var(--ped-accent);
  --light:     var(--ped-light);
  --bg:        var(--ped-bg);
}

body.theme-stock {
  --primary:   var(--stk-primary);
  --primary-d: var(--stk-primary-d);
  --accent:    var(--stk-accent);
  --light:     var(--stk-light);
  --bg:        var(--stk-bg);
}

body.theme-caja {
  --primary:   var(--caja-primary);
  --primary-d: var(--caja-primary-d);
  --accent:    var(--caja-accent);
  --light:     var(--caja-light);
  --bg:        var(--caja-bg);
}

body.theme-dashboard {
  --primary:   var(--dash-primary);
  --primary-d: var(--dash-primary-d);
  --accent:    var(--dash-accent);
  --light:     var(--dash-light);
  --bg:        var(--dash-bg);
}

body.theme-config {
  --primary:   #4b5563;
  --primary-d: #374151;
  --accent:    #9ca3af;
  --light:     #f3f4f6;
  --bg:        #f9fafb;
}

/* ═══════════════════════════════════════════════════════════════
   DARK MODE
═══════════════════════════════════════════════════════════════ */
/* Dark mode — purple palette (#BB86FC / #3700B3 family) */
body.dark {
  --white:     #1e1b2e;
  --gray-50:   #13111f;
  --gray-100:  #1a1730;
  --gray-200:  #252241;
  --gray-300:  #38345a;
  --gray-500:  #b8b0d8;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --danger-bg: #3b1212;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
  --shadow:    0 4px 16px rgba(0,0,0,.6);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.7);
}

/* Vivero dark: full palette override from #2D6A4F Ant Design dark scale */
body.dark.theme-vivero {
  --bg:        #131614;
  --white:     #15201c;
  --gray-50:   #131614;
  --gray-100:  #1c2e26;
  --gray-200:  #1f3b2f;
  --gray-300:  #244c3a;
  --gray-500:  #416e58;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --light:     #295d46;
  --primary:   #2d6a4f;
  --primary-d: #7eb89f;
  --accent:    #5e7f6e;
}
/* Regalería dark: warm purple scale */
body.dark.theme-regaleria {
  --bg:        #1a1520;
  --white:     #231d30;
  --gray-50:   #1a1520;
  --gray-100:  #2d2440;
  --gray-200:  #3d3258;
  --gray-300:  #4e4070;
  --gray-500:  #9b7cc8;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --light:     #3d3258;
  --primary:   #7952b3;
  --primary-d: #c0a8e8;
  --accent:    #9b7cc8;
}
body.dark.theme-config  { --bg: #13111f; --light: #211b38; }

/* PetShop dark: full palette override from #23849C Ant Design dark scale */
body.dark.theme-petshop {
  --bg:        #121a1d;
  --white:     #14272c;
  --gray-50:   #121a1d;
  --gray-100:  #19363d;
  --gray-200:  #1b4651;
  --gray-300:  #1e5d6c;
  --gray-500:  #5ea3ad;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --light:     #1e5d6c;
  --primary:   #23849c;
  --primary-d: #88bcc2;
  --accent:    #5ea3ad;
}

body.dark.theme-pedidos {
  --bg:        #1a1500;
  --white:     #261e00;
  --gray-50:   #1a1500;
  --gray-100:  #382d00;
  --gray-200:  #4d3d00;
  --gray-300:  #6b5500;
  --gray-500:  #c49a2a;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --light:     #4d3d00;
  --primary:   #b45309;
  --primary-d: #fbbf24;
  --accent:    #d97706;
}

body.dark.theme-stock {
  --bg:        #0e0d1f;
  --white:     #14132e;
  --gray-50:   #0e0d1f;
  --gray-100:  #1e1c42;
  --gray-200:  #2a285c;
  --gray-300:  #3b3880;
  --gray-500:  #8b89d4;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --light:     #2a285c;
  --primary:   #4338ca;
  --primary-d: #a5b4fc;
  --accent:    #6366f1;
}

body.dark.theme-caja {
  --bg:        #021a0f;
  --white:     #042d1a;
  --gray-50:   #021a0f;
  --gray-100:  #063d22;
  --gray-200:  #0a5430;
  --gray-300:  #0f6b3e;
  --gray-500:  #34d399;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --light:     #0a5430;
  --primary:   #059669;
  --primary-d: #6ee7b7;
  --accent:    #10b981;
}

body.dark.theme-dashboard {
  --bg:        #080d1a;
  --white:     #0d1630;
  --gray-50:   #080d1a;
  --gray-100:  #111d42;
  --gray-200:  #1a2d60;
  --gray-300:  #243d80;
  --gray-500:  #6b8cda;
  --gray-700:  #ffffff;
  --gray-900:  #ffffff;
  --light:     #1a2d60;
  --primary:   #1e40af;
  --primary-d: #93c5fd;
  --accent:    #3b82f6;
}

body.dark .cat-item.active,
body.dark .group-header.active .group-name { color: #ffffff; }

body.dark .form-group input,
body.dark .form-group select,
body.dark .search-input {
  background: var(--gray-100);
  color: var(--gray-900);
  border-color: var(--gray-300);
}

body.dark .search-input:focus { background: var(--gray-100); }

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--bg);
  min-height: 100vh;
  transition: background var(--transition);
}

/* ═══════════════════════════════════════════════════════════════
   NAVBAR
═══════════════════════════════════════════════════════════════ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 58px;
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow);
  transition: background var(--transition);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .02em;
  flex-shrink: 0;
}

.brand-icon { font-size: 1.3rem; }

.navbar-tabs {
  display: flex;
  gap: .25rem;
  flex: 1;
  justify-content: center;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1.2rem;
  border: 2px solid rgba(255,255,255,.3);
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255,255,255,.8);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover  { border-color: rgba(255,255,255,.7); color: var(--white); }
.tab-btn.active { background: rgba(255,255,255,.2); border-color: var(--white); color: var(--white); font-weight: 700; }

.config-btn {
  padding: .4rem .9rem;
  border: 2px solid rgba(255,255,255,.3);
  border-radius: var(--radius);
  background: transparent;
  color: rgba(255,255,255,.8);
  font-size: .85rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.config-btn:hover,
.config-btn.active { border-color: var(--white); color: var(--white); background: rgba(255,255,255,.15); }

.dark-mode-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid rgba(255,255,255,.3);
  border-radius: var(--radius);
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  line-height: 1;
}
.dark-mode-btn:hover { border-color: rgba(255,255,255,.7); background: rgba(255,255,255,.15); }

.user-badge {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.user-badge-name {
  display: inline-block;
  padding: .4rem .9rem;
  border: 2px solid rgba(255,255,255,.3);
  border-radius: var(--radius);
  color: rgba(255,255,255,.9);
  font-size: .85rem;
  font-weight: 600;
  user-select: none;
  transition: all var(--transition);
}
.user-badge:hover .user-badge-name,
.user-badge.open  .user-badge-name { border-color: var(--white); background: rgba(255,255,255,.15); color: var(--white); }
.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.user-badge.open .user-menu { display: block; }
.user-menu-item {
  display: block;
  width: 100%;
  padding: .65rem 1rem;
  background: none;
  border: none;
  text-align: left;
  font-size: .88rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition);
}
.user-menu-item:hover { background: var(--gray-50); }
.user-menu-logout { color: #dc2626; }
.user-menu-logout:hover { background: #fee2e2; }
.user-menu-divider { height: 1px; background: var(--gray-100); margin: .25rem 0; }

/* ═══════════════════════════════════════════════════════════════
   SECTIONS
═══════════════════════════════════════════════════════════════ */
.main { height: calc(100vh - 58px); overflow: hidden; }

.section { display: none; height: 100%; }
.section.active { display: flex; flex-direction: column; }

/* ── Section layout: sidebar + content ── */
.section-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════ */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem .75rem;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-header h3 {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
}

.btn-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--primary); color: var(--white); }

.cat-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: .5rem 0;
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1rem;
  cursor: pointer;
  font-size: .9rem;
  border-radius: 0;
  color: var(--gray-700);
  transition: background var(--transition);
  border-left: 3px solid transparent;
}

.cat-item:hover { background: var(--gray-100); }

.cat-item.active {
  background: var(--light);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

.cat-actions {
  display: none;
  gap: .2rem;
}

.cat-item:hover .cat-actions { display: flex; }

.cat-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: .75rem;
  line-height: 1;
  opacity: .6;
  transition: opacity var(--transition);
}
.cat-action-btn:hover { opacity: 1; }

/* ── PetShop group hierarchy ─────────────────────────────────── */
.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem .45rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition);
}

.group-header:hover { background: var(--gray-100); }

.group-header.active {
  background: var(--light);
  border-left-color: var(--primary);
}

.group-header.active .group-name {
  color: var(--primary);
  font-weight: 700;
}

.group-label {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.group-icon { font-size: 1rem; }

.group-name {
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-600);
}

.group-header .cat-actions { display: none; }
.group-header:hover .cat-actions { display: flex; }

.sub-cat-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sub-item {
  padding-left: 2.2rem;
  font-size: .875rem;
  border-left: 3px solid transparent;
}

.sub-item.active {
  border-left-color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════
   CONTENT AREA
═══════════════════════════════════════════════════════════════ */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1.25rem;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: .5rem .75rem .5rem 2.2rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
  background: var(--gray-50);
}
.search-input:focus { border-color: var(--accent); background: var(--white); }

/* ═══════════════════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════════════════ */
.table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: .875rem;
}

thead th {
  background: var(--primary);
  color: var(--white);
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

thead th:last-child { text-align: center; }

thead th.th-sortable { cursor: pointer; user-select: none; }
thead th.th-sortable:hover { filter: brightness(1.15); }
thead th.th-sorted { filter: brightness(1.1); }
.sort-icon { font-size: .7rem; opacity: .75; margin-left: .25rem; }

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

td {
  padding: .65rem 1rem;
  color: var(--gray-700);
  vertical-align: middle;
}

td.price {
  font-weight: 600;
  color: var(--primary-d);
  white-space: nowrap;
}

td.price-calc {
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}

td.actions {
  text-align: center;
  white-space: nowrap;
}

.row-cat-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  background: var(--light);
  color: var(--primary-d);
  font-size: .75rem;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}

.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: .75rem; }

.loading {
  text-align: center;
  padding: 3rem;
  color: var(--gray-500);
  font-size: .95rem;
}

/* ═══════════════════════════════════════════════════════════════
   ACTION BUTTONS
═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover { background: var(--primary-d); }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
}
.btn-ghost:hover { background: var(--gray-100); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { background: #b91c1c; }

.btn-edit, .btn-delete {
  padding: .3rem .6rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  transition: all var(--transition);
  margin: 0 .15rem;
}

.btn-edit {
  background: var(--light);
  color: var(--primary-d);
}
.btn-edit:hover { background: var(--accent); color: var(--white); }

.btn-delete {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-delete:hover { background: var(--danger); color: var(--white); }

/* ═══════════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden { display: none; }

/* Confirm dialog must always appear on top of any other open modal */
#confirm-overlay { z-index: 400; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .18s ease;
}

.modal-sm { max-width: 380px; }

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem .9rem;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 { font-size: 1.05rem; font-weight: 700; color: var(--gray-900); }

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
  padding: .2rem;
  border-radius: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--gray-900); }

.modal-form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.modal-body {
  padding: 1.2rem 1.4rem;
}

#modal-fields {
  padding: 1.2rem 1.4rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .9rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: .9rem 1.4rem;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   FORM FIELDS
═══════════════════════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.form-group label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group input,
.form-group select {
  padding: .55rem .75rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
  background: var(--white);
  color: var(--gray-900);
}

.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }

.form-group input[readonly] { background: var(--gray-100); color: var(--gray-500); cursor: default; }

.password-wrap { position: relative; }
.password-wrap input { width: 100%; padding-right: 2.4rem; box-sizing: border-box; }
.password-toggle {
  position: absolute;
  right: .55rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--gray-500);
  padding: 0;
  transition: color var(--transition);
}
.password-toggle:hover { color: var(--gray-700); }

.form-group textarea {
  padding: .55rem .75rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
  background: var(--white);
  color: var(--gray-900);
  resize: vertical;
}
.form-group textarea:focus { border-color: var(--accent); }

.modal-separator {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  font-weight: 700;
  padding: .5rem 0 .1rem;
  border-bottom: 1px solid var(--gray-200);
}

/* ═══════════════════════════════════════════════════════════════
   CONFIG SECTION
═══════════════════════════════════════════════════════════════ */
#section-config {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.config-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.config-panel h2 {
  font-size: 1.3rem;
  margin-bottom: .5rem;
  color: var(--gray-900);
}

.config-hint {
  font-size: .875rem;
  color: var(--gray-500);
  margin-bottom: 1.75rem;
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.save-badge {
  font-size: .85rem;
  color: #16a34a;
  font-weight: 600;
  align-self: center;
}
.save-badge.hidden { display: none; }

/* ═══════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  padding: .75rem 1.25rem;
  background: var(--gray-900);
  color: var(--white);
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
  max-width: 360px;
}

.toast.hidden { display: none; }
.toast.success { background: #16a34a; }
.toast.error   { background: var(--danger); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   LOAD MORE
═══════════════════════════════════════════════════════════════ */
.load-more-wrap {
  text-align: center;
  padding: 1rem 1.25rem;
}

.load-more-btn {
  width: 100%;
  max-width: 360px;
  justify-content: center;
  border-style: dashed;
  color: var(--gray-500);
}
.load-more-btn:hover { color: var(--primary); border-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   PEDIDOS SECTION
═══════════════════════════════════════════════════════════════ */
.pedidos-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.toolbar-pedidos { flex-wrap: wrap; gap: .5rem; }

.filter-select {
  padding: .48rem .65rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--accent); }

body.dark .filter-select {
  background: var(--gray-100);
  color: var(--gray-900);
  border-color: var(--gray-300);
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .02em;
}

.badge-success    { background: #dcfce7; color: #15803d; }
.badge-danger     { background: #fee2e2; color: #b91c1c; }
.badge-warning    { background: #fef3c7; color: #b45309; }
.badge-info       { background: #dbeafe; color: #1d4ed8; }
.badge-preparing  { background: #fef9c3; color: #854d0e; }

body.dark .badge-success   { background: #14532d; color: #86efac; }
body.dark .badge-danger    { background: #450a0a; color: #fca5a5; }
body.dark .badge-warning   { background: #451a03; color: #fcd34d; }
body.dark .badge-info      { background: #1e3a5f; color: #93c5fd; }
body.dark .badge-preparing { background: #422006; color: #fde68a; }

.pedido-desc {
  color: var(--gray-700);
  font-size: .95rem;
  font-weight: 700;
  max-width: 200px;
}

.price-danger {
  color: var(--danger);
  font-weight: 600;
  white-space: nowrap;
}

.text-success { color: #15803d !important; }
.text-danger  { color: #b91c1c !important; }

/* ── Pagos modal ─────────────────────────────────────────────── */
.modal-pagos { max-width: 620px; }

.pagos-summary {
  display: flex;
  gap: .75rem;
  padding: .85rem 1.4rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pagos-summary-item {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
  min-width: 110px;
}

.pagos-summary-item > span {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  font-weight: 600;
}

.pagos-summary-item > strong { font-size: .95rem; color: var(--gray-900); }

.pagos-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1.4rem;
  min-height: 80px;
  max-height: 220px;
}

.pagos-empty {
  text-align: center;
  color: var(--gray-500);
  font-size: .9rem;
  padding: 1.25rem 0;
}

.pagos-loading {
  padding: .75rem 0;
  color: var(--gray-500);
  font-size: .9rem;
}

.pagos-table { font-size: .875rem; }
.pagos-table thead th { font-size: .75rem; }

.pagos-add-form {
  padding: .9rem 1.4rem .6rem;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.pagos-add-form h4 {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  margin-bottom: .6rem;
}

.pago-form-row {
  display: flex;
  gap: .65rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.pago-form-row .form-group { flex: 1; min-width: 90px; }
.pago-form-row .btn { flex-shrink: 0; padding: .53rem 1rem; }

/* ═══════════════════════════════════════════════════════════════
   STOCK SECTION
═══════════════════════════════════════════════════════════════ */
.stock-badge, .stock-ok, .stock-low, .stock-empty {
  display: inline-block;
  padding: .18rem .65rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.stock-ok    { background: #dcfce7; color: #15803d; }
.stock-low   { background: #fef9c3; color: #854d0e; }
.stock-empty { background: #fee2e2; color: #b91c1c; }

body.dark .stock-ok    { background: #14532d; color: #86efac; }
body.dark .stock-low   { background: #422006; color: #fde68a; }
body.dark .stock-empty { background: #450a0a; color: #fca5a5; }

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

.movimientos-filters {
  display: flex;
  gap: .4rem;
  padding: .6rem 1.4rem;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.movimientos-filters .btn-days        { font-size: .8rem; padding: .3rem .7rem; }
.movimientos-filters .btn-days.active { background: var(--light); color: var(--primary-d); border-color: var(--primary); }

.modal-movimientos { max-width: 700px; }

.mov-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.mov-inicial { background: #f3f4f6; color: #374151; }
.mov-entrada { background: #dcfce7; color: #15803d; }
.mov-salida  { background: #fee2e2; color: #b91c1c; }
.mov-ajuste  { background: #fef3c7; color: #b45309; }

body.dark .mov-inicial { background: #374151; color: #d1d5db; }
body.dark .mov-entrada { background: #14532d; color: #86efac; }
body.dark .mov-salida  { background: #450a0a; color: #fca5a5; }
body.dark .mov-ajuste  { background: #451a03; color: #fcd34d; }

/* Habilitar results */
.hab-results {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  max-height: 250px;
  overflow-y: auto;
}

.hab-result-item {
  display: flex;
  align-items: center;
  padding: .55rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-size: .875rem;
  text-align: left;
  transition: all var(--transition);
  font-family: var(--font);
}
.hab-result-item:hover { border-color: var(--accent); background: var(--light); }

/* ═══════════════════════════════════════════════════════════════
   CAJA SECTION
═══════════════════════════════════════════════════════════════ */
.caja-summary {
  display: flex;
  gap: .75rem;
  padding: .85rem 1.25rem;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.caja-summary.hidden { display: none; }

.caja-summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 120px;
  padding: .6rem 1rem;
  border-radius: var(--radius);
  gap: .2rem;
}

.caja-card-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  color: var(--gray-500);
}

.caja-card-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gray-900);
}

.caja-card-ingresos { background: #dcfce7; }
.caja-card-egresos  { background: #fee2e2; }
.caja-card-balance  { background: var(--light); }

body.dark .caja-card-ingresos { background: #14532d; }
body.dark .caja-card-egresos  { background: #450a0a; }
body.dark .caja-card-balance  { background: var(--light); }

.caja-badge {
  display: inline-block;
  padding: .18rem .65rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  white-space: nowrap;
}
.caja-ingreso { background: #dcfce7; color: #15803d; }
.caja-egreso  { background: #fee2e2; color: #b91c1c; }

body.dark .caja-ingreso { background: #14532d; color: #86efac; }
body.dark .caja-egreso  { background: #450a0a; color: #fca5a5; }

.caja-monto-ingreso { color: #15803d !important; }
.caja-monto-egreso  { color: #b91c1c !important; }

body.dark .caja-monto-ingreso { color: #86efac !important; }
body.dark .caja-monto-egreso  { color: #fca5a5 !important; }

.metodo-badge {
  display: inline-block;
  padding: .15rem .5rem;
  background: var(--gray-100);
  border-radius: var(--radius);
  font-size: .75rem;
  font-weight: 700;
  color: var(--gray-700);
  font-family: monospace;
  letter-spacing: .03em;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD SECTION
═══════════════════════════════════════════════════════════════ */
.dashboard-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.dash-filters {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.25rem;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.dash-filter-group {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
}

.dash-period-btn {
  padding: .35rem .8rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: transparent;
  color: var(--gray-700);
  font-size: .8rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.dash-period-btn:hover  { border-color: var(--accent); color: var(--primary); }
.dash-period-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

.dash-custom-range {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.dash-custom-range.hidden { display: none; }

.dash-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background: var(--bg);
}

/* Grid */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}

.dash-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dash-card-wide {
  grid-column: 1 / -1;
}

.dash-card-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .8rem 1.1rem .6rem;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-100);
}

.dash-alert-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 99px;
  font-size: .7rem;
  padding: .1rem .5rem;
  font-weight: 700;
}

/* KPI row */
.dash-kpis {
  display: flex;
  gap: .75rem;
  padding: .85rem 1.1rem;
  flex-wrap: wrap;
}

.dash-kpi {
  flex: 1;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  gap: .3rem;
}

.dash-kpi-ingreso { background: #dcfce7; }
.dash-kpi-egreso  { background: #fee2e2; }
.dash-kpi-balance { background: var(--light); }

body.dark .dash-kpi-ingreso { background: #14532d; }
body.dark .dash-kpi-egreso  { background: #450a0a; }
body.dark .dash-kpi-balance { background: var(--light); }

.dash-kpi-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
  color: var(--gray-500);
}

.dash-kpi-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gray-900);
  white-space: nowrap;
}

/* Tables inside cards */
.dash-table {
  width: 100%;
  font-size: .85rem;
  border-collapse: collapse;
}
.dash-table thead th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .5rem .9rem;
  text-align: left;
}
.dash-table tbody td { padding: .55rem .9rem; border-bottom: 1px solid var(--gray-100); }
.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-total-row td { background: var(--gray-50); }

/* Sin stock alert */
.dash-alert-ok .dash-card-header { color: #15803d; }

.dash-alert-empty {
  padding: .9rem 1.1rem;
  color: var(--gray-500);
  font-size: .875rem;
}

.sin-stock-list {
  padding: .6rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.sin-stock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .3rem .4rem;
  border-radius: var(--radius);
  background: var(--gray-50);
}

.sin-stock-nombre {
  font-size: .875rem;
  font-weight: 600;
  color: var(--gray-900);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .sidebar { width: 160px; }
  .brand-name { display: none; }
  table { font-size: .8rem; }
  td, th { padding: .5rem .6rem; }
  .config-panel { margin: 1rem; }
}

@media (max-width: 500px) {
  .sidebar { display: none; }
  .toolbar { flex-wrap: wrap; }
}
