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

:root {
  --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: #ffb800;        /* amber WMS */
  --accent-ink: #2a1f00;
  --accent-soft: #fff4d1;

  --success: #1f7a4d;
  --success-soft: #d8efe1;
  --danger: #b22d2d;
  --danger-soft: #f6d9d4;
  --warn: #b56b00;
  --warn-soft: #ffe6b8;
  --info: #2c5fa3;
  --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: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme="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: #3d2f00;
  --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: #14140e;
  color: #d8d6cc;
  border-right: 1px solid #000;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.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-family: var(--mono);
  font-size: 10px;
  color: #88857c;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.nav {
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}
.nav-section {
  font-family: var(--mono);
  font-size: 10px;
  color: #66645c;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 5px;
  color: #b8b5ab;
  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.04); color: #fff; }
.nav-item.active {
  background: rgba(255,184,0,0.12);
  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-family: var(--mono);
  font-size: 11px;
  color: #66645c;
}
.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.user-chip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb800, #ff7d00);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  color: #2a1f00;
}
.user-name { color: #d8d6cc; font-weight: 500; }
.user-role { color: #66645c; font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }

/* ============================================================
   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: #e8a700; border-color: #e8a700; }

.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; }

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: 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; }
.tbl .actions .btn { margin-left: 4px; }
.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; }

/* ============================================================
   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 #ffd96e;
}
.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;
}

/* ============================================================
   Toma — Mobile responsive (≤ 600px)
   ============================================================ */
@media (max-width: 600px) {
  /* Safety net: nada desborda horizontalmente */
  .main { overflow-x: hidden; }
  .page { padding: 12px 12px 100px; overflow-x: hidden; }

  .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .page-title { font-size: 18px; }
  .page-sub { font-size: 11px; word-break: break-word; }
  .page-actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; }

  .toma-stripe { padding: 10px 14px; }
  .toma-stripe h2 { font-size: 13px; gap: 8px; }
  .toma-stripe .session { font-size: 10px; }

  /* toma-body: padding reducido, sin desborde */
  .toma-body { padding: 12px; }
  .toma-row { margin-bottom: 12px; }

  /* Capture grid: una sola columna para que num-input tenga espacio real.
     En un teléfono de 375px: 375-24(page)-24(body) = 327px disponibles,
     suficiente para botones 52px + input legible. */
  .capture-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "bultos" "saldo" "mp";
    gap: 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; }
  /* Masterpack: visualmente secundario */
  .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; }

  /* num-input: botones cómodos, input con espacio real */
  .num-input.lg button { width: 52px; font-size: 22px; height: 58px; }
  .num-input.lg input { height: 58px; font-size: 26px; min-width: 0; }
  .num-input.lg { width: 100%; }

  /* SearchSelect: dropdown no se sale */
  .ss { width: 100%; max-width: 100%; }
  .ss-popover { left: 0; right: 0; max-height: 220px; }
  .ss-list { max-height: 160px; }

  /* Input LPN / Lote en toma-row */
  .toma-row input.input { width: 100%; }

  /* Formula: columna, total centrado y grande */
  .formula-card {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
    text-align: center;
  }
  .formula-expr { justify-content: center; font-size: 12px; gap: 6px; flex-wrap: wrap; }
  .formula-expr .chip { padding: 2px 6px; }
  .formula-result { align-items: center; }
  .formula-result .val { font-size: 48px; }

  /* Submit row: stacked, botón de registrar full width y alto */
  .toma-submit-row { flex-direction: column; align-items: stretch; gap: 10px; padding-top: 12px; }
  .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: 17px; padding: 0 20px; height: 56px; }

  /* Session log: estático, altura limitada */
  .session-log { position: static; }
  .log-list { max-height: 220px; }
  .log-item { padding: 10px 12px; }

  /* Theoretical: wrap */
  .theoretical { flex-wrap: wrap; gap: 4px; padding: 10px 12px; }
  .theoretical .val { font-size: 13px; }

  /* Product card */
  .product-card { padding: 10px; margin-bottom: 12px; }
  .product-title { font-size: 14px; }
  .product-head { flex-wrap: wrap; gap: 8px; }
  .product-mp { padding: 6px 10px; }
  .product-mp .val { font-size: 15px; }

  /* Modal: padding lateral en teléfono */
  .modal-bg { padding: 12px; }
  .modal { border-radius: 10px; }
  .modal-head { padding: 12px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 10px 16px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; min-width: 120px; 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 {
  width: 56px; height: 56px; border-radius: 12px;
  background: var(--accent);
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 22px;
  color: var(--accent-ink);
  margin: 0 auto 16px;
  animation: load-pulse 1.4s ease-in-out infinite;
}
@keyframes load-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.92); opacity: 0.7; }
}
.loader-screen .lbl { color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

/* 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
   ============================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #14140e 0%, #2a2a1e 100%);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}
.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,184,0,0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,184,0,0.05) 0%, transparent 40%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.login-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.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;
}
.login-err .ico { width: 14px; height: 14px; }

.login-quick { border-top: 1px solid var(--border); padding-top: 20px; }
.login-quick-title { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 10px; }
.login-quick-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.login-quick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.1s, background 0.1s;
}
.login-quick-item:hover { border-color: var(--ink-2); background: var(--surface); }
.login-quick-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.login-quick-hint { font-size: 11px; color: var(--muted); text-align: center; font-family: var(--mono); }
.login-quick-hint .kbd { margin: 0 2px; }

/* ============================================================
   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; }

