/* ══════════════════════════════════════════════════════════════════════
   SAGA Nómina — Design System
   ══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Variables ─────────────────────────────────────────────────────── */
:root {
  /* Navy palette */
  --c0:  #040D20;
  --c1:  #071530;
  --c2:  #0D2248;
  --c3:  #142E62;
  --c4:  #0E44CC;
  --c5:  #1558F0;
  --c6:  #3A75FF;
  --c7:  #7AABFF;
  --c8:  #BFCFFF;
  --c9:  #E0EAFF;
  --c10: #F0F5FF;
  --cyan: #00C8FF;

  /* Semantic */
  --bg:      #F0F5FF;
  --surface: #fff;
  --border:  #D4E0F8;
  --text:    #0A1628;
  --muted:   #6B82A8;
  --light:   #99B0CC;
  --danger:  #DC2626;
  --success: #059669;

  /* Backward-compat aliases used in JS-generated HTML */
  --primary:      #1558F0;
  --primary-dark: #040D20;
  --accent:       #DDA853;
  --card:         #fff;

  /* Layout */
  --sw: 240px;
  --hh: 60px;
  --r:  10px;
  --r-lg: 14px;

  /* Shadows */
  --sh-sm:  0 1px 4px rgba(8,40,120,.07);
  --sh-md:  0 4px 20px rgba(8,40,120,.09);
  --sh-btn: 0 4px 14px rgba(21,88,240,.35);
}

/* ── Base ───────────────────────────────────────────────────────────── */
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3, h4, .card-title {
  font-family: 'Outfit', system-ui, sans-serif;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--c7); border-radius: 3px; }

code {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 13px;
  background: var(--c10);
  color: var(--c4);
  padding: 2px 7px;
  border-radius: 5px;
}

/* ── ═══════════════════════════════════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════════════════════════════════ */

#view-login {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

@media (max-width: 850px) {
  #view-login {
    grid-template-columns: 1fr;
  }
}

/* Left: branding panel */
.login-left {
  background: linear-gradient(155deg, var(--c0) 0%, #071A3A 55%, #0D2552 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 32px 28px;
}

.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(58,117,255,.14) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.login-left::after {
  content: '';
  position: absolute;
  bottom: -80px; right: -80px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(21,88,240,.3) 0%, transparent 70%);
  pointer-events: none;
}

.login-logo-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-logo-img {
  height: 48px;
  width: auto;
  filter: invert(1);
  object-fit: contain;
}

.login-logo-label {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
  line-height: 1.2;
}

.login-brand-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 700; font-size: 18px; color: #fff;
}

.login-brand-sub { font-size: 12px; color: rgba(255,255,255,.45); }

.login-hero {
  position: relative;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 20px;
}

.login-hero h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px; font-weight: 800; color: #fff;
  line-height: 1.25; margin-bottom: 12px;
}

.login-hero p {
  color: rgba(255,255,255,.65);
  font-size: 14px; line-height: 1.6;
  margin-bottom: 20px;
}

.login-features { display: flex; flex-direction: column; gap: 10px; }

.login-feature {
  display: flex; align-items: center;
  gap: 10px; color: rgba(255,255,255,.75); font-size: 13px;
}

.login-feature::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  flex-shrink: 0;
}

.login-version {
  position: relative;
  font-size: 11px; color: rgba(255,255,255,.35); font-weight: 500;
  margin-top: 24px;
}

/* Right: form panel */
.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 40px 24px;
  min-height: 100vh;
}

.login-form-wrap { width: 100%; max-width: 380px; }

.login-form-wrap h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 28px; font-weight: 700; color: var(--text);
  margin-bottom: 6px;
}

.login-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 28px; }

/* Legacy login box — kept for graceful fallback */
.login-box {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--sh-md);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 380px;
}

.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo h1 { font-size: 2rem; font-weight: 800; color: var(--primary); }
.login-logo h1 span { color: var(--accent); }
.login-logo p { color: var(--muted); font-size: .875rem; margin-top: .25rem; }

/* ── Login: autocomplete de usuario ────────────────────────────── */
.ac-wrap { position: relative; }

.ac-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
  list-style: none;
}
.ac-list.hidden { display: none; }

.ac-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background .1s;
}
.ac-item:hover { background: var(--c10); }

.ac-item-user {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.ac-item-name {
  font-size: 12px;
  color: var(--muted);
}

/* ── Login: campo de contraseña con ojo ─────────────────────────── */
.input-pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-pass-wrap input { width: 100%; padding-right: 42px !important; }

.btn-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  transition: color .15s;
  line-height: 0;
}
.btn-eye:hover { color: var(--c5); }

/* ── ═══════════════════════════════════════════════════════════════════
   ADMIN LAYOUT (Sidebar + Header + Content)
   ═══════════════════════════════════════════════════════════════════ */

.admin-layout {
  display: flex;
  height: 100vh;
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  width: var(--sw);
  height: 100vh;
  position: sticky;
  top: 0;
  background: linear-gradient(170deg, var(--c0) 0%, var(--c1) 45%, var(--c2) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 22px 18px 18px;
  display: flex; align-items: center; gap: 11px;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--c5), var(--cyan));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800; font-size: 20px; color: #fff;
  flex-shrink: 0;
}

.sidebar-brand {
  font-family: 'Outfit', sans-serif;
  font-weight: 700; font-size: 16px; color: #fff; white-space: nowrap;
}

.sidebar-subbrand { font-size: 11px; color: rgba(255,255,255,.4); white-space: nowrap; }

.sidebar-qchip {
  margin: 0 12px 14px;
  padding: 8px 14px;
  background: rgba(0,200,255,.1);
  border-radius: 9px;
  border: 1px solid rgba(0,200,255,.2);
  display: none;
}

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

.qchip-label {
  font-size: 10px; color: rgba(0,200,255,.7);
  font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}

.qchip-nombre { font-size: 13px; color: #fff; font-weight: 600; margin-top: 2px; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 0 12px 8px;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow: hidden auto;
  padding: 4px 0;
}

/* Nav tabs inside sidebar become vertical links */
.nav-tabs {
  display: contents; /* collapses the wrapper, nav links flow directly */
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  margin: 2px 10px;
  border-radius: 9px;
  cursor: pointer;
  color: rgba(255,255,255,.5);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
  transition: all .15s ease;
  position: relative;
  background: transparent;
  border: none;
  width: calc(100% - 20px);
  text-align: left;
}

.nav-tab:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.85);
}

.nav-tab.active {
  background: rgba(21,88,240,.25);
  color: #fff;
}

.nav-tab.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%;
  height: 60%; width: 3px;
  background: var(--cyan);
  border-radius: 0 3px 3px 0;
}

.nav-tab svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-version {
  text-align: center;
  font-size: .68rem;
  color: rgba(255,255,255,.28);
  line-height: 1.5;
  padding: 0 8px 10px;
}

/* Logout button (dark sidebar context) */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  margin: 2px 10px;
  border-radius: 9px;
  background: transparent;
  color: rgba(255,255,255,.45);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px; font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
  width: calc(100% - 20px);
}

.btn-logout:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.8);
}

/* Logout button in admin header (always visible) */
.btn-logout-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-logout-header:hover {
  background: #FEF2F2;
  color: var(--danger);
  border-color: #FECACA;
}

/* En móvil ocultar el texto "Salir" para ahorrar espacio */
@media (max-width: 640px) {
  .btn-logout-header-txt { display: none; }
  .btn-logout-header { padding: 7px 9px; }
}

/* Admin main area */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.admin-header {
  height: var(--hh);
  background: #fff;
  border-bottom: 1px solid var(--c9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}

.admin-breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
}

.admin-bc-tab { color: var(--text); font-weight: 600; }

.admin-header-right { display: flex; align-items: center; gap: 14px; }

.admin-user-chip { display: flex; align-items: center; gap: 9px; }

.admin-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c5), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700; font-size: 14px; color: #fff;
}

.admin-user-name { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── ═══════════════════════════════════════════════════════════════════
   WORKER LAYOUT (Operario / Patinador)
   ═══════════════════════════════════════════════════════════════════ */

.worker-layout {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.worker-header {
  background: linear-gradient(135deg, var(--c0), var(--c2));
  padding: 0 24px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}

.worker-header-brand { display: flex; align-items: center; gap: 11px; }

.worker-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--c5), var(--cyan));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 800; font-size: 18px; color: #fff;
}

.worker-brand-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 700; font-size: 16px; color: #fff;
}

.worker-header-right { display: flex; align-items: center; gap: 12px; }

.worker-user-info { text-align: right; }

.worker-user-name { font-size: 14px; font-weight: 600; color: #fff; }

.worker-user-role { font-size: 11px; color: rgba(255,255,255,.45); }

.worker-user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c5), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-weight: 700; font-size: 16px; color: #fff;
}

.btn-logout-ghost {
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.6);
  border: 1px solid rgba(255,255,255,.15);
  padding: 7px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  display: flex; align-items: center;
}

.btn-logout-ghost:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}

.worker-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

/* ── ═══════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════════════ */

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
}

/* ── ═══════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════ */

.card {
  background: #fff;
  border-radius: var(--r-lg);
  border: 1px solid var(--c9);
  box-shadow: var(--sh-sm);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px; font-weight: 700; color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--c9);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.97); }

.btn-primary {
  background: var(--c5); color: #fff;
  box-shadow: var(--sh-btn);
}
.btn-primary:hover:not(:disabled) {
  background: var(--c6);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(21,88,240,.4);
}

.btn-accent {
  background: #DDA853; color: #fff;
  box-shadow: 0 4px 14px rgba(221,168,83,.3);
}
.btn-accent:hover:not(:disabled) { background: #c99040; transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; transform: translateY(-1px); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--c5);
  border: 1.5px solid var(--c8);
}
.btn-ghost:hover:not(:disabled) { background: var(--c10); border-color: var(--c6); }

.btn-full {
  width: 100%; justify-content: center;
  padding: 12px; font-size: 15px;
}

.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ── ═══════════════════════════════════════════════════════════════════
   FORMS & INPUTS
   ═══════════════════════════════════════════════════════════════════ */

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 6px;
}

/* Global input/select style (excludes checkboxes, file inputs, qty) */
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not(.qty),
select {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not(.qty):focus,
select:focus {
  border-color: var(--c6);
  box-shadow: 0 0 0 3px rgba(58,117,255,.12);
}

input::placeholder { color: var(--light); }

.flex-row {
  display: flex; align-items: center;
  gap: .75rem; flex-wrap: wrap;
}

/* Quantity input (operario panel) */
.qty {
  width: 90px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  text-align: right;
  outline: none;
  transition: border-color .15s;
  font-variant-numeric: tabular-nums;
  background: #fff;
  color: var(--text);
}

.qty:focus {
  border-color: var(--c6);
  box-shadow: 0 0 0 3px rgba(58,117,255,.12);
}

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

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
  background: var(--c2);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-family: 'Outfit', sans-serif;
  font-weight: 600; font-size: 12.5px;
  letter-spacing: .04em;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--c9);
  vertical-align: middle;
  color: var(--text);
}

tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: #F4F8FF; }

tfoot tr td {
  background: var(--c2);
  color: #fff;
  font-weight: 700;
  border-bottom: none;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px; font-weight: 600;
}

/* Existing names (used in JS-generated HTML) */
.badge-open    { background: #ECFDF5; color: #059669; }
.badge-closed  { background: #FEF2F2; color: #DC2626; }
.badge-admin   { background: #F5F3FF; color: #7C3AED; }
.badge-worker  { background: #EBF2FF; color: var(--c5); }
.badge-carrier { background: #E0F7FF; color: #0090CC; }

/* New names */
.badge-green  { background: #ECFDF5; color: #059669; }
.badge-red    { background: #FEF2F2; color: #DC2626; }
.badge-blue   { background: #EBF2FF; color: var(--c5); }
.badge-purple { background: #F5F3FF; color: #7C3AED; }
.badge-cyan   { background: #E0F7FF; color: #0090CC; }
.badge-gray   { background: #F0F2F5; color: #6B7280; }
.badge-amber  { background: #FFFBEB; color: #D97706; }

/* ── ═══════════════════════════════════════════════════════════════════
   PRODUCT ACCORDION
   ═══════════════════════════════════════════════════════════════════ */

.prod-item {
  border: 1.5px solid var(--c9);
  border-radius: var(--r);
  margin-bottom: 8px;
  overflow: hidden;
}

.prod-header {
  display: flex; align-items: center; gap: .75rem;
  padding: 11px 16px;
  background: var(--c10);
  cursor: pointer; user-select: none;
  transition: background .15s;
}

.prod-header:hover { background: var(--c9); }

.prod-arrow { color: var(--muted); font-size: .8rem; width: 1rem; flex-shrink: 0; }

.prod-nombre { font-weight: 600; color: var(--text); }

.prod-ops {
  padding: 14px 16px 16px;
  border-top: 1.5px solid var(--c9);
  background: #fff;
}

/* ── ═══════════════════════════════════════════════════════════════════
   ALERTS & ERRORS
   ═══════════════════════════════════════════════════════════════════ */

.login-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--danger);
  border-radius: var(--r);
  padding: 9px 13px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

/* ── ═══════════════════════════════════════════════════════════════════
   SPINNER
   ═══════════════════════════════════════════════════════════════════ */

.spinner {
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

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

/* ── ═══════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════ */

.hidden   { display: none !important; }

.text-muted { color: var(--muted); font-size: .875rem; }

.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }

/* ── ═══════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════ */

@keyframes fadeUp {
  from { transform: translateY(8px); opacity: .3; }
  to   { transform: translateY(0);   opacity: 1;  }
}

.fade-in { animation: fadeUp .18s ease both; }

/* ── ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */

/* Hamburger button — hidden on desktop */
.hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.hamburger-btn:hover { background: var(--c10); }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4,13,32,.55);
  z-index: 199;
}

/* ── Tablet ≤ 900px: icon-only sidebar ─────── */
@media (max-width: 900px) {
  #view-login { grid-template-columns: 1fr; }
  .login-left { display: none; }

  .sidebar { width: 62px; }
  .sidebar-brand, .sidebar-subbrand, .sidebar-qchip, .sidebar-logo-text { display: none; }
  .nav-tab span, .btn-logout span { display: none; }
  .nav-tab   { justify-content: center; padding: 10px; margin: 2px 6px; width: calc(100% - 12px); }
  .btn-logout { justify-content: center; padding: 10px; margin: 2px 6px; width: calc(100% - 12px); }
  .sidebar-header { padding: 18px 0 14px; justify-content: center; }
}

/* ── Mobile ≤ 768px: hidden sidebar + hamburger ── */
@media (max-width: 768px) {
  .hamburger-btn { display: flex !important; }

  .sidebar {
    position: fixed;
    left: calc(-1 * var(--sw) - 10px);
    z-index: 200;
    width: var(--sw) !important;
    transition: left .25s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.mob-open { left: 0; }
  .sidebar-overlay.mob-open { display: block; }

  /* Restore full labels inside the open drawer */
  .sidebar .sidebar-brand,
  .sidebar .sidebar-subbrand,
  .sidebar .sidebar-logo-text { display: block !important; }
  .sidebar .sidebar-qchip { display: none; }
  .sidebar .sidebar-qchip.visible { display: block !important; }
  .sidebar .nav-tab span,
  .sidebar .btn-logout span { display: inline !important; }
  .sidebar .nav-tab {
    justify-content: flex-start !important;
    padding: 10px 18px !important;
    margin: 2px 10px !important;
    width: calc(100% - 20px) !important;
  }
  .sidebar .btn-logout {
    justify-content: flex-start !important;
    padding: 10px 18px !important;
    margin: 2px 10px !important;
    width: calc(100% - 20px) !important;
  }
  .sidebar .sidebar-header {
    padding: 22px 18px 18px !important;
    justify-content: flex-start !important;
  }

  .admin-header { padding: 0 14px; }
  .main-content { padding: 14px 16px; }
}

/* ── Small mobile ≤ 640px: operario form & tables ── */
@media (max-width: 640px) {
  /* Worker header */
  .worker-header { padding: 0 14px; height: 56px; }
  .worker-user-info { display: none; }
  .worker-content { padding: 12px; }

  /* Cards */
  .card { padding: 14px; margin-bottom: 12px; overflow-x: auto; }
  .card-title { font-size: 15px; margin-bottom: 10px; padding-bottom: 8px; }

  /* Form rows: stack vertically */
  .flex-row {
    flex-direction: column;
    align-items: stretch;
  }
  .flex-row > .form-group {
    width: 100% !important;
    padding-top: 0 !important;
    margin-bottom: 10px;
  }
  .flex-row > .form-group select,
  .flex-row > .form-group input {
    width: 100%;
  }
  .flex-row > .form-group .btn {
    width: 100%;
    justify-content: center;
    padding: 13px;
    font-size: 15px;
    min-height: 48px;
  }

  /* Allow table scrolling inside product accordion */
  .prod-item { overflow: visible; }
  .prod-ops  { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Bigger touch targets */
  .btn-sm { padding: 9px 14px; font-size: 13px; min-height: 38px; }

  /* Login */
  .login-right { padding: 28px 16px; }
  .login-form-wrap h2 { font-size: 24px; }
  input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):not(.qty),
  select { padding: 11px 13px; font-size: 15px; }
  .btn-full { padding: 13px; font-size: 15px; }
}

/* ── Toggle switch ─────────────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 34px;
  transition: background .2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.toggle-switch input:checked + .toggle-slider { background: #16a34a; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-switch:hover .toggle-slider { filter: brightness(.95); }

/* ── Toast notifications ───────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(4,13,32,.18);
  pointer-events: auto;
  animation: toast-in .25s cubic-bezier(.34,1.56,.64,1) forwards;
}

.toast.toast-success {
  background: #166534;
  color: #dcfce7;
  border: 1px solid #15803d;
}

.toast.toast-out {
  animation: toast-out .2s ease-in forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0)    scale(1);   }
  to   { opacity: 0; transform: translateY(10px) scale(.95); }
}

/* ── Banner quincena activa (panel operario) ─────────────────────────────── */

.qbanner {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(130deg, var(--c2) 0%, var(--c3) 100%);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin-bottom: 18px;
  box-shadow: 0 4px 18px rgba(14,68,204,.22);
  position: relative;
  overflow: hidden;
}

.qbanner::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  pointer-events: none;
}

.qbanner-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 52px; height: 52px;
  background: rgba(255,255,255,.12);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}

.qbanner-body { flex: 1; min-width: 0; }

.qbanner-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.55);
  margin-bottom: 3px;
}

.qbanner-nombre {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.qbanner-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.qbanner-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: .78rem;
  font-weight: 500;
  color: rgba(255,255,255,.9);
  font-variant-numeric: tabular-nums;
}

.qbanner-today {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  font-weight: 500;
  color: rgba(255,255,255,.6);
}

/* ── Tablas detalle liquidación ──────────────────────────────────────────── */

/* Reemplaza el header azul marino pesado por uno suave y legible */
.liq-detail-table th {
  background: #EEF3FF;
  color: var(--c3);
  border-bottom: 2px solid #C8D8FF;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 9px 14px;
}

/* Wrapper de tabla: borde suave, sin sombra extra */
.liq-table-wrap {
  border: 1.5px solid var(--c9);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 0;
}

/* ── Tabla acumulado quincena (panel operario) ───────────────────────────── */

.acum-table { border-radius: 10px; overflow: hidden; border: 1px solid var(--c9); }

/* Encabezado de producto: franja suave con acento lateral */
.acum-prod-header td {
  background: #EEF3FF;
  color: var(--c3);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .02em;
  padding: .55rem 1rem .55rem .85rem;
  border-left: 4px solid var(--c5);
  border-bottom: 1px solid var(--c8);
}

/* Desactiva hover genérico en filas especiales */
.acum-prod-header:hover td,
.acum-subtotal:hover td,
.acum-total:hover td {
  background: inherit;
}

/* Filas de operación */
.acum-op-row td {
  padding-left: 1.6rem;
  color: var(--text);
}

.acum-op-row td:first-child {
  color: var(--text);
  font-size: .93rem;
}

/* Subtotales por producto */
.acum-subtotal td {
  background: #F5F7FB;
  color: var(--c3);
  font-weight: 600;
  font-style: italic;
  padding-left: 1.6rem;
  border-top: 1px dashed var(--c8);
  border-bottom: 2px solid var(--c9);
}

/* Fila total final */
.acum-total td {
  background: var(--c2);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  border-bottom: none;
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 700px) {
  .dash-grid-2 { grid-template-columns: 1fr; }
}
.dash-kpi-row {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.dash-kpi-card {
  flex: 1;
  min-width: 150px;
  background: #fff;
  border: 1px solid var(--c8);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 18px 16px 14px;
  text-align: center;
}
.dash-kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.1;
}
.dash-kpi-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 5px;
}
.dash-kpi-icon {
  margin-bottom: 8px;
  opacity: .8;
}
.dash-progress-bar {
  height: 8px;
  background: var(--c9);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
}
.dash-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .45s ease;
}

/* ── Liquidación responsive ──────────────────────────────────────────────────── */

/* En tablets y móviles reducimos el min-width de la tabla de liquidación */
@media (max-width: 900px) {
  /* La tabla principal de liquidación */
  #liq-content table { min-width: 700px !important; }
}

@media (max-width: 768px) {
  /* Reducir padding de celdas */
  #liq-content th,
  #liq-content td { padding: 8px 8px; font-size: 13px; }

  /* Input de valor pagado más angosto */
  #liq-content input[type="text"] { width: 90px !important; font-size: .78rem !important; }

  /* Ocultar columna "Saldo Ant." (4ta col) en móvil — menos relevante */
  #liq-content table thead tr th:nth-child(4),
  #liq-content table tbody tr td:nth-child(4),
  #liq-content table tfoot tr td:nth-child(4) { display: none; }

  /* Reducir min-width de la tabla */
  #liq-content table { min-width: 580px !important; }
}

@media (max-width: 640px) {
  /* Ocultar también columna "Estado" (7ma después de ocultar la 4ta queda en pos 7) */
  #liq-content table thead tr th:nth-child(8),
  #liq-content table tbody tr td:nth-child(8),
  #liq-content table tfoot tr td:nth-child(8) { display: none; }

  /* Reducir aún más */
  #liq-content table { min-width: 480px !important; }

  /* Texto de botón "Ver detalle" → solo icono en móvil */
  #liq-content .btn-detalle-txt { display: none; }

  /* Encabezados más cortos usando atributo data */
  #liq-content th { font-size: 11px; padding: 7px 6px; letter-spacing: 0; }
  #liq-content td { padding: 7px 6px; font-size: 12px; }

  /* Input pago aún más angosto */
  #liq-content input[type="text"] { width: 72px !important; padding: 4px 5px !important; }

  /* Toggle switch más pequeño */
  #liq-content .toggle-switch { width: 38px; height: 22px; }
  #liq-content .toggle-slider::before { width: 16px; height: 16px; }
  #liq-content .toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
}

/* Asegura que el wrapper de liq-content no desborde el card */
#liq-content { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#liq-content > div { min-width: 0; }

/* ── ═══════════════════════════════════════════════════════════════════
   PRODUCT CHIP TOGGLES (quincena product selector)
   ═══════════════════════════════════════════════════════════════════ */

.prod-chip-group {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
  margin-top: .6rem;
}

.prod-chip {
  display: inline-flex;
}

.prod-chip input[type="checkbox"] {
  display: none;
}

.prod-chip label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .85rem;
  border-radius: 2rem;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .13s, color .13s, border-color .13s, box-shadow .13s;
  user-select: none;
  line-height: 1.5;
  white-space: nowrap;
}

.prod-chip label::before {
  content: '';
  display: inline-block;
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  transition: background .13s, border-color .13s;
  flex-shrink: 0;
}

.prod-chip label:hover {
  border-color: var(--c6);
  color: var(--c4);
  background: var(--c10);
}

.prod-chip label:hover::before {
  border-color: var(--c6);
}

.prod-chip input[type="checkbox"]:checked + label {
  background: var(--c5);
  border-color: var(--c5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(21,88,240,.22);
}

.prod-chip input[type="checkbox"]:checked + label::before {
  content: '✓';
  background: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.5);
  color: #fff;
  font-size: .55rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.prod-chip-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-top: .55rem;
}

.prod-chip-actions a {
  font-size: .75rem;
  color: var(--c5);
  text-decoration: none;
  padding: .2rem .55rem;
  border-radius: .35rem;
  border: 1px solid transparent;
  transition: background .1s, border-color .1s;
  font-weight: 500;
}

.prod-chip-actions a:hover {
  background: var(--c10);
  border-color: var(--border);
  text-decoration: none;
}

.prod-chip-actions .sep {
  color: var(--border);
  font-size: .7rem;
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE REFINEMENTS  (solo móvil — no afecta escritorio)
   ══════════════════════════════════════════════════════════════════════ */

/* ── 1. Scroll horizontal en todas las cards desde tablet ───────────── */
@media (max-width: 900px) {
  .card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── 2. Mobile ≤ 768px ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Padding más compacto en contenido principal */
  .main-content { padding: 10px 12px; }
  .card { padding: 14px; }

  /* Liquidación: grid de 3 columnas → columna única */
  #liq-content [style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    gap: .75rem !important;
  }

  /* Liquidación: reducir padding interior del detalle expandido */
  #liq-content .fade-in > div:first-child {
    padding: .75rem 0 !important;
  }

  /* Forzar que .flex-row se estire aunque haya align-items inline */
  .flex-row { align-items: stretch !important; }

  /* Filtros de registros: cada campo ocupa 100% */
  #reg-filters-ops .form-group {
    min-width: unset !important;
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  #reg-filters-ops input {
    width: 100% !important;
    min-width: unset !important;
  }

  /* Panel "Agregar registro" y "Agregar horas": campos al 100% */
  #panel-add-reg .form-group,
  #panel-add-hora .form-group {
    min-width: unset !important;
    width: 100% !important;
    flex: 1 1 100% !important;
  }
  #panel-add-reg input,  #panel-add-reg select,
  #panel-add-hora input, #panel-add-hora select {
    width: 100% !important;
    min-width: unset !important;
  }
  #panel-add-reg .btn-success,
  #panel-add-hora .btn-success {
    width: 100% !important;
    justify-content: center;
  }

  /* Quincenas + tabs selector row: apilado */
  #reg-q-select { width: 100%; }
}

/* ── 3. Small mobile ≤ 640px ────────────────────────────────────────── */
@media (max-width: 640px) {
  /* KPI dashboard: 2 por fila */
  .dash-kpi-card {
    min-width: calc(50% - 8px) !important;
    flex: 0 0 calc(50% - 8px) !important;
    padding: 14px 10px 10px !important;
  }
  .dash-kpi-value { font-size: 1.2rem !important; }

  /* Gráficas dashboard: limitar alto en móvil */
  .dash-grid-2 canvas { max-height: 200px; }

  /* Tabla acumulado del operario: scroll propio */
  .acum-table {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
  }

  /* Botones de tab "Operaciones / Horas": ocupan su fila */
  #reg-tab-ops, #reg-tab-horas { flex: 1; justify-content: center; }

  /* Input de tiempo en panel horas: no colapsar demasiado */
  #panel-add-hora input[type="time"] { min-width: 90px; }

  /* Selector de quincena + botones de exportar: wrap */
  #liq-content + div,
  .card > .flex-row { row-gap: .5rem; }
}

/* ── 4. Teléfono muy pequeño ≤ 420px ────────────────────────────────── */
@media (max-width: 420px) {
  .main-content { padding: 8px; }
  .card { padding: 10px; margin-bottom: 8px; }

  /* Ocultar nombre de usuario en header para ahorrar espacio */
  .admin-user-name { display: none; }

  /* Breadcrumb más compacto */
  .admin-breadcrumb { font-size: 12px; gap: 5px; }

  /* Filas título + botón acción: permitir wrap */
  .card [style*="space-between"] {
    flex-wrap: wrap !important;
    row-gap: .4rem;
  }

  /* Botones de acción en tablas: tamaño mínimo táctil */
  .btn-sm { min-height: 34px; padding: 6px 10px; font-size: 12px; }

  /* KPI: reducir fuente de label */
  .dash-kpi-label { font-size: .65rem; }

  /* Liq: ocultar col "Valor Pagado" para ahorrar ancho */
  #liq-content th:nth-child(7),
  #liq-content td:nth-child(7) { display: none; }
}
