/* brini-admin.css
 * Sistema de inventario del taller BRINI.
 * Mobile-first desde 320px, paleta morado/violeta consistente con brini.cl.
 * Sin frameworks, vanilla CSS con custom properties.
 */

/* ============================================================================
   RESET + VARIABLES
   ============================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Paleta morado/violeta (misma que brini.cl) */
  --primary: #7e22ce;
  --primary-dark: #6b21a8;
  --primary-deep: #4c1d95;
  --accent: #9333ea;
  --accent-gold: #f59e0b;

  /* Estados */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  /* Superficies */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-alt: #f1f5f9;
  --bg-dim: #faf5ff;

  /* Texto */
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-on-primary: #ffffff;

  /* Bordes */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Sombras (SaaS premium sobrio) */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Tipografia */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;

  /* Transiciones */
  --t-fast: 0.15s ease-out;
  --t-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh; /* dynamic viewport (mobile) */
  padding-bottom: 80px; /* espacio para bottom nav */
}

/* ============================================================================
   LAYOUT: header sticky + main + bottom nav
   ============================================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.app-header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--secondary, #0f172a);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header .back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  font-size: 1rem;
}
.app-header .back-btn:hover { background: var(--bg-alt); color: var(--primary); }

.app-header .header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.05rem;
  position: relative;
}
.app-header .header-icon-btn:hover { background: var(--bg-alt); color: var(--primary); }

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 0.95rem;
}
.app-brand .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* ============================================================================
   BOTTOM NAV (la barra de abajo, fija, mobile-first)
   ============================================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  position: relative;
  transition: color var(--t-fast);
  min-height: 44px;
}
.bottom-nav a i { font-size: 1.2rem; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}
.bottom-nav a .badge {
  position: absolute;
  top: 6px;
  right: 22%;
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.card.tappable { cursor: pointer; }
.card.tappable:active { transform: scale(0.98); box-shadow: var(--shadow-sm); }

.card-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}
.card-body { padding: 14px; }
.card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================================
   KPI CARDS (para el dashboard)
   ============================================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi-card .kpi-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(126, 34, 206, 0.08);
  color: var(--primary);
}
.kpi-card.kpi-warn .kpi-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.kpi-card.kpi-success .kpi-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.kpi-card.kpi-danger .kpi-icon { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================================
   LISTA DE ITEMS (cajas, pedidos, productos)
   ============================================================================ */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.list-item:active { transform: scale(0.99); }
.list-item:hover { box-shadow: var(--shadow-md); }

.list-item .item-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border);
}
.list-item .item-body {
  flex: 1;
  min-width: 0;
}
.list-item .item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.list-item .item-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: right;
  flex-shrink: 0;
}

/* ============================================================================
   ESTADOS / BADGES
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge.badge-pendiente  { background: rgba(245, 158, 11, 0.12); color: #b45309; }
.badge.badge-en_corte   { background: rgba(59, 130, 246, 0.12); color: #1e40af; }
.badge.badge-en_bordado { background: rgba(168, 85, 247, 0.12); color: #6b21a8; }
.badge.badge-en_costura { background: rgba(236, 72, 153, 0.12); color: #9d174d; }
.badge.badge-listo      { background: rgba(16, 185, 129, 0.12); color: #047857; }
.badge.badge-entregado  { background: rgba(100, 116, 139, 0.15); color: #475569; }
.badge.badge-cancelado  { background: rgba(239, 68, 68, 0.12); color: #b91c1c; }
.badge.badge-muted      { background: var(--bg-alt); color: var(--text-muted); }
.badge.badge-primary    { background: rgba(126, 34, 206, 0.1); color: var(--primary-dark); }

/* ============================================================================
   TABS
   ============================================================================ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1;
  min-width: max-content;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.tab.active { background: var(--primary); color: #fff; }
.tab:not(.active):hover { color: var(--primary); background: var(--bg-alt); }

/* ============================================================================
   BOTONES
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: rgba(126, 34, 206, 0.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; min-height: 36px; }

/* FAB (Floating Action Button) */
.fab {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 40;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 8px 24px rgba(126, 34, 206, 0.4);
  transition: transform var(--t-fast);
}
.fab:active { transform: scale(0.92); }

/* ============================================================================
   EXPORT MENU (popover anclado al boton "Exportar" del header)
   ============================================================================ */
.export-menu {
  position: fixed;
  top: 60px;
  right: 12px;
  z-index: 60;
  min-width: 220px;
  max-width: calc(100vw - 24px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  animation: exportMenuIn 0.15s ease-out;
}
.export-menu.open { display: block; }
@keyframes exportMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.export-menu-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px 4px;
}
.export-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
  min-height: 40px;
}
.export-menu-item:hover { background: var(--bg-alt); }
.export-menu-item i { color: var(--primary); width: 18px; text-align: center; }
.export-menu-item .em-sub { font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 1px; }
.export-menu-item .em-text { display: flex; flex-direction: column; }
.export-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}
.export-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: transparent;
  display: none;
}
.export-backdrop.open { display: block; }

/* ============================================================================
   FORMULARIOS
   ============================================================================ */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text-main);
  min-height: 44px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(126, 34, 206, 0.12);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================================
   MODAL / SHEET (bottom sheet en mobile, modal en desktop)
   ============================================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
}
.sheet-backdrop.open { opacity: 1; visibility: visible; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 101;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform var(--t-base);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 10px auto 6px;
}
.sheet-header {
  padding: 8px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet-title { font-size: 1.05rem; font-weight: 700; }
.sheet-close {
  background: var(--bg-alt);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
}
.sheet-body { padding: 18px; }
.sheet-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================================
   TOAST (notificaciones)
   ============================================================================ */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}
.toast {
  background: var(--text-main);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDownFade 0.3s ease-out;
}
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); color: #422006; }
@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   LOADING
   ============================================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 16px;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; color: var(--text-light); margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; color: var(--text-main); margin-bottom: 4px; }
.empty-state p { font-size: 0.88rem; }

/* ============================================================================
   SECCIONES ESPECIFICAS
   ============================================================================ */
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 18px 0 8px;
  padding-left: 4px;
}
.section-title:first-child { margin-top: 0; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.quick-action {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-decoration: none;
  color: var(--text-main);
  cursor: pointer;
  transition: all var(--t-fast);
}
.quick-action:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.quick-action:active { transform: scale(0.98); }
.quick-action .qa-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(126, 34, 206, 0.12), rgba(147, 51, 234, 0.12));
  color: var(--primary);
  font-size: 1.1rem;
}
.quick-action .qa-title { font-weight: 700; font-size: 0.92rem; }
.quick-action .qa-sub { font-size: 0.75rem; color: var(--text-muted); }

/* Caja: card especial con color de la caja */
.caja-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all var(--t-fast);
}
.caja-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.caja-card:active { transform: scale(0.99); }
.caja-card .caja-color {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.caja-card .caja-info { flex: 1; min-width: 0; }
.caja-card .caja-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}
.caja-card .caja-loc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.caja-card .caja-count {
  background: var(--bg-alt);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Item en caja: lista simple con cantidad editable */
.stock-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.stock-row:last-child { border-bottom: none; }
.stock-row .stock-name { font-weight: 600; font-size: 0.92rem; }
.stock-row .stock-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  padding: 2px;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 700;
}
.qty-btn:active { background: rgba(126, 34, 206, 0.15); }
.qty-value {
  min-width: 36px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

/* Pedido card */
.pedido-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.pedido-card:hover { box-shadow: var(--shadow-md); }
.pedido-card:active { transform: scale(0.99); }
.pedido-card .pedido-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 10px;
}
.pedido-card .pedido-colegio {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}
.pedido-card .pedido-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pedido-card .pedido-items {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Switch (toggle) */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 13px;
  transition: background var(--t-fast);
}
.switch-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */
:focus-visible {
  outline: 3px solid var(--accent-gold);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible, .list-item:focus-visible {
  outline-offset: 4px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  z-index: 1000;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   RESPONSIVE: 320px (iPhone SE) hasta desktop
   ============================================================================ */
@media (min-width: 640px) {
  main { padding: 24px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .quick-actions { grid-template-columns: repeat(4, 1fr); }
  .form-row { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1024px) {
  main { max-width: 960px; padding: 32px 24px 100px; }
  .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
}

/* iPhone safe areas */
@supports (padding: max(0px)) {
  .app-header { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .bottom-nav { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
