/* ============================================================
   Audit · Xmartlan — Inventory Audit System
   Profesional WMS look. Dense tables, big touch targets on form.
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --surface-sunk: #ecebe5;
  --border: #e0ddd3;
  --border-strong: #c9c5b8;
  --ink: #16160e;
  --ink-2: #3a3a30;
  --muted: #76746a;
  --muted-2: #9a988d;

  --primary: #1a1a14;
  --primary-ink: #fafaf5;

  --accent: #2d8781;
  --accent-ink: #ffffff;
  --accent-soft: #d4edec;

  --success: #729a6a;
  --success-soft: #d8efe1;
  --danger: #9c6d6d;
  --danger-soft: #f6d9d4;
  --warn: #a29c5d;
  --warn-soft: #ffe6b8;
  --info: #6796b4;
  --info-soft: #d9e4f4;

  --r-sm: 4px;
  --r-md: 7px;
  --r-lg: 12px;

  --shadow-sm: 0 1px 0 rgba(20,20,15,0.04), 0 1px 2px rgba(20,20,15,0.04);
  --shadow-md: 0 4px 14px -6px rgba(20,20,15,0.18), 0 2px 4px rgba(20,20,15,0.06);
  --shadow-lg: 0 22px 60px -20px rgba(20,20,15,0.28), 0 8px 20px -8px rgba(20,20,15,0.12);

  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: var(--sans);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14140e;
  --surface: #1d1d16;
  --surface-2: #232319;
  --surface-sunk: #0e0e08;
  --border: #2e2e23;
  --border-strong: #45453a;
  --ink: #f5f3eb;
  --ink-2: #d0cec3;
  --muted: #8e8c81;
  --muted-2: #6a685f;
  --primary: #f5f3eb;
  --primary-ink: #14140e;
  --accent-soft: #0d302f;
  --success-soft: #1b3a28;
  --danger-soft: #3d1c1c;
  --warn-soft: #3d2a00;
  --info-soft: #1b2c4a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1, "zero" 1; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================
   Layout
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background-color: #07090e;
  background-image:
    radial-gradient(circle 1.2px at 12% 7%,  rgba(255,255,255,0.90) 0%, transparent 1.2px),
    radial-gradient(circle 0.8px at 70% 13%, rgba(255,255,255,0.65) 0%, transparent 0.8px),
    radial-gradient(circle 1px   at 38% 23%, rgba(190,230,255,0.80) 0%, transparent 1px),
    radial-gradient(circle 0.8px at 83% 31%, rgba(255,255,255,0.55) 0%, transparent 0.8px),
    radial-gradient(circle 1.3px at 22% 42%, rgba(255,255,255,0.85) 0%, transparent 1.3px),
    radial-gradient(circle 0.7px at 56% 51%, rgba(255,255,255,0.45) 0%, transparent 0.7px),
    radial-gradient(circle 1px   at 76% 62%, rgba(190,230,255,0.70) 0%, transparent 1px),
    radial-gradient(circle 0.8px at 17% 71%, rgba(255,255,255,0.60) 0%, transparent 0.8px),
    radial-gradient(circle 1.3px at 92% 78%, rgba(255,255,255,0.80) 0%, transparent 1.3px),
    radial-gradient(circle 0.7px at 45% 86%, rgba(255,255,255,0.50) 0%, transparent 0.7px),
    radial-gradient(circle 1px   at 63% 94%, rgba(190,230,255,0.65) 0%, transparent 1px),
    radial-gradient(circle 0.8px at  7% 55%, rgba(255,255,255,0.55) 0%, transparent 0.8px),
    radial-gradient(circle 1px   at 94% 47%, rgba(255,255,255,0.70) 0%, transparent 1px),
    radial-gradient(circle 0.7px at 33% 65%, rgba(255,255,255,0.45) 0%, transparent 0.7px),
    radial-gradient(circle 1.2px at 78% 89%, rgba(190,230,255,0.80) 0%, transparent 1.2px),
    radial-gradient(circle 0.8px at 50% 77%, rgba(255,255,255,0.60) 0%, transparent 0.8px),
    radial-gradient(circle 0.7px at 15% 34%, rgba(255,255,255,0.50) 0%, transparent 0.7px),
    radial-gradient(circle 1px   at 87% 20%, rgba(255,255,255,0.75) 0%, transparent 1px),
    radial-gradient(circle 1.5px at 44% 5%,  rgba(200,240,255,0.90) 0%, transparent 1.5px),
    radial-gradient(circle 0.7px at 62% 38%, rgba(255,255,255,0.40) 0%, transparent 0.7px);
  color: #d8d6cc;
  border-right: 1px solid rgba(58,147,143,0.18);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

/* ── Aurora principal: blob teal grande que deriva hacia arriba ── */
.sidebar::before {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(58,147,143,0.60) 0%,
    rgba(58,147,143,0.22) 40%,
    transparent 70%
  );
  bottom: -80px;
  left: -90px;
  pointer-events: none;
  z-index: 0;
  filter: blur(52px);
  animation: aurora-main 11s ease-in-out infinite alternate;
}

/* ── Aurora secundaria: blob azul-índigo que deriva desde arriba ── */
.sidebar::after {
  content: '';
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(18,85,170,0.50) 0%,
    rgba(30,110,180,0.18) 40%,
    transparent 70%
  );
  top: 20px;
  right: -70px;
  pointer-events: none;
  z-index: 0;
  filter: blur(44px);
  animation: aurora-secondary 14s ease-in-out infinite alternate;
}

@keyframes aurora-main {
  0%   { transform: translate(  0px,   0px) scale(1.00); opacity: 0.70; }
  35%  { transform: translate( 65px, -100px) scale(1.28); opacity: 1.00; }
  70%  { transform: translate( 25px, -190px) scale(1.05); opacity: 0.82; }
  100% { transform: translate( 85px, -120px) scale(1.18); opacity: 0.92; }
}

@keyframes aurora-secondary {
  0%   { transform: translate(  0px,   0px) scale(1.00); opacity: 0.55; }
  40%  { transform: translate(-55px, 130px) scale(1.22); opacity: 0.85; }
  100% { transform: translate(-25px,  85px) scale(0.88); opacity: 0.65; }
}

.sidebar-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(58,147,143,0.18);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-ink);
  letter-spacing: -0.04em;
}
.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: #fff;
}
.brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.48);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.nav {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(58,147,143,0.25) transparent;
  position: relative;
  z-index: 1;
}
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: rgba(58,147,143,0.28); border-radius: 2px; }
.nav-section-btn {
  font-size: 10px;
  color: rgba(255,255,255,0.36);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 14px 10px 6px;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color 0.12s;
}
.nav-section-btn:hover { color: rgba(255,255,255,0.62); }

/* ── Animated section collapse ──────────────────────────── */
.nav-section-items {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.2s ease;
}
.nav-section-items.closed {
  grid-template-rows: 0fr;
}
.nav-section-items-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1px;
  opacity: 1;
  transition: opacity 0.15s ease;
}
.nav-section-items.closed .nav-section-items-inner {
  opacity: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 5px;
  color: rgba(255,255,255,0.72);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.06s ease, color 0.06s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: rgba(58,147,143,0.15);
  color: #fff;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .ico { opacity: 1; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  color: rgba(255,255,255,0.38);
}
.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(58,147,143,0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  position: relative;
  z-index: 1;
}
.user-chip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a938f, #2e7874);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  color: #ffffff;
}
.user-name { color: rgba(255,255,255,0.92); font-weight: 500; }
.user-role { color: rgba(255,255,255,0.44); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.user-chip-btn {
  background: none; border: none; padding: 0; cursor: pointer; flex-shrink: 0;
  border-radius: 50%; display: block;
}
.user-chip-btn:hover .user-chip { opacity: 0.85; }

.sidebar-foot { position: relative; }
.sidebar-user-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 8px;
  right: 8px;
  background: #0c1416;
  border: 1px solid rgba(58,147,143,0.22);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.6), 0 0 0 1px rgba(58,147,143,0.08) inset;
  z-index: 200;
}
.sidebar-user-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px;
  background: none; border: none; border-radius: 5px;
  color: rgba(255,255,255,0.75); font-size: 13px; cursor: pointer;
  text-align: left; transition: background 0.1s, color 0.1s;
}
.sidebar-user-menu-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-user-menu-item.danger { color: #f87171; }
.sidebar-user-menu-item.danger:hover { background: rgba(239,68,68,0.12); color: #fca5a5; }
.sidebar-user-menu-sep { height: 1px; background: rgba(255,255,255,0.07); margin: 3px 0; }

/* ── Module Dock ─────────────────────────────────────────── */
.module-dock {
  padding: 7px 10px;
  border-top: 1px solid rgba(58,147,143,0.15);
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}
.module-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: rgba(255,255,255,0.38);
  padding: 6px 7px;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}
.module-btn:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.68); }
.module-btn.active { flex: 1; }
.module-btn.active[data-m="cube"]          { background: rgba(111,150,173,0.14); }
.module-btn.active[data-m="cube"]:hover    { background: rgba(111,150,173,0.22); }
.module-btn.active[data-m="deal"]          { background: rgba(244,114,101,0.14); }
.module-btn.active[data-m="deal"]:hover    { background: rgba(244,114,101,0.22); }
.module-btn.active[data-m="bill"]          { background: rgba(123,157,114,0.14); }
.module-btn.active[data-m="bill"]:hover    { background: rgba(123,157,114,0.22); }
.module-btn.active[data-m="dash"]          { background: rgba(130,131,128,0.14); }
.module-btn.active[data-m="dash"]:hover    { background: rgba(130,131,128,0.22); }
.module-btn .ico { width: 15px; height: 15px; flex-shrink: 0; }
.module-label {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Collapsed: vertical stack */
.sidebar.collapsed .module-dock {
  flex-direction: column;
  padding: 6px;
  align-items: center;
  gap: 2px;
}
.sidebar.collapsed .module-btn {
  flex: none;
  width: 34px;
  height: 30px;
  justify-content: center;
  padding: 0;
}
.sidebar.collapsed .module-btn.active { flex: none; }

/* Mobile reset */
@media (max-width: 840px) {
  .sidebar.collapsed .module-dock { flex-direction: row; padding: 7px 10px; align-items: center; gap: 4px; }
  .sidebar.collapsed .module-btn { flex: none; width: auto; height: auto; padding: 6px 7px; justify-content: flex-start; }
  .sidebar.collapsed .module-btn.active { flex: 1; }
}

/* ── Sidebar colapsable ─────────────────────────────────── */
.app { transition: grid-template-columns 0.22s ease; }
.app.sidebar-collapsed { grid-template-columns: 52px 1fr; }

.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.38);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.88); }
.sidebar-toggle .ico { width: 13px; height: 13px; }

/* Brand en collapsed */
.sidebar.collapsed .sidebar-brand {
  flex-direction: column;
  padding: 14px 0 10px;
  gap: 6px;
  align-items: center;
}

/* Nav en collapsed */
.sidebar.collapsed .nav { padding: 8px 6px; }
.sidebar.collapsed .nav-section-btn { display: none; }
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
}
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-item .count { display: none; }
.sidebar.collapsed .nav-item.active::before { display: none; }
.sidebar.collapsed .nav-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Footer en collapsed */
.sidebar.collapsed .sidebar-foot {
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 8px 0 12px;
}

/* En móvil no aplica el modo collapsed */
@media (max-width: 840px) {
  .app.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar.collapsed .sidebar-brand { flex-direction: row; padding: 18px 18px 14px; gap: 10px; align-items: center; }
  .sidebar.collapsed .nav { padding: 14px 10px; }
  .sidebar.collapsed .nav-section-btn { display: flex; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 8px 10px; gap: 10px; }
  .sidebar.collapsed .nav-item span { display: inline; }
  .sidebar.collapsed .nav-item .count { display: inline; }
  .sidebar.collapsed .nav-item.active::before { display: block; }
  .sidebar.collapsed .nav-item.active { box-shadow: none; }
  .sidebar.collapsed .sidebar-foot { flex-direction: row; gap: 10px; align-items: center; padding: 12px; }
}

/* ============================================================
   Main area
   ============================================================ */
.main {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.crumb {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.crumb .sep { color: var(--muted-2); }
.crumb .now { color: var(--ink); font-weight: 600; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.db-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  padding: 4px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.db-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.db-dot.saving { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.page {
  padding: 24px;
  max-width: 1440px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 4px;
}
.page-sub { color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.05s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  border-color: var(--primary);
}
.btn-primary:hover { background: #000; border-color: #000; }

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-accent:hover { background: #2e7874; border-color: #2e7874; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border); }

.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-xl { height: 52px; padding: 0 22px; font-size: 15px; font-weight: 600; }

.btn-icon {
  width: 30px;
  padding: 0;
  display: grid;
  place-items: center;
}
.btn .ico { width: 15px; height: 15px; }

/* ============================================================
   Inputs / Fields
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.field-label .hint { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: 11px; }

.input {
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
.input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(20,20,14,0.08);
}
.input::placeholder { color: var(--muted-2); }
.input.input-lg { height: 44px; font-size: 16px; }
.input.input-mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }

/* Select: reset apariencia nativa para que el background de .input se aplique
   correctamente en todos los navegadores (Safari / Chrome macOS) */
select.input {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
[data-theme="dark"] select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

textarea.input {
  height: auto;
  padding: 10px 12px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
}

/* Number input - big tactile */
.num-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
.num-input:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(20,20,14,0.08);
}
.num-input button {
  width: 38px;
  border: none;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border-right: 1px solid var(--border);
}
.num-input button:last-child { border-right: none; border-left: 1px solid var(--border); }
.num-input button:hover { background: var(--surface-sunk); }
.num-input button:active { background: var(--border); }
.num-input input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  text-align: center;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  font-feature-settings: "tnum" 1;
  min-width: 0;
  -moz-appearance: textfield;
}
.num-input input::-webkit-outer-spin-button,
.num-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input.lg { }
.num-input.lg input { height: 56px; font-size: 26px; }
.num-input.lg button { width: 50px; font-size: 22px; }

/* ============================================================
   SearchSelect (combobox with search)
   ============================================================ */
.ss {
  position: relative;
  width: 100%;
}
.ss-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.1s ease;
}
.ss-trigger:hover { border-color: var(--ink-2); }
.ss-trigger.open { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,20,14,0.08); }
.ss-trigger .ico-search { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.ss-trigger .ss-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-trigger .ss-placeholder { color: var(--muted-2); }
.ss-trigger .ico-chev { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.ss-trigger .ss-clear {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--surface-sunk);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ss-trigger .ss-clear:hover { background: var(--border); color: var(--ink); }

.ss-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  max-height: 360px;
  overflow: hidden;
}
.ss-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.ss-search .ico-search { width: 14px; height: 14px; color: var(--muted); }
.ss-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--ink);
}
.ss-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.ss-opt {
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
}
.ss-opt:hover, .ss-opt.kbd-active {
  background: var(--surface-sunk);
}
.ss-opt.selected { background: var(--accent-soft); }
.ss-opt .ss-opt-main { flex: 1; min-width: 0; }
.ss-opt .ss-opt-title { color: var(--ink); font-weight: 500; }
.ss-opt .ss-opt-meta { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; font-family: var(--mono); }
.ss-opt .ss-opt-meta .dim { color: var(--muted-2); }
.ss-opt .ss-opt-trail { font-family: var(--mono); font-size: 11px; color: var(--muted); flex-shrink: 0; }
.ss-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.ss-foot {
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  display: flex;
  justify-content: space-between;
}
.kbd {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 10px;
}

mark { background: var(--accent-soft); color: inherit; padding: 0 1px; border-radius: 2px; }

/* ============================================================
   Card / Surface
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-head .badge { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.card-body { padding: 18px; }
.card-body.dense { padding: 0; }

/* ============================================================
   Table
   ============================================================ */
.tbl-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}
.tbl {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  font-family: var(--mono);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { font-family: var(--mono); text-align: right; font-feature-settings: "tnum" 1; }
.tbl .sku { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.tbl .actions { text-align: right; white-space: nowrap; width: 1px; padding: 4px 8px; }
.tbl .actions .btn { margin-left: 2px; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.sort-icon { font-size: 9px; opacity: 0.35; margin-left: 3px; }
.sort-icon.active { opacity: 1; color: var(--accent); }
.tbl .muted { color: var(--muted); }
.tbl .truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tbl-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.tbl-empty h4 { font-size: 14px; color: var(--ink); margin: 0 0 4px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 2px;
  gap: 8px;
  flex-wrap: wrap;
}
.pagination-info { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.pagination-btns { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.pagination-ellipsis { width: 30px; text-align: center; font-size: 12px; color: var(--muted); }

/* ============================================================
   Tag / Badge
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-sunk);
  color: var(--ink-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.tag.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

/* ============================================================
   Toma de Inventario — el corazón de la app
   ============================================================ */
.toma-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 1100px) {
  .toma-layout { grid-template-columns: 1fr; }
}

.toma-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: visible;
}

.toma-stripe {
  background: linear-gradient(90deg, #1a1a14 0%, #2a2a1e 100%);
  color: #f5f3eb;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 3px solid var(--accent);
}
.toma-stripe h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toma-stripe .session {
  font-family: var(--mono);
  font-size: 11px;
  color: #b8b5ab;
  letter-spacing: 0.04em;
}
.toma-stripe .session strong { color: var(--accent); }

.toma-body { padding: 22px; }

.toma-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 720px) {
  .toma-row { grid-template-columns: 1fr; }
}

.product-card {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 16px;
  margin-bottom: 18px;
}
.product-card.filled {
  border-style: solid;
  border-color: var(--ink);
  background: var(--surface);
}
.product-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.product-empty .ico { width: 22px; height: 22px; opacity: 0.6; }

.product-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.product-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.product-sku { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 2px; }

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.product-mp {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  border: 1px solid #7bc8c5;
}
.product-mp .lbl { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; font-size: 10px; }
.product-mp .val { font-family: var(--mono); font-weight: 700; font-size: 18px; }
.product-mp .um { color: var(--muted); font-size: 11px; }

.capture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 720px) {
  .capture-grid { grid-template-columns: 1fr 1fr; }
}

.capture-field {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.capture-field .field-label { margin-bottom: 6px; }

.formula-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: var(--surface-sunk);
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  margin-bottom: 18px;
}
.formula-expr {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.formula-expr .chip {
  padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--ink);
  font-weight: 600;
  font-feature-settings: "tnum" 1;
}
.formula-expr .op { color: var(--muted-2); font-weight: 700; }
.formula-result {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.formula-result .lbl {
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.formula-result .val {
  font-family: var(--mono);
  font-size: 36px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
  line-height: 1.05;
}
.formula-result .val small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 4px; }

.theoretical {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--info-soft);
  border-radius: var(--r-md);
  margin-bottom: 18px;
  font-size: 13px;
}
.theoretical .lbl { color: var(--info); font-weight: 500; }
.theoretical .val { font-family: var(--mono); font-weight: 700; }
.theoretical.match { background: var(--success-soft); }
.theoretical.match .lbl { color: var(--success); }
.theoretical.diff { background: var(--warn-soft); }
.theoretical.diff .lbl { color: var(--warn); }

.toma-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.toma-submit-row .hint { font-size: 12px; color: var(--muted); }
.toma-submit-row .hint .kbd { margin: 0 2px; }

/* Session log card */
.session-log {
  position: sticky;
  top: 76px;
}
.session-log-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.session-log-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}
.session-log-head .count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.log-list {
  max-height: 540px;
  overflow-y: auto;
}
.log-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
}
.log-item:last-child { border-bottom: none; }
.log-item .li-title { font-size: 13px; font-weight: 500; color: var(--ink); }
.log-item .li-meta { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.log-item .li-qty {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  text-align: right;
  font-feature-settings: "tnum" 1;
}
.log-item .li-formula {
  grid-column: 2;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}
.log-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ============================================================
   Mobile responsive ≤ 600px — layout compacto, sin desborde
   ============================================================ */
@media (max-width: 600px) {

  /* ── Freno global: ningún elemento desborda la pantalla ── */
  html, body { overflow-x: hidden; }
  .main  { overflow-x: hidden; max-width: 100vw; }
  .page  { padding: 8px 8px 88px; overflow-x: hidden; max-width: 100vw; }

  /* ── Encabezado ── */
  .page-head   { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 12px; }
  .page-title  { font-size: 17px; }
  .page-sub    { font-size: 11px; word-break: break-word; overflow-wrap: anywhere; }
  .page-actions{ justify-content: flex-end; flex-wrap: wrap; gap: 6px; }

  /* ── Toma layout: margen lateral, hijos contenidos ── */
  .toma-layout      { margin: 0 4px; gap: 12px; }
  .toma-layout > *  { min-width: 0; max-width: 100%; }

  /* ── Stripe del card ── */
  .toma-stripe         { padding: 10px 12px; }
  .toma-stripe h2      { font-size: 12px; gap: 6px; }
  .toma-stripe .session{
    font-size: 10px;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ── Cuerpo del formulario ── */
  .toma-body   { padding: 10px; }
  .toma-row    { margin-bottom: 10px; }
  .toma-row > *{ min-width: 0; }   /* celdas de grid no expanden más allá de 1fr */

  /* ── Capture grid: una columna, reordenado por importancia ── */
  .capture-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "bultos" "saldo" "mp";
    gap: 8px;
    margin-bottom: 10px;
  }
  .capture-field            { padding: 10px; }
  .capture-field:nth-child(1){ grid-area: bultos; }
  .capture-field:nth-child(2){ grid-area: mp;     }
  .capture-field:nth-child(3){ grid-area: saldo;  }
  .capture-field:nth-child(2){
    background: var(--surface-2);
    border-style: dashed;
  }
  .capture-field:nth-child(2) .field-label { color: var(--muted); font-size: 11px; }

  /* ── Botones numéricos: táctiles pero proporcionales ── */
  .num-input.lg        { width: 100%; }
  .num-input.lg button { width: 48px; height: 50px; font-size: 20px; }
  .num-input.lg input  { height: 50px; font-size: 22px; min-width: 0; }

  /* ── SearchSelect ── */
  .ss           { width: 100%; max-width: 100%; }
  .ss-popover   { left: 0; right: 0; max-height: 200px; }
  .ss-list      { max-height: 140px; }

  /* ── Inputs de texto en toma-row ── */
  .toma-row input.input { width: 100%; }

  /* ── Formula: una columna, número más justo ── */
  .formula-card {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px;
    text-align: center;
    margin-bottom: 10px;
  }
  .formula-expr          { justify-content: center; font-size: 12px; gap: 5px; flex-wrap: wrap; }
  .formula-expr .chip    { padding: 2px 6px; }
  .formula-result        { align-items: center; }
  .formula-result .val   { font-size: 36px; }

  /* ── Teórico ── */
  .theoretical     { flex-wrap: wrap; gap: 4px; padding: 8px 10px; margin-bottom: 10px; }
  .theoretical .val{ font-size: 12px; }

  /* ── Fila de submit ── */
  .toma-submit-row          { flex-direction: column; align-items: stretch; gap: 8px; padding-top: 10px; }
  .toma-submit-row .hint    { display: none; }
  .toma-submit-row > div    { display: flex; flex-direction: column; gap: 8px; }
  .toma-submit-row .btn     { width: 100%; justify-content: center; }
  .btn.btn-accent.btn-xl    { font-size: 16px; height: 50px; padding: 0 16px; }

  /* ── Log de sesión ── */
  .session-log       { position: static; }
  .log-list          { max-height: 200px; }
  .log-item          { padding: 8px 10px; }
  .log-item .li-title{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }
  .log-item .li-qty  { font-size: 14px; }

  /* ── Product card: columna, sin estirarse ── */
  .product-card                { padding: 10px; margin-bottom: 10px; }
  .product-head                { flex-direction: column; gap: 6px; margin-bottom: 4px; }
  .product-head > div:first-child{ min-width: 0; }
  .product-title               { font-size: 13px; white-space: normal; word-break: break-word; }
  .product-sku                 { font-size: 10px; }
  .product-mp                  { align-self: flex-start; padding: 4px 10px; gap: 6px; }
  .product-mp .val             { font-size: 14px; }
  .product-mp .lbl             { font-size: 9px; }

  /* ── Modales ── */
  .modal-bg  { padding: 10px; }
  .modal     { border-radius: 10px; max-height: 95vh; }
  .modal-head{ padding: 12px 14px; }
  .modal-body{ padding: 12px 14px; }
  .modal-foot{ padding: 10px 14px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; min-width: 100px; justify-content: center; }
}

/* ============================================================
   Modal
   ============================================================ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(20,20,14,0.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar .input { width: 280px; height: 36px; }
.filter-bar select.input { width: auto; }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.stat-label {
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 4px;
  font-feature-settings: "tnum" 1;
}
.stat-trend {
  font-size: 11px;
  font-family: var(--mono);
  margin-top: 2px;
  color: var(--muted);
}

/* Diff visual */
.diff-pos { color: var(--success); }
.diff-neg { color: var(--danger); }
.diff-zero { color: var(--muted); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--primary-ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } }
.toast .ico { width: 16px; height: 16px; }
.toast.success { background: var(--success); }
.toast.danger { background: var(--danger); }

/* Loader */
.loader-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 1000;
  text-align: center;
}
.loader-mark {
  position: relative;
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--accent-ink);
  margin: 0 auto 20px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.18);
  animation: load-breathe 1.8s ease-in-out infinite;
}
/* halo difuminado que late detrás del ícono */
.loader-mark::before {
  content: '';
  position: absolute; inset: -12px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(18px);
  z-index: -1;
  animation: load-halo 1.8s ease-in-out infinite;
}
.loader-mark img {
  width: 48px !important; height: 48px !important;
  animation: load-focus 1.8s ease-in-out infinite;
}
@keyframes load-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(0.955); }
}
@keyframes load-halo {
  0%, 100% { opacity: 0.28; transform: scale(1); }
  50%      { opacity: 0.62; transform: scale(1.2); }
}
/* el logo se difumina y vuelve a enfocar (efecto "cargando") */
@keyframes load-focus {
  0%, 100% { filter: blur(0); opacity: 1; }
  50%      { filter: blur(2.5px); opacity: 0.8; }
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-screen .lbl { color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

/* ── Overlay de carga por navegación (semitransparente) ──
   Se ve la página detrás (atenuada + leve blur) con el ícono encima,
   para indicar "trabajando" sin tapar todo. No bloquea clics. */
.page-load-overlay {
  position: fixed; inset: 0; z-index: 800;
  display: grid; place-items: center;
  pointer-events: none;
  animation: plo-in 0.18s ease;
}
.page-load-overlay::before {
  content: ''; position: absolute; inset: 0;
  background: var(--bg); opacity: 0.5;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
@keyframes plo-in { from { opacity: 0; } to { opacity: 1; } }
.page-load-mark {
  position: relative; z-index: 1;
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--accent);
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.22);
  animation: load-breathe 1.6s ease-in-out infinite;
}
.page-load-mark::before {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  background: var(--accent); filter: blur(16px); z-index: -1;
  animation: load-halo 1.6s ease-in-out infinite;
}
.page-load-mark img {
  width: 40px; height: 40px; object-fit: contain;
  animation: load-focus 1.6s ease-in-out infinite;
}

/* Mobile: collapse sidebar */
@media (max-width: 840px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { 
    position: fixed; 
    left: 0; top: 0; bottom: 0;
    width: 232px; z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40;
  }
  .mobile-menu-btn { display: inline-flex !important; }
}
.mobile-menu-btn { display: none; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.checkbox-row input { width: 16px; height: 16px; }

/* ============================================================
   Login — Split-screen SaaS
   ============================================================ */
.login-root {
  position: fixed;
  inset: 0;
  display: flex;
  font-family: var(--sans);
  overflow: hidden;
}

/* ── Left brand panel ── */
.login-left {
  flex: 0 0 56%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 48px 56px;
  background: linear-gradient(150deg, #081623 0%, #0d2a28 55%, #071a18 100%);
  color: #fff;
}
.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle 1.5px at 12% 15%, rgba(255,255,255,0.55) 0%, transparent 100%),
    radial-gradient(circle 1px at 28% 8%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(circle 2px at 46% 21%, rgba(255,255,255,0.45) 0%, transparent 100%),
    radial-gradient(circle 1px at 69% 13%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(circle 1.5px at 86% 26%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(circle 1px at 93% 7%, rgba(255,255,255,0.25) 0%, transparent 100%),
    radial-gradient(circle 1px at 6% 50%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(circle 1.5px at 34% 64%, rgba(255,255,255,0.32) 0%, transparent 100%),
    radial-gradient(circle 1px at 75% 57%, rgba(255,255,255,0.22) 0%, transparent 100%),
    radial-gradient(circle 2px at 56% 76%, rgba(255,255,255,0.38) 0%, transparent 100%),
    radial-gradient(circle 1px at 19% 88%, rgba(255,255,255,0.18) 0%, transparent 100%),
    radial-gradient(circle 1.5px at 89% 83%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(circle 1px at 42% 95%, rgba(255,255,255,0.15) 0%, transparent 100%),
    radial-gradient(circle 1px at 62% 91%, rgba(255,255,255,0.2) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}
.login-aurora-1 {
  position: absolute;
  width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(58,147,143,0.38) 0%, transparent 66%);
  filter: blur(60px);
  top: -100px; left: -80px;
  animation: login-blob-a 18s ease-in-out infinite alternate;
  z-index: 0;
}
.login-aurora-2 {
  position: absolute;
  width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,0.28) 0%, transparent 66%);
  filter: blur(52px);
  bottom: -60px; right: -50px;
  animation: login-blob-b 22s ease-in-out infinite alternate;
  z-index: 0;
}
.login-aurora-3 {
  position: absolute;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(45,140,133,0.2) 0%, transparent 66%);
  filter: blur(44px);
  top: 58%; left: 42%;
  animation: login-blob-c 14s ease-in-out infinite alternate;
  z-index: 0;
}
@keyframes login-blob-a {
  0%   { transform: translate(  0px,   0px) scale(1.00); }
  40%  { transform: translate( 80px,  70px) scale(1.18); }
  100% { transform: translate( 40px, 110px) scale(0.93); }
}
@keyframes login-blob-b {
  0%   { transform: translate(  0px,   0px) scale(1.00); }
  45%  { transform: translate(-70px, -65px) scale(1.22); }
  100% { transform: translate(-25px, -95px) scale(0.90); }
}
@keyframes login-blob-c {
  0%   { transform: translate(0px,   0px) scale(1.00); }
  50%  { transform: translate(-45px, 50px) scale(1.28); }
  100% { transform: translate( 35px,-30px) scale(0.82); }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1;   transform: scale(1);   }
  50%       { opacity: 0.5; transform: scale(0.75); }
}
.login-left-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100%;
}
.login-left-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: auto;
}
.login-left-logo-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(58,147,143,0.22);
  border: 1px solid rgba(58,147,143,0.38);
  display: grid; place-items: center;
}
.login-left-logo-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: #fff; }
.login-left-logo-sub  { font-size: 11px; color: rgba(255,255,255,0.4); letter-spacing: 0.04em; margin-top: 1px; }
.login-left-hero { margin-bottom: 36px; }
.login-left-tag {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border-radius: 20px;
  background: rgba(58,147,143,0.16);
  border: 1px solid rgba(58,147,143,0.32);
  color: rgba(80,210,205,0.9);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: 22px;
}
.login-left-tag-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(80,210,205,0.9);
  animation: pulse-dot 2.2s ease-in-out infinite;
}
.login-left-h1 {
  font-size: 38px; font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.1;
  color: #fff; margin: 0 0 16px;
}
.login-left-h1 span {
  background: linear-gradient(90deg, #4dd8d3 0%, #7ae4e1 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-left-desc {
  font-size: 14px; color: rgba(255,255,255,0.48);
  line-height: 1.65; max-width: 380px;
}
.login-features { display: flex; flex-direction: column; gap: 12px; margin-bottom: 44px; }
.login-feature  { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255,255,255,0.68); }
.login-feature-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(58,147,143,0.14); border: 1px solid rgba(58,147,143,0.24);
  display: grid; place-items: center; flex-shrink: 0;
  color: rgba(80,210,205,0.82);
}
.login-left-footer {
  padding-top: 22px; border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.login-left-footer a {
  color: rgba(255,255,255,0.36); font-size: 12px;
  text-decoration: none; transition: color 0.15s;
}
.login-left-footer a:hover { color: rgba(255,255,255,0.7); }
.login-left-footer-sep { width: 1px; height: 12px; background: rgba(255,255,255,0.12); }

/* ── Right form panel ── */
.login-right {
  flex: 1;
  background: var(--surface);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 56px 64px;
  overflow-y: auto;
}
.login-right-inner { width: 100%; max-width: 360px; }
.login-right-logo  { display: flex; align-items: center; gap: 10px; margin-bottom: 36px; }
.login-right-logo-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--accent); display: grid; place-items: center;
}
.login-heading    { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 0 0 6px; }
.login-subheading { font-size: 13px; color: var(--muted); margin: 0 0 28px; line-height: 1.5; }
.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.login-field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.01em; }
.login-field-wrap  { position: relative; }
.login-field-wrap .input { width: 100%; padding-right: 40px; }
.login-eye-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: 4px; cursor: pointer;
  color: var(--muted); display: grid; place-items: center;
  border-radius: 4px; transition: color 0.15s;
}
.login-eye-btn:hover { color: var(--ink); }
.login-row {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.login-remember {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 12px; color: var(--ink-2);
  user-select: none;
}
.login-remember input { display: none; }
.login-remember-box {
  width: 16px; height: 16px; border: 1.5px solid var(--border-strong);
  border-radius: 4px; display: grid; place-items: center;
  transition: background 0.15s, border-color 0.15s; flex-shrink: 0;
}
.login-remember input:checked ~ .login-remember-box {
  background: var(--accent); border-color: var(--accent);
}
.login-remember-check { display: none; }
.login-remember input:checked ~ .login-remember-box .login-remember-check { display: block; }
.login-forgot {
  font-size: 12px; color: var(--accent);
  background: none; border: none; padding: 0;
  cursor: pointer; font-family: inherit; font-weight: 500;
  transition: opacity 0.15s;
}
.login-forgot:hover { opacity: 0.72; }
.login-err {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--r-md); font-size: 13px; font-weight: 500;
  margin-bottom: 14px;
}
.login-submit {
  width: 100%; padding: 12px 16px;
  font-size: 14px; font-weight: 600;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-md);
  cursor: pointer; font-family: inherit;
  letter-spacing: 0.01em; margin-bottom: 24px;
  transition: opacity 0.15s, transform 0.1s;
}
.login-submit:hover:not(:disabled) { opacity: 0.88; }
.login-submit:active:not(:disabled) { transform: scale(0.99); }
.login-submit:disabled { opacity: 0.45; cursor: default; }
.login-right-footer {
  padding-top: 22px; border-top: 1px solid var(--border);
  text-align: center; display: flex;
  align-items: center; justify-content: center; gap: 4px;
}
.login-right-footer a {
  color: var(--muted); font-size: 12px;
  text-decoration: none; transition: color 0.15s;
}
.login-right-footer a:hover { color: var(--accent); }
.login-right-footer-sep { color: var(--border-strong); font-size: 11px; margin: 0 4px; }
/* Forgot modal overlay */
.login-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: grid; place-items: center; z-index: 200; padding: 24px;
}
.login-modal-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px;
  box-shadow: 0 30px 80px -10px rgba(0,0,0,0.35);
}
.login-modal-title { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0 0 8px; }
.login-modal-sub   { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0 0 24px; }
/* Responsive */
@media (max-width: 900px) {
  .login-left  { display: none; }
  .login-right { padding: 48px 40px; }
}
@media (max-width: 480px) {
  .login-right { padding: 32px 24px; }
}

/* ============================================================
   Role badge
   ============================================================ */
.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.role-pill.admin { background: rgba(124, 58, 237, 0.15); color: #7c3aed; }
.role-pill.supervisor { background: rgba(37, 99, 235, 0.15); color: #2563eb; }
.role-pill.auditor { background: var(--accent-soft); color: var(--accent-ink); }

/* ============================================================
   CSV Import
   ============================================================ */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--ink); background: var(--accent-soft); }
.dropzone .ico { width: 32px; height: 32px; color: var(--muted); margin-bottom: 8px; }
.dropzone h4 { margin: 0 0 4px; font-size: 14px; }
.dropzone .hint { font-size: 12px; color: var(--muted); }

.csv-preview {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  max-height: 320px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11px;
}
.csv-preview table { width: 100%; border-collapse: collapse; }
.csv-preview th, .csv-preview td { padding: 6px 8px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
.csv-preview th { background: var(--surface-2); position: sticky; top: 0; font-weight: 600; }
.csv-preview td.invalid { background: var(--danger-soft); color: var(--danger); }
.csv-preview tr.invalid { background: rgba(178, 45, 45, 0.06); }

.import-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.import-summary > div {
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.import-summary .v { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.import-summary .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--mono); }
.import-summary .ok .v { color: var(--success); }
.import-summary .bad .v { color: var(--danger); }

/* ============================================================
   Signature pad
   ============================================================ */
.sig-pad {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: #fff;
  position: relative;
  overflow: hidden;
}
.sig-pad canvas { display: block; width: 100%; cursor: crosshair; touch-action: none; }
.sig-pad-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--muted-2);
  font-size: 13px;
  font-style: italic;
}
.sig-pad-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.sig-pad-foot .lbl { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.sig-img {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  padding: 8px;
}
.sig-img img { display: block; max-width: 100%; height: auto; }

/* ============================================================
   Conciliacion / sesion cards
   ============================================================ */
.sesion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.sesion-card:hover { border-color: var(--ink-2); box-shadow: var(--shadow-sm); }
.sesion-card.active { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,20,14,0.06); }
.sesion-id { font-family: var(--mono); font-weight: 700; font-size: 14px; min-width: 160px; }
.sesion-meta { color: var(--muted); font-size: 12px; }
.sesion-stats { display: flex; gap: 16px; margin-left: auto; }
.sesion-stat { text-align: right; }
.sesion-stat .v { font-family: var(--mono); font-weight: 700; font-size: 16px; }
.sesion-stat .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.sesion-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

/* ============================================================
   Scanner — bottom-sheet (móvil) / card centrado (desktop)
   ============================================================ */
.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;      /* bottom-sheet en móvil */
  justify-content: center;
}

.scan-sheet {
  width: 100%;
  max-width: 480px;
  background: #16160f;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: scan-slide-up 0.22s ease-out;
}

@keyframes scan-slide-up {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.scan-title {
  font-size: 14px;
  font-weight: 600;
  color: #f5f3eb;
  letter-spacing: 0.01em;
}

.scan-close-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #f5f3eb;
  font-size: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.scan-close-btn:hover { background: rgba(255,255,255,0.16); }

.scan-viewfinder {
  width: 100%;
  background: #000;
  min-height: 220px;
}

/* Oculta el contador de fps/scans que html5-qrcode inyecta */
#xm-qr-reader__dashboard_section_swaplink,
#xm-qr-reader__status_span,
#xm-qr-reader__camera_permission_button { display: none !important; }
#xm-qr-reader__header_message { font-size: 11px !important; }

.scan-hint {
  font-size: 12px;
  color: rgba(245,243,235,0.5);
  text-align: center;
  padding: 10px 20px 6px;
}

.scan-error {
  margin: 16px 20px;
  background: rgba(220,53,69,0.15);
  border: 1px solid rgba(220,53,69,0.3);
  border-radius: 8px;
  padding: 14px;
  color: #ff6b7a;
  font-size: 13px;
  text-align: center;
}

.scan-footer {
  padding: 12px 20px 20px;
}

/* Botón de escanear (cámara) junto a inputs */
.scan-btn {
  height: 40px;
  width: 40px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: transparent;
}
.scan-btn:hover { background: var(--accent); color: #ffffff; }

/* Desktop: centrado como card */
@media (min-width: 601px) {
  .scan-overlay { align-items: center; padding: 20px; }
  .scan-sheet {
    border-radius: 14px;
    animation: scan-fade-in 0.18s ease-out;
  }
  @keyframes scan-fade-in {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
  }
}

/* Mobile: viewfinder más alto */
@media (max-width: 600px) {
  .scan-viewfinder { min-height: 260px; }
  .scan-footer { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}

/* ============================================================
   Global Loading Bar — aparece dentro del topbar
   ============================================================ */
.loading-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: loading-sweep 1.3s ease-in-out infinite;
  pointer-events: none;
}
@keyframes loading-sweep {
  0%   { background-position: -40% center; }
  100% { background-position: 140% center; }
}

/* ============================================================
   Page transition — fade+slide cuando se monta una página
   ============================================================ */
.page { animation: page-enter 0.18s ease; }
@keyframes page-enter {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Startup loader — branding mejorado
   ============================================================ */
.loader-brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #16160e;
  margin-top: 14px;
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
}
.loader-version {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #76746a;
  text-transform: uppercase;
  font-family: 'IBM Plex Mono', monospace;
  margin-top: 4px;
}
.loader-progress {
  width: 110px;
  height: 2px;
  background: #e0ddd3;
  border-radius: 2px;
  overflow: hidden;
  margin: 22px auto 12px;
}
.loader-bar {
  height: 100%;
  width: 40%;
  background: #3a938f;
  border-radius: 2px;
  animation: loader-bar-sweep 1.4s ease-in-out infinite;
}
@keyframes loader-bar-sweep {
  0%   { transform: translateX(-250%); }
  100% { transform: translateX(350%); }
}

