/* ===========================================================================
   Almácigo Software — capa de marca + base de UI
   Tokens de color (claro/oscuro), tipografía y componentes base.
   Misma identidad que la landing, pero pensada para una app de gestión.
   =========================================================================== */

:root {
  --paper:      #F7F3EC;
  --paper-2:    #EFE9DD;
  --ink:        #1A1A18;
  --ink-2:      #6A645A;
  --line:       rgba(26, 26, 24, .16);
  --accent:     #1F4D3A;        /* verde savia */
  --accent-ink: #FBF8F1;

  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);

  --font-display: 'Fraunces', Georgia, serif;
  --font-ui:      'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --paper:      #15130E;
  --paper-2:    #201C15;
  --ink:        #ECE6D8;
  --ink-2:      #A49C8B;
  --line:       rgba(236, 230, 216, .14);
  --accent:     #5FBE85;
  --accent-ink: #0E140F;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* respetar el atributo hidden sobre cualquier display */
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}

a { color: var(--accent); }

/* --- Toggle de tema (sol / luna) --------------------------------------- */
.theme-toggle {
  position: fixed; top: 18px; right: 18px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --- Botones ------------------------------------------------------------ */
.btn {
  font-family: var(--font-ui);
  font-size: 15px; font-weight: 600;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, border-color .15s, filter .15s;
}
.btn:hover { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(1.06); }

/* --- Formularios -------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  font-family: var(--font-ui); font-size: 15px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* --- Gasto: tipo + líneas de compra de mercadería ---------------------- */
.gtype { display: flex; flex-wrap: wrap; gap: 10px; }
.gtype-opt { display: flex; align-items: flex-start; gap: 9px; cursor: pointer;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); background: var(--paper); }
.gtype-opt:has(input:checked) { border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--paper)); }
.gtype-opt input { margin-top: 3px; accent-color: var(--accent); }
.gtype-opt span { display: flex; flex-direction: column; }
.gtype-opt strong { font-size: 14px; }
.gtype-opt small { font-size: 12px; color: var(--ink-2); font-weight: 400; }

.pline-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* Columnas: producto · cant. · costo · precio · ganancia · quitar */
.pline-labels, .pline { display: grid;
  grid-template-columns: 1fr 64px 96px 110px 58px 28px; gap: 8px; align-items: center; }
.pline-labels { font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-2); margin-bottom: 6px; padding: 0 2px; }
.pline { margin-bottom: 8px; }
.pline select, .pline input { width: 100%; font-family: var(--font-ui); font-size: 14px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); }
.pline select:focus, .pline input:focus { outline: none; border-color: var(--accent); }
.pline-margin { font-size: 13px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums; color: var(--ink-2); }
.pline-margin.pos { color: var(--accent); }
.pline-margin.neg { color: #c0392b; }
.pline-del { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 16px; }
.pline-del:hover { color: #c0392b; }

.pline-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Cartel "producto nuevo" debajo de la línea (ocupa el ancho completo). */
.pline-new { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--accent);
  margin: -2px 0 6px; }
/* Texto explicativo de la compra: más grande y legible que un .hint. */
.pline-intro { margin: 8px 0 14px; font-size: 14px; line-height: 1.5; color: var(--ink); }
.pline-intro strong { font-weight: 700; }

/* Alta rápida de producto dentro de la compra */
.np-panel { margin: 0 0 14px; padding: 14px; border: 1px dashed var(--accent);
  border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 6%, var(--paper)); }
.np-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.np-row:last-of-type { margin-bottom: 0; }
.np-row input { flex: 1 1 180px; min-width: 0; font-family: var(--font-ui); font-size: 14px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); }
.np-row input:focus { outline: none; border-color: var(--accent); }
.np-row .btn { flex: 0 0 auto; }
.np-error { color: #c0392b; margin: 8px 0 0; }
@media (max-width: 720px) {
  .pline-labels { display: none; }
  .pline { grid-template-columns: 1fr 1fr; }
  .pline .pline-prod { grid-column: 1 / -1; }
  .np-row input { flex-basis: 100%; }
}

/* --- Layout de autenticación ------------------------------------------- */
.auth-wrap {
  min-height: 100%;
  display: grid; place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  padding: 32px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand svg { color: var(--accent); }
.brand .wordmark { font-family: var(--font-display); font-size: 22px; font-weight: 600; }

.auth-card h1 { font-size: 20px; margin: 18px 0 4px; }
.auth-sub  { margin: 0 0 24px; color: var(--ink-2); font-size: 14px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--ink-2); font-size: 13px; }

/* --- Alertas / errores -------------------------------------------------- */
.alert {
  margin-bottom: 18px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, #c0392b 40%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #c0392b 10%, var(--paper));
  color: color-mix(in srgb, #c0392b 65%, var(--ink));
  font-size: 14px;
}

.alert-success {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--paper));
  color: color-mix(in srgb, var(--accent) 70%, var(--ink));
}

/* --- Placeholder del dashboard (provisorio, 0.5 lo reemplaza) ----------- */
.shell-placeholder { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 18px 0 24px; }
.kv dt { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.kv dd { margin: 0; font-size: 14px; }

/* ===========================================================================
   Panel super-admin
   =========================================================================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand svg { color: var(--accent); }
.topbar-brand .wordmark { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.topbar-sep { color: var(--ink-2); }
.topbar-title { color: var(--ink-2); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
/* Dentro de la topbar el toggle no va fijo a la pantalla */
.theme-toggle.topbar-toggle { position: static; top: auto; right: auto; width: 36px; height: 36px; }

.container { max-width: 1040px; margin: 0 auto; padding: 28px 24px 48px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }

/* Botones chicos / variantes */
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger {
  background: transparent;
  color: color-mix(in srgb, #c0392b 70%, var(--ink));
  border-color: color-mix(in srgb, #c0392b 40%, var(--line));
}
.btn-danger:hover { border-color: #c0392b; color: #c0392b; }

/* Tabla */
/* Barra de Inventario: buscador + acción */
.inv-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }
.inv-search { display: flex; flex: 1; gap: 8px; min-width: 0; }
.inv-search input { flex: 1; min-width: 0; font-family: var(--font-ui); font-size: 15px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); }
.inv-search input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.inv-toolbar .btn { width: auto; white-space: nowrap; }
@media (max-width: 620px) {
  .inv-toolbar { flex-direction: column; align-items: stretch; }
  .inv-toolbar .btn-primary { width: 100%; }
}

/* Pestañas de Inventario */
.inv-tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.inv-tab { padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--ink-2);
  text-decoration: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.inv-tab:hover { color: var(--ink); }
.inv-tab.active { color: var(--accent-ink); background: var(--accent); }

/* Alerta de stock bajo */
.inv-lowstock { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; padding: 12px 16px; font-size: 15px; font-weight: 600;
  border: 1px solid color-mix(in srgb, #e67e22 45%, var(--line));
  background: color-mix(in srgb, #e67e22 12%, var(--paper));
  color: color-mix(in srgb, #e67e22 70%, var(--ink)); border-radius: var(--radius-sm); }
.inv-lowstock .btn { width: auto; white-space: nowrap; flex-shrink: 0; }

/* Ajuste rápido de precios */
.price-tool { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px;
  padding: 18px 22px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
.price-tool-label { font-weight: 700; font-size: 16px; }
.price-tool input, .price-tool select { font-family: var(--font-ui); font-size: 15px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
.price-tool-pct { width: 100px; }
.price-tool .btn { width: auto; }
.price-tool-hint { font-size: 13px; }
.price-table .price-check { width: 44px; text-align: center; }
.price-table tbody td { padding: 16px 14px; }
.price-table .price-name { font-size: 16px; font-weight: 600; }
.price-input { width: 150px; font-family: var(--font-ui); font-size: 16px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
.price-input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.price-actions { margin-top: 18px; display: flex; align-items: center; gap: 14px; }
.price-actions .btn-primary { width: auto; }
.price-page-warn { font-size: 13px; }

.dirty-flag { color: #e67e22; font-weight: 700; font-size: 13px; }

/* Cartel central al aplicar el % (pregunta si guardar) */
.price-confirm { position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .45); padding: 20px; }
.price-confirm[hidden] { display: none; }
.price-confirm:not([hidden]) { display: flex; }
.price-confirm-box { width: 100%; max-width: 400px; text-align: center;
  padding: 26px 28px; background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0, 0, 0, .35); }
.price-confirm-msg { margin: 0 0 22px; font-size: 16px; line-height: 1.45; }
.price-confirm-actions { display: flex; gap: 10px; justify-content: center; }
.price-confirm-actions .btn { width: auto; }

/* Tarjetas de Inventario */
.inv-list { display: flex; flex-direction: column; gap: 12px; }
.inv-card { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px; background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); }
.inv-card-body { min-width: 0; }
.inv-card-name { font-size: 18px; font-weight: 700; margin-bottom: 8px; line-height: 1.25; }
.inv-card-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center;
  font-size: 15px; color: var(--ink-2); }
.inv-card-meta strong { color: var(--ink); font-weight: 700; }
.inv-card > .btn { width: auto; white-space: nowrap; flex-shrink: 0; }

.inv-pager { display: flex; gap: 14px; justify-content: center; align-items: center; margin-top: 20px; }
.inv-pager .btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-2);
  padding: 11px 14px; background: var(--paper-2); border-bottom: 1px solid var(--line);
}
.table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { padding: 12px 14px; border-top: 2px solid var(--ink-2);
  font-weight: 700; background: var(--paper-2); }
.table code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 13px; }
.table .muted { color: var(--ink-2); font-size: 13px; }
/* Acciones de fila: el <td> queda como celda de tabla (alinea bien con las demás,
   incluso cuando está vacía); los botones/forms se acomodan inline a la derecha.
   NO usar display:flex en el <td>: lo saca del modelo de columnas de la tabla y
   descuadra la fila (sobre todo si la celda está vacía). */
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * { display: inline-flex; vertical-align: middle; }
.row-actions > * + * { margin-left: 6px; }

/* Movimientos del período (Métricas): texto más grande y paginador */
.mov-table { font-size: 15.5px; }
.mov-table thead th { font-size: 12.5px; }
.mov-table tbody td { padding: 15px 16px; }
.mov-table .muted { font-size: 14.5px; }
.mov-table .badge { font-size: 13px; }
.mov-pager { display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-top: 14px; font-size: 14px; }
.btn.is-disabled { opacity: .4; pointer-events: none; }

/* Detalle desplegable de una venta (qué se vendió) */
.mov-detail-row > td { padding: 0 16px 14px !important; background: var(--paper-2); }
.mov-detail-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); }
.mov-detail-head { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.mov-detail-items { list-style: none; margin: 0 0 8px; padding: 0; }
.mov-detail-items li { display: flex; justify-content: space-between; gap: 16px;
  padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.mov-detail-items li:last-child { border-bottom: 0; }
.mov-detail-totals { display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
  font-size: 14px; color: var(--ink-2); }
.mov-detail-totals > div { display: flex; gap: 14px; min-width: 200px; justify-content: space-between; }
.mov-detail-total { font-weight: 700; font-size: 15.5px; color: var(--ink); }

/* Badges de estado */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; text-transform: capitalize;
  border: 1px solid var(--line);
}
.badge-active {
  color: color-mix(in srgb, var(--accent) 75%, var(--ink));
  background: color-mix(in srgb, var(--accent) 14%, var(--paper));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.badge-suspended {
  color: color-mix(in srgb, #b8860b 75%, var(--ink));
  background: color-mix(in srgb, #b8860b 14%, var(--paper));
  border-color: color-mix(in srgb, #b8860b 40%, var(--line));
}
.badge-archived { color: var(--ink-2); background: var(--paper); }

/* Formulario en tarjeta */
.form-card {
  max-width: 460px; padding: 24px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.form-card .hint { margin: 6px 0 0; color: var(--ink-2); font-size: 12px; }
.mov-card { border-color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.mov-card .mov-card-title { margin: 0 0 4px; font-size: 16px; font-weight: 700;
  color: var(--ink); display: flex; align-items: center; gap: 8px; }
.form-card .sep { border: 0; border-top: 1px solid var(--line); margin: 6px 0 18px; }
.form-card .btn-primary { width: auto; }

/* Configuración (Métricas): cada sección en su propia tarjeta, en grilla de 2 columnas */
.config-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  align-items: start; max-width: 760px; }
.config-form .form-card { max-width: none; }
.config-form .form-card > *:last-child { margin-bottom: 0; }
.config-form .btn-primary { grid-column: 1 / -1; width: auto; justify-self: start; }
@media (max-width: 820px) { .config-form { grid-template-columns: 1fr; max-width: 520px; } }

.empty {
  padding: 40px; text-align: center; color: var(--ink-2);
  border: 1px dashed var(--line); border-radius: var(--radius);
}

/* --- Campo de contraseña con ojito ------------------------------------- */
.input-wrap { position: relative; }
.input-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ink-2);
  cursor: pointer; border-radius: 6px;
}
.pw-toggle:hover { color: var(--accent); }
.pw-toggle .icon-eye-off { display: none; }
.pw-toggle.is-showing .icon-eye { display: none; }
.pw-toggle.is-showing .icon-eye-off { display: block; }

/* ===========================================================================
   Shell del dashboard del negocio
   =========================================================================== */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  display: flex; flex-direction: column;
  padding: 18px 14px;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sidebar-brand svg { color: var(--accent); }
.sidebar-brand .wordmark { font-family: var(--font-display); font-size: 19px; font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav-item.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: color-mix(in srgb, var(--accent) 80%, var(--ink));
}
.nav-item.disabled { color: var(--ink-2); cursor: default; }
.nav-item.disabled:hover { background: transparent; }
.nav-item .soon {
  margin-left: auto; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px;
}

.sidebar-foot { margin-top: auto; padding: 12px 12px 4px; border-top: 1px solid var(--line); }
.sidebar-foot .who { font-size: 13px; font-weight: 600; word-break: break-all; }
.sidebar-foot .who-role { font-size: 12px; color: var(--ink-2); text-transform: capitalize; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--line);
}
.app-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.app-header-actions { display: flex; align-items: center; gap: 10px; }

/* Indicador de conexión con el servidor */
.conn-indicator { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--ink-2); white-space: nowrap; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); flex: none; }
.conn-indicator.is-online { color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.conn-indicator.is-online .conn-dot { background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.conn-indicator.is-offline { color: #c0392b;
  border-color: color-mix(in srgb, #c0392b 45%, var(--line));
  background: color-mix(in srgb, #c0392b 8%, transparent); }
.conn-indicator.is-offline .conn-dot { background: #c0392b; animation: conn-pulse 1.1s ease-in-out infinite; }
@keyframes conn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@media (max-width: 620px) { .conn-indicator .conn-text { display: none; } }

/* Aviso de sin conexión (arriba del contenido) */
.offline-banner { padding: 11px 24px; font-size: 14px; font-weight: 600; color: #fff;
  background: #c0392b; border-bottom: 1px solid color-mix(in srgb, #c0392b 60%, #000); }
.offline-banner.flash { animation: offline-flash .45s ease; }
@keyframes offline-flash {
  0%, 100% { background: #c0392b; }
  35% { background: #e05545; }
}
.app-content { padding: 28px 24px; }

.welcome h1 { font-size: 26px; }
.welcome .muted { color: var(--ink-2); margin: 4px 0 0; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-2); margin: 28px 0 14px; font-family: var(--font-ui); font-weight: 600; }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.module-card {
  padding: 20px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.module-ico {
  width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 12px;
  border-radius: var(--radius-sm); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.module-ico svg { width: 22px; height: 22px; }
.module-card h3 { font-size: 16px; margin-bottom: 6px; }
.module-card p { margin: 0 0 14px; color: var(--ink-2); font-size: 13px; line-height: 1.45; }

/* Card que es link (home con módulos activos) */
.module-link { display: block; text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .05s; }
.module-link:hover { border-color: var(--accent); }
.module-link:active { transform: translateY(1px); }
.module-open { font-size: 13px; font-weight: 600; color: var(--accent); }

/* Lista de módulos en la ficha del negocio (panel super-admin) */
.mod-list { display: flex; flex-direction: column; gap: 10px; }
.mod-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.mod-info strong { font-size: 15px; }
.mod-info p { margin: 4px 0 0; font-size: 13px; }
.mod-action { display: flex; align-items: center; gap: 10px; flex: none; }
.mod-action form { display: inline; }

/* Usuarios / empleados del negocio (panel super-admin) */
.user-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.user-card { padding: 16px 18px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius); }
.user-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.user-head strong { font-size: 15px; margin-right: 8px; }
.user-card form { margin: 0; }
.perm-grid { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 12px; }
.perm-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.perm-check input { width: auto; }
.user-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.pw-reset { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.pw-reset input { flex: 1; }
.user-new { max-width: 520px; margin-top: 6px; }
.field-hint { display: block; margin-top: 5px; font-size: 12px; min-height: 14px; }
.field-hint.hint-ok { color: #2ecc71; }
.field-hint.hint-bad { color: #e74c3c; }

/* ===========================================================================
   Inventario
   =========================================================================== */
.head-actions { display: flex; gap: 8px; }

/* Select con el mismo look que los inputs */
.field select {
  width: 100%; font-family: var(--font-ui); font-size: 15px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink);
}
.field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Dos campos lado a lado */
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

/* La form-card del dashboard puede ser un poco más ancha que la de login */
.app-content .form-card { max-width: 520px; }

/* Zona de borrado (editar producto): separada y marcada como peligrosa. */
.danger-zone { max-width: 520px; margin: 18px 0 0; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid color-mix(in srgb, #c0392b 35%, var(--line)); border-radius: var(--radius);
  background: color-mix(in srgb, #c0392b 5%, var(--paper-2)); }
.danger-zone strong { font-size: 14px; }
.danger-zone .hint { margin: 3px 0 0; }
.danger-zone form { margin: 0; flex: none; }
/* Caja de resguardo (panel super-admin): mismo formato que danger-zone, neutro. */
.backup-box { max-width: 520px; margin: 6px 0 0; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); }
.backup-box strong { font-size: 14px; }
.backup-box .hint { margin: 3px 0 0; }
.backup-box .btn { flex: none; }
/* La compra de mercadería necesita más ancho para las líneas de producto. */
.app-content .form-card.is-wide { max-width: 1040px; }

/* Form en línea (agregar categoría) */
.inline-form { display: flex; gap: 8px; max-width: 520px; }
.inline-form input {
  flex: 1; font-family: var(--font-ui); font-size: 15px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink);
}
.inline-form input:focus { outline: none; border-color: var(--accent); }

.row-inactive { opacity: .55; }

/* Cabecera del movimiento */
.mov-head { display: flex; gap: 40px; margin-bottom: 20px; }
.mov-head span { display: block; font-size: 12px; color: var(--ink-2); }
.mov-head strong { font-size: 17px; }
.mov-head .big { font-size: 26px; font-family: var(--font-display); }

/* Badges de tipo de movimiento */
.badge-mov-in {
  color: color-mix(in srgb, var(--accent) 75%, var(--ink));
  background: color-mix(in srgb, var(--accent) 14%, var(--paper));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.badge-mov-out {
  color: color-mix(in srgb, #c0392b 70%, var(--ink));
  background: color-mix(in srgb, #c0392b 12%, var(--paper));
  border-color: color-mix(in srgb, #c0392b 40%, var(--line));
}
.badge-mov-adjust { color: var(--ink-2); background: var(--paper); }

/* ===========================================================================
   Caja (KPIs, dos columnas, arqueo)
   =========================================================================== */
.card-title { font-size: 16px; margin-bottom: 16px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.stat {
  padding: 14px 16px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.stat .label { font-size: 12px; color: var(--ink-2); }
.stat .value { font-size: 20px; font-family: var(--font-display); margin-top: 4px; }
.stat.accent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.stat.accent .value { color: var(--accent); }
/* Inversión (compra de mercadería): resta, pero no es un gasto consumido.
   La marcamos con un tono propio (índigo) para diferenciarla de los gastos. */
.stat.invest { border-color: color-mix(in srgb, #5a67d8 40%, var(--line));
  background: color-mix(in srgb, #5a67d8 7%, var(--paper-2)); }
.stat.invest .value { color: #5a67d8; }
.stat.invest .label { display: flex; align-items: center; gap: 6px; }
.tag-invest { font-size: 10px; text-transform: uppercase; letter-spacing: .03em;
  font-weight: 700; color: #5a67d8; background: color-mix(in srgb, #5a67d8 15%, transparent);
  padding: 1px 6px; border-radius: 999px; }
.invest-note { max-width: 760px; margin: -8px 0 22px; padding: 12px 14px;
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
  border-left: 3px solid #5a67d8; background: var(--paper-2); border-radius: var(--radius-sm); }
.stat .value.muted { color: var(--ink-2); font-size: 16px; }
.stat .stat-sub { margin-top: 4px; font-size: 11px; color: var(--ink-2); }

.two-col { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 28px; align-items: start; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

.diff-ok  { color: var(--accent); }
.diff-bad { color: #c0392b; }

/* ===========================================================================
   Métricas (gráfico SVG vanilla)
   =========================================================================== */
.chart-wrap {
  padding: 14px 8px 6px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chart { width: 100%; height: auto; display: block; }
.bar { fill: var(--accent); transition: fill .1s; }
.bar:hover { fill: color-mix(in srgb, var(--accent) 78%, var(--ink)); }
.bar-label { fill: var(--ink-2); font-size: 10px; font-family: var(--font-ui); }

/* Selector de período (Métricas) */
.period-tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 18px; }
.period-tab { padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.period-tab:hover { border-color: var(--accent); }
.period-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* Rango de fechas personalizado, al lado de las pestañas de período */
.period-range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-left: 6px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; }
.period-range.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--paper)); }
.period-range input[type=date] { padding: 5px 8px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font-size: 13px; }
@media (max-width: 620px) { .period-range { margin-left: 0; width: 100%; justify-content: flex-start; } }

/* Barra de filtros (Gastos) */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper); color: var(--ink); font-size: 13px; }
.filter-bar input { min-width: 180px; }

/* Buscador de ticket (Métricas → Movimientos) */
.ticket-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -2px 0 14px; }
.ticket-search input { padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font-size: 13px; min-width: 240px; }
/* Que "Anular" y "Devolución" tengan el mismo ancho (orden visual parejo). */
.mov-table .row-actions .btn-danger,
.mov-table .row-actions .btn-warning { min-width: 104px; }

/* Pantalla de devolución (elegir qué devolvió el cliente) */
.ret-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.ret-row { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.ret-row.is-done { opacity: .6; }
.ret-info strong { display: block; font-size: 14px; }
.ret-info small { color: var(--ink-2); font-size: 12px; }
.ret-qty { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ret-qty label { font-size: 12px; color: var(--ink-2); }
.ret-qty input { width: 72px; font-family: var(--font-ui); font-size: 15px; padding: 7px 9px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper-2); color: var(--ink); }
.ret-qty input::-webkit-outer-spin-button,
.ret-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ret-qty input { -moz-appearance: textfield; appearance: textfield; }
.ret-total { display: flex; align-items: baseline; justify-content: space-between;
  padding: 12px 2px; border-top: 1px solid var(--line); }
.ret-total strong { font-family: var(--font-display); font-size: 22px; color: var(--accent); }
.ret-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.ret-actions .btn-primary { width: auto; }

/* Desglose por categoría: barra horizontal proporcional */
.table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-cell { width: 45%; }
.hbar { display: block; height: 8px; border-radius: 999px; background: var(--accent);
  min-width: 2px; }

/* Config de pagos: campos de % y switch */
.pct-field { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.pct-field label { margin-bottom: 0; }
.pct-input { position: relative; width: 120px; }
.pct-input input { width: 100%; padding-right: 28px; text-align: right; }
.pct-sign { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-2); font-size: 14px; }

.switch { display: flex; gap: 12px; align-items: flex-start; margin: 18px 0 22px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; }
.switch input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.switch-text strong { display: block; font-size: 14px; }
.switch-text small { color: var(--ink-2); font-size: 12px; line-height: 1.4; }

/* ===========================================================================
   POS (punto de venta) — lista vertical de productos + carrito, estilo forrajería
   =========================================================================== */
.pos-open-info { align-self: center; }
/* Proporción tipo forrajería: ~60% productos / ~40% carrito */
.pos { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .pos { grid-template-columns: 1fr; } }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Columna de productos --- */
.pos-products-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pos-products-head .card-title { margin: 0; }

.free-panel { margin-bottom: 14px; padding: 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 10%, var(--paper)); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px; }
.free-panel input { width: 100%; font-family: var(--font-ui); font-size: 14px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
.free-panel .free-row { display: flex; gap: 8px; align-items: stretch; }
.free-panel .free-row #pos-free-price { flex: 1 1 auto; min-width: 0; }
.free-panel .free-row #pos-free-qty { flex: 0 0 64px; width: 64px; text-align: center; }
.free-panel .free-row .btn { flex: 0 0 auto; width: auto; white-space: nowrap; }

.pos-search { margin-bottom: 12px; }
.pos-search input { width: 100%; font-family: var(--font-ui); font-size: 15px;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); }
.pos-search input:focus { outline: none; border-color: var(--accent); }
/* Aviso del escaneo de código de barras (debajo del buscador) */
.pos-scan-msg { margin-top: 6px; padding: 6px 10px; font-size: 13px; font-weight: 600;
  border-radius: var(--radius-sm); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pos-scan-msg.is-error { color: #c0392b; background: color-mix(in srgb, #c0392b 12%, transparent); }

/* Oferta por cantidad: badge en la tarjeta de producto y tag en el carrito */
.pcard-offer { margin: 4px 0 0; font-size: 12px; font-weight: 700; color: #b8860b; }
.cart-offer { display: block; color: #b8860b; font-weight: 700; }
/* Form de producto: un poco más ancho para que la fila de oferta entre en una línea */
.app-content .form-card.product-form { max-width: 600px; }

/* Solapita de oferta (details/summary) en el alta/edición de producto */
.offer-box { margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper-2); }
.offer-box > summary { cursor: pointer; padding: 11px 14px; font-size: 14px; font-weight: 600;
  list-style: none; user-select: none; }
.offer-box > summary::-webkit-details-marker { display: none; }
.offer-box > summary::before { content: '▸ '; color: var(--ink-2); }
.offer-box[open] > summary::before { content: '▾ '; }
.offer-box[open] > summary { border-bottom: 1px solid var(--line); }
.offer-body { padding: 14px; }
.offer-body .hint { margin: 8px 0 0; }
/* Selector de tipo de oferta (combo / precio rebajado) */
.offer-mode { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.offer-mode-opt { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; flex: 1 1 200px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.offer-mode-opt:has(input:checked) { border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--paper)); }
.offer-mode-opt input { margin-top: 3px; accent-color: var(--accent); }
.offer-mode-opt span { display: flex; flex-direction: column; }
.offer-mode-opt strong { font-size: 13px; }
.offer-mode-opt small { font-size: 11px; color: var(--ink-2); }
.offer-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.offer-row input { width: 170px; font-family: var(--font-ui); font-size: 15px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); }
.offer-row input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.doc-offer { font-size: 11px; color: #b8860b; font-weight: 700; }

/* Lista vertical de tarjetas (cada una full-width) */
.pos-grid { display: flex; flex-direction: column; gap: 10px; }
.pcard { padding: 12px 14px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius); }
.pcard-name { font-size: 18px; font-weight: 700; }
.pmethods { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 8px; font-size: 15.5px; font-weight: 700; }
.pm-cash { color: #2ecc71; } .pm-transfer { color: #3498db; }
.pm-mp { color: #9b59b6; } .pm-card { color: #e74c3c; }
.pcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pcard-foot .stock { font-size: 14.5px; color: var(--ink-2); }
.pcard-ctrls { display: flex; align-items: center; gap: 6px; }
.pcard-qty { width: 56px; height: 34px; text-align: center; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }

.pos-pager { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 16px; }

/* --- Carrito --- */
.cart { position: sticky; top: 16px; min-width: 0;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
.cart .card-title { margin-bottom: 4px; }
.cart-items { display: flex; flex-direction: column; gap: 10px; max-height: 42vh; overflow-y: auto; padding-right: 2px; }
.cart-empty { color: var(--ink-2); font-size: 16px; text-align: center; padding: 16px 0; }
.cart-row { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.cart-name { font-size: 19px; font-weight: 600; line-height: 1.3; }
.cart-name small { display: block; color: var(--ink-2); font-size: 15.5px; font-weight: 400; margin-top: 2px; }
.cart-qty { display: flex; align-items: center; gap: 6px; }
.cart-qty span { font-size: 19px; font-weight: 700; min-width: 22px; text-align: center; }
.qty-btn { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper-2); color: var(--ink); cursor: pointer; font-size: 18px; line-height: 1; }
.qty-btn:hover { border-color: var(--accent); color: var(--accent); }
.cart-line { font-size: 19px; font-weight: 700; min-width: 74px; text-align: right; }
.cart-del { border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 18px; }
.cart-del:hover { color: #c0392b; }

/* Footer del carrito */
.cart-footer { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.cart-total-row { display: flex; justify-content: space-between; align-items: baseline; }
.cart-total { font-family: var(--font-display); font-size: 26px; color: var(--accent); }
.cart-method .label { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.method-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.method-tab { padding: 9px 8px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink-2); cursor: pointer; }
.method-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.desc-panel { display: flex; flex-direction: column; gap: 8px;
  margin-top: 6px; padding: 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--paper); }
.desc-mode-label { font-size: 12px; font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .04em; }
.desc-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.desc-mode-btn { padding: 10px 8px; font-size: 14px; font-weight: 700;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper-2); color: var(--ink-2); cursor: pointer; }
.desc-mode-btn:hover { border-color: var(--accent); color: var(--ink); }
.desc-mode-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.desc-input-row { display: flex; align-items: stretch; }
.desc-affix { display: flex; align-items: center; justify-content: center; min-width: 40px;
  font-size: 17px; font-weight: 700; color: var(--ink-2);
  border: 1px solid var(--line); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--paper-2); }
.desc-panel input { width: 100%; font-family: var(--font-ui); font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); }
.desc-input-row input { flex: 1; width: auto; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.desc-hint { font-size: 12.5px; line-height: 1.35; }
/* Vuelto (modal de cobro en efectivo): "Paga con" + resultado. */
.vuelto-input { display: flex; align-items: stretch; flex: 1; max-width: 180px; }
.vuelto-input span { display: flex; align-items: center; justify-content: center; min-width: 34px;
  font-size: 16px; font-weight: 700; color: var(--ink-2);
  border: 1px solid var(--line); border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--paper-2); }
.vuelto-input input { flex: 1; width: auto; font-family: var(--font-ui); font-size: 15px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--paper); color: var(--ink); text-align: left; }
/* Sin las flechitas de incremento del input number. */
.vuelto-input input::-webkit-outer-spin-button,
.vuelto-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.vuelto-input input { -moz-appearance: textfield; appearance: textfield; }
.vuelto-result { font-size: 15px; font-weight: 700; text-align: right; }
.vuelto-result.is-ok { color: #2ecc71; }
.vuelto-result.is-short { color: #e74c3c; }
/* Modal de cobro en efectivo */
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(0, 0, 0, .5); }
.modal-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
  padding: 20px; background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-card .card-title { margin: 0; }
.modal-total-row { display: flex; align-items: baseline; justify-content: space-between; }
.modal-total-row strong { font-family: var(--font-display); font-size: 22px; color: var(--accent); }
.modal-card > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.modal-paga-row { display: flex; align-items: stretch; gap: 8px; }
.modal-paga-row .vuelto-input { max-width: none; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.cart-actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-full { width: 100%; }

/* Botones de acción con los colores del POS */
.btn-warning { background: #f39c12; color: #1a1a18; border-color: #f39c12; }
.btn-warning:hover { background: #d68910; border-color: #d68910; }
.btn-info { background: #3498db; color: #fff; border-color: #3498db; }
.btn-info:hover { filter: brightness(1.05); }
.cart-footer .btn-danger { background: #e74c3c; color: #fff; border-color: #e74c3c; }
.cart-footer .btn-danger:hover { background: #c0392b; border-color: #c0392b; }

/* ===========================================================================
   Documentos imprimibles (presupuesto / ticket)
   =========================================================================== */
.print-toolbar { display: flex; gap: 8px; padding: 14px 20px;
  border-bottom: 1px solid var(--line); background: var(--paper-2); }

.doc { max-width: 720px; margin: 24px auto; padding: 32px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.doc-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 22px; }
.doc-brand svg { color: var(--accent); }
.doc-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.doc-contact { font-family: var(--font); font-size: 12px; color: var(--ink-2); }
.doc-meta { text-align: right; color: var(--ink-2); font-size: 14px; }
.doc-meta strong { font-family: var(--font-display); font-size: 20px; color: var(--ink); }
.doc-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 18px; }
.doc-table th { text-align: left; padding: 8px; border-bottom: 2px solid var(--line);
  color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.doc-table td { padding: 8px; border-bottom: 1px solid var(--line); }
.doc-table th:nth-child(n+2), .doc-table td:nth-child(n+2) { text-align: right; }
.doc-totals { margin-left: auto; max-width: 300px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.doc-totals > div { display: flex; justify-content: space-between; }
.doc-total { border-top: 1px solid var(--line); padding-top: 8px;
  font-family: var(--font-display); font-size: 20px; }
.doc-foot { margin-top: 28px; color: var(--ink-2); font-size: 12px; }

.ticket { max-width: 320px; margin: 24px auto; padding: 20px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; }
.ticket-brand { font-family: var(--font-display); font-size: 18px; text-align: center; }
.ticket-contact { text-align: center; color: var(--ink-2); font-size: 11px; }
.ticket-meta { text-align: center; color: var(--ink-2); font-size: 12px; }
.ticket hr { border: 0; border-top: 1px dashed var(--line); margin: 10px 0; }
.ticket-line { display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; font-size: 13px; margin: 3px 0; }
/* El nombre usa el espacio disponible y hace wrap; el importe no se parte. */
.ticket-line > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ticket-line > span:last-child { flex-shrink: 0; white-space: nowrap; text-align: right; }
.ticket-total { display: flex; justify-content: space-between; margin-top: 8px;
  font-family: var(--font-display); font-size: 18px; }
/* Renglones bajo cada producto (promo / precio unitario): chicos, atenuados, con sangría. */
.ticket-promo, .ticket-unit { font-size: 11px; color: var(--ink-2); margin: 0 0 4px; padding-left: 12px; }
/* Total ahorrado al pie: destacado en verde, como un beneficio. */
.ticket-saved { font-weight: 700; color: #2ecc71; }
.ticket-foot { text-align: center; color: var(--ink-2); font-size: 12px; margin-top: 12px; }
.ticket-legal { text-align: center; color: var(--ink-2); font-size: 10px; margin: 0; }

/* Pantalla del ticket recién emitido: la ZONA de acciones (no el ticket). */
.ticket-page { max-width: 360px; margin: 0 auto; padding: 28px 16px 48px;
  display: flex; flex-direction: column; gap: 20px; }
.ticket-page .ticket { margin: 0 auto; }
.ticket-actions { display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 20px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
.ticket-status { font-family: var(--font-display); font-size: 19px; font-weight: 700; color: #2ecc71; }
.ticket-status-sub { margin: 0; color: var(--ink-2); font-size: 13px; text-align: center; }
.ticket-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 12px; }
.ticket-btns .btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .ticket-page { padding: 0; max-width: none; gap: 0; }
  .doc, .ticket { border: 0; margin: 0; max-width: none; background: #fff; }
}

/* Responsive: en pantallas chicas el sidebar pasa arriba en horizontal */
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; gap: 8px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .sidebar-brand { padding: 0 8px 0 4px; }
  .nav { flex-direction: row; gap: 2px; }
  .nav-item .soon { display: none; }
  .sidebar-foot { display: none; }
}
