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

:root {
  --primary:      #2563eb;
  --primary-h:    #1d4ed8;
  --primary-light:#eff6ff;
  --primary-glow: rgba(37,99,235,.18);
  --success:      #16a34a;
  --success-light:#dcfce7;
  --danger:       #dc2626;
  --danger-light: #fee2e2;
  --warning:      #d97706;
  --warning-light:#fef3c7;
  --purple:       #7c3aed;
  --purple-light: #ede9fe;
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --surface2:     #f8fafc;
  --border:       #e2e8f0;
  --border-focus: #93c5fd;
  --text:         #0f172a;
  --text-2:       #334155;
  --muted:        #64748b;
  --muted-light:  #94a3b8;
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:    0 16px 48px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.06);
}

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a    { color: inherit; text-decoration: none; }

/* ─── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1d4ed8 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,.25) 0%, transparent 70%);
  top: -200px; right: -100px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,.2) 0%, transparent 70%);
  bottom: -100px; left: -50px;
}

.login-container {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 52px 44px;
  text-align: center;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.1);
}

.login-logo {
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
}
.login-logo svg { width: 80px; height: 80px; filter: drop-shadow(0 8px 16px rgba(37,99,235,.4)); }

.login-container h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle { color: var(--muted); margin-bottom: 32px; font-size: .95rem; }

.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  background: var(--surface2);
}
.role-card:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--primary-glow);
}
.role-icon { font-size: 2.6rem; line-height: 1; }
.role-card h2 { font-size: 1rem; font-weight: 700; }
.role-card p  { font-size: .8rem; color: var(--muted); }

/* ─── App page ───────────────────────────────────────────────────────────── */
.app-page { min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 58px;
  background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(37,99,235,.35);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

.topbar-right { display: flex; align-items: center; gap: 10px; font-size: .85rem; }

.back-btn {
  font-size: .82rem;
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 20px;
  background: rgba(255,255,255,.1);
  color: #fff;
  transition: all .2s;
}
.back-btn:hover { background: rgba(255,255,255,.2); }

/* ─── Pestañas ───────────────────────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  gap: 2px;
  overflow-x: auto;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.tab-btn {
  background: none;
  border: none;
  padding: 0 20px;
  height: 48px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all .2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tab-btn:hover  { color: var(--primary); background: var(--primary-light); border-radius: 8px 8px 0 0; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content        { display: none; }
.tab-content.active {
  display: block;
  height: calc(100vh - 58px - 49px);
  overflow-y: auto;
  padding: 28px 32px;
  background: var(--bg);
}

/* ─── Tab top header ─────────────────────────────────────────────────────── */
.tab-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.tab-top-left { display: flex; align-items: center; gap: 12px; }
.tab-top-left h2 { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.tab-top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-input {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  background: var(--surface);
  color: var(--text);
  width: 260px;
  transition: border-color .2s, box-shadow .2s;
}
.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ─── Form 2-column grid inside modals ───────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}
.form-grid .field      { margin-bottom: 14px; }
.form-grid .field-full { grid-column: 1 / -1; }
.form-grid .field-group-title { grid-column: 1 / -1; }

/* Wide modal for products/bottles */
.modal-xl { max-width: 860px !important; }

/* ─── Pedido cards ───────────────────────────────────────────────────────── */
.pedido-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.pedido-card:hover { box-shadow: var(--shadow); border-color: var(--border-focus); }

.pedido-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 12px;
}
.pedido-card-titulo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pedido-card-titulo h3 { font-size: 1rem; font-weight: 700; color: var(--text); }

.estado-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.estado-dot-pendiente  { background: var(--warning); }
.estado-dot-en_proceso { background: var(--primary); }
.estado-dot-completado { background: var(--success); }

.pedido-card-meta {
  display: flex;
  gap: 18px;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pedido-progress { margin-bottom: 12px; }
.progress-label { font-size: .75rem; color: var(--muted); margin-top: 4px; display: block; }
.pedido-no-lineas { font-size: .8rem; color: var(--muted); margin-bottom: 12px; font-style: italic; }

.pedido-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Pedido name preview ─────────────────────────────────────────────────── */
.nombre-preview {
  background: var(--primary-light);
  border: 1.5px dashed var(--border-focus);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
  min-height: 38px;
}

/* ─── Operario view ──────────────────────────────────────────────────────── */
.op-pedido-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.op-pedido-card:hover { border-color: var(--primary); box-shadow: 0 4px 16px var(--primary-glow); transform: translateY(-2px); }
.op-pedido-titulo { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.op-pedido-meta   { font-size: .8rem; color: var(--muted); margin-bottom: 12px; }

.op-lineas-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.op-linea-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all .2s;
}
.op-linea-item:hover { border-color: var(--primary); background: var(--primary-light); }
.op-linea-item.completada { opacity: .6; border-color: var(--success); background: var(--success-light); }
.op-linea-num { font-size: 1.1rem; font-weight: 800; color: var(--muted); min-width: 28px; }
.op-linea-info { flex: 1; }
.op-linea-desc { font-size: .92rem; font-weight: 600; }
.op-linea-sub  { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.op-linea-status { font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.op-linea-status.ok { background: var(--success-light); color: var(--success); }
.op-linea-status.pending { background: var(--warning-light); color: var(--warning); }

/* ─── Tarjeta expandida de línea (operario) ──────────────────────────────── */
.op-linea-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.op-linea-card + .op-linea-card { margin-top: 14px; }
.op-linea-card.completada { border-color: var(--success); background: linear-gradient(to right, #f0fdf4, var(--surface)); opacity: .85; }

.op-linea-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.op-linea-card-titulo { font-size: 1rem; font-weight: 800; color: var(--text); }
.op-linea-card-codigo { font-size: .78rem; color: var(--muted); font-family: monospace; margin-top: 2px; }

.op-linea-datos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.op-datos-grupo {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.op-datos-titulo {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.op-linea-instrucciones {
  font-size: .84rem;
  color: var(--text-2);
  background: var(--warning-light);
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.op-btn-completar {
  margin-top: 14px;
  font-size: .95rem;
  padding: 13px 20px;
  width: 100%;
}
.btn-video-link {
  background: #0369a1;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-video-link:hover { background: #0284c7; }

/* Detail view for operator line */
.op-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.btn-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--text-2);
  transition: all .2s;
  white-space: nowrap;
}
.btn-back:hover { background: var(--surface2); }

/* ─── Barra de filtros (admin pedidos) ───────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filter-bar select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: .84rem;
  color: var(--text);
  background: var(--surface2);
  cursor: pointer;
  min-width: 140px;
}
.filter-bar select:focus {
  outline: none;
  border-color: var(--border-focus);
}
.filter-bar .search-input {
  height: 38px;
  background: var(--surface2);
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  height: calc(100vh - 58px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
}

.content {
  padding: 28px;
  overflow-y: auto;
  background: var(--bg);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::before {
  content: '';
  display: inline-block;
  width: 4px; height: 18px;
  background: linear-gradient(180deg, var(--primary), var(--purple));
  border-radius: 2px;
}

.card h3 { font-size: .9rem; font-weight: 700; margin-bottom: 14px; color: var(--text-2); }

/* ─── Pedido items ───────────────────────────────────────────────────────── */
.pedido-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.pedido-item:hover  { border-color: var(--primary); box-shadow: 0 4px 16px var(--primary-glow); transform: translateY(-1px); }
.pedido-item.active { border-color: var(--primary); background: var(--primary-light); }

.pedido-item-info h3 { font-size: .92rem; font-weight: 700; margin-bottom: 4px; }
.pedido-item-info p  { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pedido-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─── Referencias ────────────────────────────────────────────────────────── */
.ref-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.ref-item:hover { border-color: var(--border-focus); box-shadow: var(--shadow); }

.ref-info   { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ref-codigo {
  font-size: .7rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  width: fit-content;
}
.ref-nombre { font-size: .95rem; font-weight: 600; color: var(--text); }
.ref-desc   { font-size: .8rem; color: var(--muted); }
.ref-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─── Ref tag (litros, envase, etc.) ────────────────────────────────────── */
.ref-tag {
  font-size: .72rem;
  font-weight: 600;
  color: var(--purple);
  background: var(--purple-light);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  width: fit-content;
}

/* ─── Field group title (separador en formularios) ───────────────────────── */
.field-group-title {
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-top: 18px;
  margin-bottom: 12px;
}

/* ─── Search bar ─────────────────────────────────────────────────────────── */
.search-bar {
  margin-bottom: 16px;
}
.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ─── Líneas de pedido ───────────────────────────────────────────────────── */
.linea-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}
.linea-item.completada { opacity: .6; background: var(--surface2); }
.linea-item.completada .linea-desc { text-decoration: line-through; }

.linea-clickable { cursor: pointer; }
.linea-clickable:hover { border-color: var(--primary); box-shadow: 0 4px 16px var(--primary-glow); transform: translateY(-1px); }

.linea-info { flex: 1; }
.linea-desc { font-size: .9rem; font-weight: 600; }
.linea-sub  { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.linea-badges { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ─── Estado badges ──────────────────────────────────────────────────────── */
.estado-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.estado-pendiente  { background: var(--warning-light); color: #92400e; }
.estado-en_proceso { background: var(--primary-light); color: #1e40af; }
.estado-completado { background: var(--success-light); color: #166534; }

.badge {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: .75rem;
  font-weight: 700;
}

.tag-video { background: var(--primary-light); color: #1e40af; padding: 3px 9px; border-radius: 12px; font-size: .72rem; font-weight: 700; }
.tag-ok    { background: var(--success-light); color: #166534; padding: 3px 9px; border-radius: 12px; font-size: .72rem; font-weight: 700; }

/* ─── Formularios ────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all .2s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.field small { font-size: .75rem; color: var(--muted); margin-top: 5px; display: block; }
.field input[type="file"] { padding: 7px; background: var(--surface2); }

/* ─── Botones ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  font-family: inherit;
  letter-spacing: .01em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-h) 0%, var(--primary) 100%);
  box-shadow: 0 4px 16px rgba(37,99,235,.45);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-danger  { background: linear-gradient(135deg, var(--danger), #ef4444); color: #fff; box-shadow: 0 2px 6px rgba(220,38,38,.25); }
.btn-danger:hover  { background: linear-gradient(135deg, #b91c1c, var(--danger)); box-shadow: 0 4px 12px rgba(220,38,38,.35); transform: translateY(-1px); }

.btn-success { background: linear-gradient(135deg, var(--success), #22c55e); color: #fff; box-shadow: 0 2px 6px rgba(22,163,74,.25); }
.btn-success:hover { background: linear-gradient(135deg, #15803d, var(--success)); box-shadow: 0 4px 12px rgba(22,163,74,.35); transform: translateY(-1px); }

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

.btn-sm   { padding: 6px 12px; font-size: .78rem; border-radius: 6px; }
.btn-full { width: 100%; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  width: 90%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.8);
  overflow: hidden;
}
.modal-box-wide { max-width: 740px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }

.modal-close {
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }

.modal-body { padding: 24px 26px; overflow-y: auto; flex: 1; }

/* ─── Vídeo ──────────────────────────────────────────────────────────────── */
video {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
  margin-bottom: 18px;
  max-height: 360px;
  box-shadow: var(--shadow);
}

.sin-video {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px;
  background: var(--surface2);
  border-radius: var(--radius);
  color: var(--muted);
  margin-bottom: 18px;
  gap: 8px;
  border: 1.5px dashed var(--border);
}
.sin-video span { font-size: 2.5rem; }
.sin-video p    { font-size: .9rem; }

.instrucciones-box {
  background: linear-gradient(135deg, var(--surface2), var(--primary-light));
  border: 1px solid var(--border-focus);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 4px;
}
.instrucciones-box h3 { font-size: .88rem; font-weight: 700; margin-bottom: 10px; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; }
.instrucciones-box p  { font-size: .92rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

/* ─── Progress bar ───────────────────────────────────────────────────────── */
.progress-bar {
  background: var(--border);
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  border-radius: 10px;
  transition: width .3s;
  width: 0%;
}
#progress-text { font-size: .8rem; color: var(--muted); }

/* ─── Section header ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* ─── Detalle operario ───────────────────────────────────────────────────── */
.detalle-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 14px;
}
.placeholder-icon { font-size: 4.5rem; filter: grayscale(1) opacity(.4); }
.detalle-placeholder p { font-size: .95rem; font-weight: 500; }

.detalle-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}
.detalle-header h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }

/* ─── Usuarios (panel control) ───────────────────────────────────────────── */
.usuario-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.usuario-item:hover { box-shadow: var(--shadow); }
.usuario-item.inactivo { opacity: .5; }

.usuario-info { flex: 1; }
.usuario-nombre { font-size: .98rem; font-weight: 700; }
.usuario-meta   { font-size: .8rem; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.usuario-actions { display: flex; gap: 6px; flex-shrink: 0; }

.rol-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.rol-admin    { background: var(--purple-light); color: #5b21b6; }
.rol-operario { background: var(--primary-light); color: #1e40af; }

.tag-inactivo {
  background: var(--border);
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 700;
}

/* ─── Tarifas ────────────────────────────────────────────────────────────── */
.tarifa-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.tarifa-row:last-child { border-bottom: none; }

.tarifa-info  { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.tarifa-tipo  { font-size: .68rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tarifa-nombre { font-size: .88rem; font-weight: 600; }

.tarifa-precio { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tarifa-input {
  width: 100px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  text-align: right;
  font-family: inherit;
  transition: all .2s;
}
.tarifa-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.tarifa-moneda { font-size: .85rem; color: var(--muted); font-weight: 700; }

/* ─── Select topbar ──────────────────────────────────────────────────────── */
.select-small {
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: .82rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.select-small option { color: var(--text); background: var(--surface); }

/* ─── Topbar usuario ─────────────────────────────────────────────────────── */
.topbar-user {
  font-size: .85rem;
  font-weight: 600;
  opacity: .9;
  padding: 4px 12px;
  background: rgba(255,255,255,.15);
  border-radius: 20px;
}

/* ─── Login form ─────────────────────────────────────────────────────────── */
.login-form { text-align: left; margin-top: 8px; }

.alert-error {
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: .88rem;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-error::before { content: '⚠️'; }

/* ─── Index footer ───────────────────────────────────────────────────────── */
.index-footer {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.link-panel {
  font-size: .85rem;
  color: var(--primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}
.link-panel:hover { text-decoration: underline; }

.link-logout {
  background: none;
  border: none;
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 5px;
}
.link-logout:hover { color: var(--danger); }

/* ─── Form actions ───────────────────────────────────────────────────────── */
.form-actions { display: flex; flex-direction: column; gap: 8px; }

/* ─── Utilidades ─────────────────────────────────────────────────────────── */
.hidden     { display: none !important; }
.mb-8       { margin-bottom: 8px; }
.mb-16      { margin-bottom: 16px; }
.mt-16      { margin-top: 16px; }
.text-muted { color: var(--muted); font-size: .88rem; }
.empty-msg  {
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
  padding: 40px 20px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1.5px dashed var(--border);
}

/* ─── Scrollbar personalizada ────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-light); }

/* ══════════════════════════════════════════════════════════════════════════
   DISEÑO MEJORADO — Stats, chips, grid, rich cards
   ══════════════════════════════════════════════════════════════════════════ */

/* ─── Stats strip ────────────────────────────────────────────────────────── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  border-radius: 2px 0 0 2px;
}
.sc-total::after   { background: linear-gradient(180deg, var(--primary), var(--purple)); }
.sc-warning::after { background: var(--warning); }
.sc-blue::after    { background: var(--primary); }
.sc-success::after { background: var(--success); }
.sc-danger::after  { background: var(--danger); }
.sc-purple::after  { background: var(--purple); }

.stat-icon  { font-size: 1.5rem; line-height: 1; margin-bottom: 10px; }
.stat-value {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.04em;
  color: var(--text);
}
.stat-label {
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 5px;
}

/* ─── Chips de atributos ─────────────────────────────────────────────────── */
.ref-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}
.chip {
  font-size: .67rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
  letter-spacing: .02em;
}
.chip-blue   { background: #dbeafe; color: #1e40af; }
.chip-purple { background: #ede9fe; color: #5b21b6; }
.chip-green  { background: #dcfce7; color: #166534; }
.chip-gray   { background: #f1f5f9; color: #475569; }
.chip-orange { background: #fef3c7; color: #92400e; }
.chip-red    { background: #fee2e2; color: #991b1b; }

/* ─── Ref-item mejorado ──────────────────────────────────────────────────── */
.ref-item {
  border-left: 4px solid var(--primary);
}
.ref-item:hover {
  border-left-color: var(--purple);
  transform: translateX(3px);
}

/* ─── Items en grid 2 columnas ───────────────────────────────────────────── */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}
.items-grid .ref-item { margin-bottom: 0; }

/* ─── Tab header con fondo degradado ─────────────────────────────────────── */
.tab-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #2563eb 100%);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(37,99,235,.2);
}
.tab-banner-left h2 {
  font-size: 1.3rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -.02em;
}
.tab-banner-left p {
  font-size: .82rem;
  color: rgba(255,255,255,.65);
  margin-top: 3px;
}
.tab-banner-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ─── Tarjetas de cliente ────────────────────────────────────────────────── */
#lista-clientes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 20px 24px;
}

.cliente-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--purple);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow .2s, border-color .2s;
  overflow: hidden;
}
.cliente-card:hover {
  border-left-color: var(--primary);
  box-shadow: var(--shadow);
}

.cliente-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
}
.cliente-card-id-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.cliente-num {
  font-size: .72rem;
  font-weight: 800;
  color: var(--purple);
  background: var(--purple-light);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.cliente-nombre {
  font-size: .98rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
  line-height: 1.3;
}
.cliente-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cliente-dato {
  font-size: .8rem;
  color: var(--muted);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cliente-dato:hover { white-space: normal; word-break: break-word; }
.cliente-email { color: var(--primary); }
.cliente-card-foot { padding-top: 4px; border-top: 1px solid var(--border); margin-top: 2px; }
.cliente-card .ref-actions { display: flex; gap: 4px; flex-shrink: 0; }
.cliente-card .btn-sm { padding: 4px 8px; font-size: .75rem; white-space: nowrap; }

/* ─── Mejor estado de cliente en lista (legacy) ──────────────────────────── */
.ref-num-cliente {
  font-size: .72rem;
  font-weight: 800;
  color: var(--purple);
  background: var(--purple-light);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
}

/* ─── Separador entre grupos ─────────────────────────────────────────────── */
.list-total {
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: 12px;
  font-style: italic;
}

/* ─── Pedido card más visual ─────────────────────────────────────────────── */
.pedido-card {
  border-left: 5px solid var(--warning);
}
.pedido-card:has(.estado-dot-pendiente) { border-left-color: var(--warning); }
.pedido-card:has(.estado-dot-en_proceso) { border-left-color: var(--primary); }
.pedido-card:has(.estado-dot-completado) { border-left-color: var(--success); }

/* ─── Buscador de producto en línea ─────────────────────────────────────── */
.producto-search-wrap { position: relative; }
.producto-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
}
.producto-option {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.producto-option:last-child { border-bottom: none; }
.producto-option:hover { background: #eff6ff; }
.opt-codigo {
  font-size: .75rem;
  font-weight: 800;
  color: var(--primary);
  font-family: monospace;
  white-space: nowrap;
  min-width: 70px;
}
.opt-nombre {
  font-size: .84rem;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Preview del producto seleccionado ─────────────────────────────────── */
.producto-preview-card {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1.5px solid #7dd3fc;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.snapshot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.snapshot-field {
  background: rgba(255,255,255,.75);
  border-radius: 8px;
  padding: 7px 12px;
}
.snapshot-field-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 700;
}
.snapshot-field-value {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
  word-break: break-all;
}

/* ─── Info de producto en vista operario ─────────────────────────────────── */
.linea-producto-info {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1.5px solid #7dd3fc;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.linea-producto-info h4 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #0369a1;
  font-weight: 800;
  margin-bottom: 10px;
}

/* ─── Checklist de validación (operario) ────────────────────────────────── */
.validacion-checklist {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 14px;
}
.validacion-checklist h4 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text);
  font-weight: 800;
  margin-bottom: 4px;
}
.val-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 8px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  user-select: none;
}
.val-item:hover { border-color: var(--primary); background: #eff6ff; }
.val-item.val-done { border-color: var(--success); background: #f0fdf4; }
.val-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  color: var(--success);
  flex-shrink: 0;
  transition: all .2s;
  background: #fff;
}
.val-item.val-done .val-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.val-label {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.val-item.val-done .val-label {
  text-decoration: line-through;
  color: var(--muted);
}

/* ─── Bloque unificado datos + verificación (operario) ───────────────────── */
.op-inner-box {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  overflow: hidden;
}
.op-inner-divider {
  height: 1px;
  background: var(--border);
}
.op-attr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
}
.op-attr-pair {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  padding: 10px 14px 11px;
}
.op-attr-pair:last-child { border-right: none; }
.op-attr-pair.op-attr-wide { /* igual que el resto */ }
.op-attr-lbl {
  font-size: .63rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 4px;
  white-space: nowrap;
}
.op-attr-val {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-2);
  word-break: break-word;
}
.op-attr-highlight { color: var(--primary); font-weight: 800; }
.op-attr-tapa      { color: var(--purple);  font-weight: 700; }
.op-attr-caja      { color: var(--success); font-weight: 700; }
.op-attr-empty     { color: var(--muted-light); font-weight: 400; }

/* Chip de verificación inline (dentro de la celda del atributo) */
.val-inline-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
  transition: all .15s;
  white-space: nowrap;
}
.val-inline-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.val-inline-chip.val-chip-done { border-color: var(--success); background: var(--success-light); color: var(--success); }

/* ─── Verificación chips ─────────────────────────────────────────────────── */
.val-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.val-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 24px;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
  transition: all .15s;
  user-select: none;
}
.val-chip:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.val-chip-done  { border-color: var(--success); background: var(--success-light); color: var(--success); }
.val-chip-check {
  font-weight: 800;
  font-size: .9rem;
  color: inherit;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-layout,
  .tab-content.active { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 320px; }
  .role-cards { grid-template-columns: 1fr; }
  .login-container { margin: 20px; padding: 36px 24px; }
  .tab-content.active { height: auto; }
  .tabs-nav { padding: 0 12px; }
  .tab-btn  { padding: 0 12px; font-size: .8rem; }
}
