/* ============================================
   ALTERNATIVE CARE — Manufacturing OS
   Diseño "Híbrido": menú grafito + contenido claro, dorado del logo como
   marca y esmeralda para las acciones. Tarjetas con relieve, tipografía sin
   cursivas pensada para leer tablas y montos todo el día.

   Tema claro por defecto; tema oscuro con <html data-theme="dark">.
   Los nombres de las variables se conservan: las pantallas los usan en
   estilos en línea (var(--ink-3), var(--accent-soft), etc.).
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Sora:wght@500;600;700&display=swap');

:root {
  color-scheme: light;

  /* === FONDOS === */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --surface-3: #e9eef4;
  --surface-grad: #fbfcfd;      /* base del degradado de las tarjetas */

  /* === BORDES === */
  --border: #dde3eb;
  --border-strong: #c2cbd7;
  --border-light: #edf1f5;

  /* === TINTAS === */
  --ink: #0d141c;
  --ink-1: #0d141c;
  --ink-2: #2a3542;
  --ink-3: #536071;             /* 5.9:1 sobre blanco */
  --ink-4: #667385;             /* 4.8:1 sobre blanco */

  /* === DORADO (marca, color del logo) === */
  --gold: #e4b520;
  --gold-bright: #f2c94c;
  --gold-deep: #85620a;         /* texto dorado: 5.1:1 sobre gold-soft */
  --gold-soft: #fdf6dd;
  --gold-tint: #f8e7a8;

  /* === ACENTO (acciones y positivos) === */
  --accent: #059669;
  --accent-soft: #e3f7ef;
  --accent-ink: #046c4e;
  --accent-bright: #12b886;

  /* === SEMÁNTICOS === */
  /* Avisos: colores vivos y saturados (no pastel) para que llamen la atención.
     *-solid es el relleno de las etiquetas de alarma (Vencida, Urgente…). */
  --danger: #dc1f26;
  --danger-soft: #ffe0de;
  --danger-ink: #a50e16;
  --danger-border: #ff8a82;
  --danger-solid: #e5252c;
  --warning: #c2410c;
  --warning-soft: #ffe7b8;
  --warning-ink: #8a3200;
  --warning-border: #ffb11f;
  --warning-solid: #ffa50a;
  --success: #047a45;
  --success-soft: #cdf7df;
  --success-ink: #03603a;
  --success-border: #4fd68f;
  --success-solid: #0fb06a;
  --info: #1556e0;
  --info-soft: #d9e6ff;
  --info-ink: #0f40a8;
  --info-border: #7da9ff;
  --info-solid: #2563eb;
  --violet: #6941c6;
  --violet-soft: #f1ecfd;

  /* === COMPATIBILIDAD === */
  --primary: var(--ink);
  --primary-soft: var(--surface-2);

  /* === MENÚ LATERAL (siempre oscuro) === */
  --side-bg: #0a0f15;
  --side-bg-2: #101923;
  --side-border: #1b2632;
  --side-ink: #c9d3de;
  --side-ink-dim: #7f8c9c;
  --side-hover: rgba(255, 255, 255, 0.05);
  --side-active: rgba(228, 181, 32, 0.13);

  /* === TIPOGRAFÍA === */
  --font-display: 'Sora', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-ui: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Códigos y montos: la misma letra legible del sistema, con números de ancho
     fijo (tabular) para que las columnas sigan alineadas. Sin "máquina de escribir". */
  --font-mono: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* === RADIOS === */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* === SOMBRAS (relieve) === */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 16px -4px rgba(16, 24, 40, 0.10);
  --shadow-3: 0 2px 4px rgba(16, 24, 40, 0.06), 0 16px 32px -8px rgba(16, 24, 40, 0.18);
  --shadow-4: 0 32px 80px -16px rgba(16, 24, 40, 0.35), 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-gold: 0 6px 20px -4px rgba(228, 181, 32, 0.45);
  --shadow-card:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(16, 24, 40, 0.05),
    0 12px 28px -14px rgba(16, 24, 40, 0.22);
  --shadow-card-hover:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 2px 4px rgba(16, 24, 40, 0.06),
    0 22px 40px -16px rgba(16, 24, 40, 0.30);

  /* === LAYOUT === */
  --sidebar-w: 264px;
  --topbar-h: 68px;
  --bottom-nav-h: 64px;

  /* === MOVIMIENTO === */
  --t-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 360ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 380ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

/* ============== TEMA OSCURO ============== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #090d12;
  --surface: #121a23;
  --surface-2: #17212c;
  --surface-3: #1e2a37;
  --surface-grad: #0f161e;

  --border: #233041;
  --border-strong: #33455a;
  --border-light: #1a2430;

  --ink: #e9eef4;
  --ink-1: #e9eef4;
  --ink-2: #c5cfda;
  --ink-3: #96a3b4;
  --ink-4: #8492a3;

  --gold-deep: #f2c94c;
  --gold-soft: #2a2209;
  --gold-tint: #3d310c;

  --accent: #34d399;
  --accent-soft: #0d2a20;
  --accent-ink: #6ee7b7;

  --danger: #ff5a52;
  --danger-soft: #4a1517;
  --danger-ink: #ffb4ae;
  --danger-border: #b42126;
  --danger-solid: #ef3a40;
  --warning: #ffb020;
  --warning-soft: #4a3008;
  --warning-ink: #ffd27a;
  --warning-border: #c27a07;
  --warning-solid: #ffab14;
  --success: #3ddc8a;
  --success-soft: #0e3b27;
  --success-ink: #8ef0bd;
  --success-border: #13804f;
  --success-solid: #19c27a;
  --info: #7aa7ff;
  --info-soft: #132d5c;
  --info-ink: #bcd3ff;
  --info-border: #2f63d8;
  --info-solid: #3b7bff;
  --violet: #b692f6;
  --violet-soft: #221a3a;

  --side-bg: #070a0e;
  --side-bg-2: #0c121a;
  --side-border: #18212c;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 18px -6px rgba(0, 0, 0, 0.55);
  --shadow-3: 0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 36px -10px rgba(0, 0, 0, 0.65);
  --shadow-4: 0 32px 80px -16px rgba(0, 0, 0, 0.8);
  --shadow-card:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 1px 2px rgba(0, 0, 0, 0.45),
    0 14px 30px -14px rgba(0, 0, 0, 0.75);
  --shadow-card-hover:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 24px 44px -16px rgba(0, 0, 0, 0.85);
}

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

html, body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

/* Fondo con un brillo sutil de marca: le da profundidad sin distraer */
body {
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(228, 181, 32, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(5, 150, 105, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* Números alineados en columnas: montos, tasas y cantidades */
table, .kpi-value, .td-mono, .text-mono, .fx-pill .value, input[type="number"],
[style*="--font-mono"] {
  font-variant-numeric: tabular-nums;
}

::selection {
  background: var(--gold-tint);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ============== LAYOUT ============== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
@media (max-width: 1100px) {
  .app { grid-template-columns: 232px minmax(0, 1fr); }
}

/* ============== MENÚ LATERAL ============== */

.sidebar {
  background:
    radial-gradient(420px 260px at 0% 0%, rgba(228, 181, 32, 0.10), transparent 70%),
    linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  border-right: 1px solid var(--side-border);
  padding: 20px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  color: var(--side-ink);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; border: none; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }

.brand {
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(145deg, #1c2733, #0d141c);
  border: 1px solid rgba(228, 181, 32, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 18px -8px rgba(228, 181, 32, 0.55);
}
.brand-logo img { width: 30px; height: auto; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-mark {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.1;
}
.brand-mark span { color: var(--gold-bright); font-weight: 600; }
.brand-sub {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--side-ink-dim);
  font-weight: 600;
  margin-top: 3px;
}

.mode-selector {
  margin: 4px 4px 18px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  display: flex;
  gap: 4px;
}
.mode-selector.single {
  background: rgba(228, 181, 32, 0.07);
  border-color: rgba(228, 181, 32, 0.22);
}
.mode-option {
  flex: 1;
  padding: 8px 6px;
  border-radius: 9px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  color: var(--side-ink-dim);
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.mode-selector.single .mode-option { cursor: default; color: var(--side-ink); }
.mode-option:hover:not(.active) { background: rgba(255, 255, 255, 0.06); color: #fff; }
.mode-option.active {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1404;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 12px -4px rgba(228, 181, 32, 0.7);
}
.mode-icon { font-size: 14px; line-height: 1; display: inline-flex; }
.mode-svg { width: 16px; height: 16px; }
.mode-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.nav-group { margin-bottom: 16px; }
.nav-group-title {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--side-ink-dim);
  font-weight: 700;
  padding: 0 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin: 1px 0;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--side-ink);
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--side-hover); color: #ffffff; }
.nav-item.active {
  background: var(--side-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(228, 181, 32, 0.22);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(228, 181, 32, 0.8);
}
.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--side-ink-dim);
  transition: color var(--t-fast);
}
.nav-item:hover .nav-icon { color: var(--side-ink); }
.nav-item.active .nav-icon { color: var(--gold-bright); }
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
}
.nav-item.active .nav-dot { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  min-width: 0;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: #1a1404;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--side-ink-dim); }
.logout-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--side-ink);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.logout-btn:hover { background: rgba(249, 112, 102, 0.12); border-color: rgba(249, 112, 102, 0.35); color: #fda29b; }

/* ============== BARRA SUPERIOR ============== */

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title-wrap { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--gold-soft);
  white-space: nowrap;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.fx-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.fx-pill:hover { border-color: var(--gold); box-shadow: var(--shadow-gold); }
.fx-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-bright) 22%, transparent);
}
.fx-pill .label { color: var(--ink-3); font-size: 11.5px; font-weight: 600; }
.fx-pill .value { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }

/* Botón de tema claro/oscuro */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.theme-toggle:hover { color: var(--gold-deep); border-color: var(--gold); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.content {
  padding: 30px 32px 40px;
  max-width: 1600px;
  width: 100%;
  min-width: 0;
  animation: pageIn 0.35s ease both;
}
/* Solo opacidad: un transform aquí convierte .content en el marco de referencia
   de los elementos position:fixed (los buscadores de productos de Ventas y
   Compras) y sus listas aparecían desplazadas o tapadas. */
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
body.rendered .content { animation: none; }
@media (max-width: 1100px) {
  .content { padding: 24px 20px 36px; }
}

/* ============== PERMISOS GLOBALES ==============
   Cuando el usuario actual no puede editar/eliminar en este módulo,
   `auth.applyPermissionClasses()` agrega `.no-edit` o `.no-delete` al <body>. */
body.no-edit [title="Editar"],
body.no-edit [onclick*="editItem("],
body.no-edit [data-perm="edit"] {
  display: none !important;
}
body.no-delete [title="Eliminar"],
body.no-delete [onclick*="deleteItem("],
body.no-delete [data-perm="delete"] {
  display: none !important;
}

/* ============== TIPOGRAFÍA ============== */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-style: normal;
}
h2 { font-size: 26px; }
h3 { font-size: 18px; font-weight: 600; }
.section-title {
  font-family: var(--font-ui);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 12px;
}
.divider-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 14px;
}
.divider-section::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
.divider-section .section-title { margin-bottom: 0; white-space: nowrap; }

/* Sin cursivas en ninguna parte del sistema */
em, i, [style*="italic"] { font-style: normal !important; }

/* ============== TARJETAS (con relieve) ============== */

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-grad) 100%);
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--t-base), transform var(--t-base);
  min-width: 0;
}
/* Tarjeta que contiene directamente una tabla → scroll horizontal */
.card:has(> table) {
  overflow-x: auto;
  overflow-y: hidden;
}
.card:has(> table)::-webkit-scrollbar { height: 10px; }
.card:has(> table)::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--surface); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Rejillas de dos columnas escritas en la pantalla (p. ej. listas del Inicio):
     en pantallas medianas cada lista necesita todo el ancho */
  .grid[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
}

/* ============== KPI (cada tarjeta con su propio color) ============== */

.kpi {
  --kpi-accent: var(--gold);
  --kpi-soft: var(--gold-soft);
  --kpi-ink: var(--gold-deep);
  background:
    radial-gradient(160px 120px at 100% 0%, color-mix(in srgb, var(--kpi-accent) 16%, transparent), transparent 70%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-grad) 100%);
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: var(--r-lg);
  padding: 20px 20px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  min-width: 0;
  transition: box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base);
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--kpi-accent), color-mix(in srgb, var(--kpi-accent) 30%, transparent));
}
.grid > .kpi:nth-child(5n+2), .kpi.kpi-green  { --kpi-accent: var(--accent-bright); --kpi-soft: var(--accent-soft); --kpi-ink: var(--accent-ink); }
.grid > .kpi:nth-child(5n+3), .kpi.kpi-blue   { --kpi-accent: #3b82f6; --kpi-soft: var(--info-soft); --kpi-ink: var(--info-ink); }
.grid > .kpi:nth-child(5n+4), .kpi.kpi-violet { --kpi-accent: #8b5cf6; --kpi-soft: var(--violet-soft); --kpi-ink: var(--violet); }
.grid > .kpi:nth-child(5n+5), .kpi.kpi-coral  { --kpi-accent: #f97316; --kpi-soft: var(--warning-soft); --kpi-ink: var(--warning-ink); }

.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-card-hover);
  border-color: color-mix(in srgb, var(--kpi-accent) 45%, var(--border));
}
.kpi-clickable:active { transform: translateY(-1px); }
.kpi-clickable:hover .kpi-action { color: var(--kpi-ink); }
.kpi-action {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  letter-spacing: 0.02em;
  transition: color var(--t-base);
}
.kpi-label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 10px;
  padding-right: 40px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.kpi-value-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 8px;
  font-family: var(--font-ui);
}
.kpi-mark {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--kpi-soft);
  color: var(--kpi-ink);
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--kpi-accent) 30%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ============== BOTONES ============== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.2;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Acción principal: esmeralda con relieve */
.btn-primary {
  background: linear-gradient(180deg, #14c08d 0%, #0ca678 100%);
  color: #03241a;
  border-color: #0a956b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 2px rgba(16, 24, 40, 0.1), 0 6px 14px -6px rgba(12, 166, 120, 0.7);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #19cc97 0%, #0db482 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 4px rgba(16, 24, 40, 0.12), 0 10px 20px -8px rgba(12, 166, 120, 0.8);
}

/* Acción de marca: dorado del logo */
.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: #1a1404;
  border-color: #c99a12;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 1px 2px rgba(16, 24, 40, 0.1), var(--shadow-gold);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.04); }

.btn-secondary {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  color: var(--ink);
  border-color: var(--border);
  border-bottom-color: var(--border-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), var(--shadow-1);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow-2); }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }

.btn-danger {
  background: linear-gradient(180deg, #ef4b3f 0%, #d92d20 100%);
  color: #ffffff;
  border-color: #b42318;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 6px 14px -6px rgba(217, 45, 32, 0.6);
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }

.btn-warning {
  background: linear-gradient(180deg, #fdb022 0%, #f79009 100%);
  color: #2b1503;
  border-color: #dc6803;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 14px -6px rgba(247, 144, 9, 0.6);
}
.btn-warning:hover:not(:disabled) { filter: brightness(1.04); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 10px; }
.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  color: var(--ink-3);
  border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border); }

/* ============== FORMULARIOS ============== */

.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}
.field-hint { font-size: 12px; color: var(--ink-3); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  min-height: 42px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.05);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), inset 0 1px 2px rgba(16, 24, 40, 0.05);
}
.input[disabled], .select[disabled], .textarea[disabled] {
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: not-allowed;
}
.textarea { min-height: 88px; resize: vertical; font-family: var(--font-ui); }
.select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667385' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.checkbox-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.checkbox-row input { width: 18px; height: 18px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ============== TABLAS ============== */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: var(--r-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}
.table-wrap::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--surface); }

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar { height: 10px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--surface); }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.search-box {
  position: relative;
  flex: 1;
  max-width: 380px;
  min-width: 180px;
}
.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 13.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.search-box input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th[onclick] { cursor: pointer; user-select: none; }
thead th[onclick]:hover { color: var(--ink); }
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--ink-2);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: color-mix(in srgb, var(--gold) 6%, var(--surface)); }
.td-mono { font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink-2); }
.td-strong { font-weight: 700; color: var(--ink); }
.td-muted { color: var(--ink-3); }
.td-actions { text-align: right; white-space: nowrap; }
.td-actions .btn-icon { color: var(--ink-3); }
.td-actions .btn-icon:hover { color: var(--ink); }

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-3);
}
.empty-state-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--gold-deep);
  background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  box-shadow: var(--shadow-card);
}
.empty-state-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.empty-state-text { font-size: 13.5px; max-width: 380px; margin: 0 auto; }

/* ============== BADGES ============== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-2);
  border: 1px solid transparent;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.badge-success, .badge-paid, .badge-active, .badge-move-in {
  background: var(--success-soft); color: var(--success-ink); border-color: color-mix(in srgb, var(--success-border) 70%, transparent);
}
.badge-partial, .badge-move-reserve {
  background: var(--warning-soft); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning-border) 70%, transparent);
}
.badge-move-out {
  background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger-border) 70%, transparent);
}
/* Alarmas: relleno sólido y vivo para que se vean de lejos */
.badge-danger, .badge-overdue {
  background: var(--danger-solid); color: #ffffff; border-color: transparent;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--danger-solid) 70%, transparent);
}
.badge-warning {
  background: var(--warning-solid); color: #2b1400; border-color: transparent;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--warning-solid) 70%, transparent);
}
.badge-danger::before, .badge-overdue::before, .badge-warning::before { opacity: 1; }
.badge-accent, .badge-invoice {
  background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 22%, transparent);
}
.badge-note, .badge-order, .badge-move-adjustment {
  background: var(--info-soft); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 22%, transparent);
}
.badge-quote {
  background: var(--violet-soft); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 22%, transparent);
}
.badge-plain {
  background: transparent; color: var(--ink-3); border-color: var(--border);
}
.badge-plain::before { display: none; }
.badge-cancelled, .badge-inactive {
  background: var(--surface-3); color: var(--ink-4); border-color: var(--border); text-decoration: line-through;
}
.badge-inactive { text-decoration: none; }
.badge-mp       { background: var(--gold-soft); color: var(--gold-deep); }
.badge-envase   { background: var(--info-soft); color: var(--info-ink); }
.badge-tapa     { background: var(--violet-soft); color: var(--violet); }
.badge-etiqueta { background: var(--accent-soft); color: var(--accent-ink); }
.badge-caja     { background: var(--warning-soft); color: var(--warning-ink); }
.badge-otro     { background: var(--surface-3); color: var(--ink-3); }

/* ============== MODALES ============== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 16, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn 0.18s ease;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 660px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-4);
  animation: slideUp var(--t-spring);
  border: 1px solid var(--border);
}
.modal-lg { max-width: 900px; }
.modal-header {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background:
    radial-gradient(320px 120px at 0% 0%, color-mix(in srgb, var(--gold) 10%, transparent), transparent 70%),
    var(--surface);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.modal-subtitle { font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.modal-body {
  padding: 22px 26px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding: 14px 26px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-2);
  flex-wrap: wrap;
}
.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ============== TOASTS ============== */

.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: rgba(13, 20, 28, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #eef2f6;
  padding: 13px 18px 13px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn var(--t-spring);
  min-width: 260px;
  max-width: 420px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 4px solid var(--gold);
}
.toast-success { border-left-color: #12b886; }
.toast-error { border-left-color: #ff3b3b; background: rgba(60, 12, 14, 0.95); }
.toast-warning { border-left-color: #ffab14; background: rgba(54, 34, 4, 0.95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ============== LOGIN ============== */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--bg);
}
.login-art {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(700px 420px at 20% 10%, rgba(228, 181, 32, 0.22), transparent 60%),
    radial-gradient(600px 400px at 90% 90%, rgba(18, 184, 134, 0.16), transparent 60%),
    linear-gradient(160deg, #0a0f15 0%, #111a24 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  padding: 56px clamp(32px, 7vw, 96px);
}
.login-art > * { position: relative; z-index: 1; max-width: 480px; }
.login-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.login-art::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(228, 181, 32, 0.18);
  box-shadow: 0 0 0 60px rgba(228, 181, 32, 0.03), 0 0 0 120px rgba(228, 181, 32, 0.02);
}
.login-art-content { position: relative; z-index: 1; max-width: 460px; }
.login-art-logo-img {
  width: 132px;
  height: auto;
  display: block;
  margin-bottom: 28px;
  filter: drop-shadow(0 18px 40px rgba(228, 181, 32, 0.35));
}
.login-art-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-art-logo::before { display: none; }
.login-art-logo svg { width: 40px; height: 40px; }
.login-art-mark {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: #ffffff;
}
.login-art-mark span { color: var(--gold-bright); }
.login-art-tag {
  margin-top: 14px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
}
.login-quote {
  margin-top: 28px;
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.82);
  font-style: normal;
  padding-left: 16px;
  border-left: 3px solid var(--gold);
}
.login-quote::before { display: none; }
.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
}
.login-form {
  width: 100%;
  max-width: 400px;
  padding: 34px 30px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-grad) 100%);
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  box-shadow: var(--shadow-card-hover);
}
.login-form h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 6px;
  font-style: normal;
}
.login-form .lead { color: var(--ink-3); font-size: 14px; margin-bottom: 26px; }
.login-roles {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.login-roles strong { color: var(--ink-2); }
.role-chip {
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.role-chip:hover { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-deep); }

/* ============== ALERTAS DEL INICIO ============== */

.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.alert-card {
  --al: var(--warning-solid);
  --al-soft: var(--warning-soft);
  --al-ink: var(--warning-ink);
  --al-on: #2b1400;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(260px 160px at 0% 0%, color-mix(in srgb, var(--al) 24%, transparent), transparent 72%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-grad) 100%);
  border: 1px solid color-mix(in srgb, var(--al) 45%, var(--border));
  border-bottom-color: color-mix(in srgb, var(--al) 60%, var(--border-strong));
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card), 0 10px 26px -14px color-mix(in srgb, var(--al) 70%, transparent);
  padding: 16px 16px 14px 20px;
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.alert-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 5px;
  border-radius: 0 5px 5px 0;
  background: var(--al);
  box-shadow: 0 0 14px color-mix(in srgb, var(--al) 60%, transparent);
}
.alert-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card-hover); }
.alert-danger { --al: var(--danger-solid); --al-soft: var(--danger-soft); --al-ink: var(--danger-ink); --al-on: #ffffff; }
.alert-info   { --al: var(--info-solid); --al-soft: var(--info-soft); --al-ink: var(--info-ink); --al-on: #ffffff; }

.alert-head { display: flex; align-items: flex-start; gap: 12px; }
.alert-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--al-on);
  background: linear-gradient(160deg, color-mix(in srgb, var(--al) 80%, #ffffff), var(--al));
  border: 1px solid color-mix(in srgb, var(--al) 70%, #000000);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 14px -6px var(--al);
}
.alert-icon svg { width: 20px; height: 20px; stroke-width: 2.4; }
.alert-title-wrap { flex: 1; min-width: 0; }
.alert-level {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--al-on);
  background: var(--al);
  padding: 2px 8px;
  border-radius: 99px;
  margin-bottom: 4px;
  margin-bottom: 2px;
}
.alert-title { font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.35; }
.alert-go {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.alert-go svg { width: 18px; height: 18px; }
.alert-go:hover { color: var(--al-ink); border-color: var(--al); background: var(--al-soft); transform: translateX(2px); }

.alert-items {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.alert-items li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  min-width: 0;
}
.alert-code {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--al-ink);
  background: var(--al-soft);
  border: 1px solid color-mix(in srgb, var(--al) 55%, transparent);
  padding: 2px 9px;
  border-radius: 99px;
}
.alert-detail {
  font-size: 13px;
  color: var(--ink-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.alert-items li.alert-more {
  background: transparent;
  border: 1px dashed var(--border);
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
}

@media (max-width: 760px) {
  .alerts-grid { gap: 10px; }
  .alert-card { padding: 14px 12px 12px 16px; }
  .alert-detail { white-space: normal; }
  .alert-items li { align-items: flex-start; }
}

/* ============== ACTION BAR ============== */

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.action-bar-left { display: flex; align-items: baseline; gap: 14px; min-width: 0; flex-wrap: wrap; }
.action-bar-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  font-style: normal;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.action-bar-count {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--surface-3);
}
.action-bar-right { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============== UTILIDADES ============== */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: 12px; align-items: center; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--ink-3); }
.text-strong { font-weight: 700; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* ============== LIST ROWS ============== */

.list-row {
  display: grid;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
  transition: background var(--t-fast);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row-title { font-weight: 700; color: var(--ink); }
.list-row-meta { font-size: 12.5px; color: var(--ink-3); }

/* ============================================================================
   ACCESIBILIDAD
   ============================================================================ */

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
a:focus-visible,
.nav-item:focus-visible,
.btn-icon:focus-visible,
.modal-close:focus-visible,
.kpi-clickable:focus-visible,
[tabindex]:focus-visible,
thead th[onclick]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.sidebar a:focus-visible,
.sidebar button:focus-visible {
  outline-color: var(--gold-bright);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .kpi-clickable:hover { transform: none; }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 300;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--gold-bright);
  border-radius: 0 0 var(--r-md) 0;
  font-weight: 700;
  font-size: 13px;
}
.skip-link:focus { left: 0; }

/* ============================================================================
   TELÉFONO — se comporta como una app
   ============================================================================
   - Barra de navegación fija abajo (Inicio, módulos principales, Más)
   - "Más" abre el menú lateral como cajón
   - Las tablas se convierten en tarjetas (ui.js etiqueta cada celda)
   - Los modales suben desde abajo como hojas, a pantalla casi completa
   - Campos de 16 px para que iOS no haga zoom al escribir
   ============================================================================ */

.sidebar-toggle { display: none; }
.bottom-nav { display: none; }
.topbar-brand { display: none; }

@media (max-width: 760px) {
  html, body { font-size: 15px; }
  body { background-attachment: scroll; }

  .app { grid-template-columns: minmax(0, 1fr); }
  /* Nada dentro del contenido puede ensanchar la página (empujaría la barra inferior) */
  .main { overflow-x: clip; }

  /* Pestañas de las pantallas (fila de botones con subrayado): deslizables */
  div:has(> button.btn-ghost[style*="border-bottom:2px"]) {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }
  div:has(> button.btn-ghost[style*="border-bottom:2px"])::-webkit-scrollbar { display: none; }
  div:has(> button.btn-ghost[style*="border-bottom:2px"]) > button { flex-shrink: 0; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 286px;
    max-width: 86vw;
    z-index: 130;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform var(--t-slow);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
  }
  .sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(7, 11, 16, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 125;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base);
  }
  .sidebar-scrim.open { opacity: 1; pointer-events: auto; }

  /* Barra superior compacta, estilo app */
  .topbar {
    height: auto;
    min-height: 58px;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
    gap: 8px;
  }
  .sidebar-toggle { display: none; }
  .topbar-brand {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    flex-shrink: 0;
    background: linear-gradient(145deg, #1c2733, #0d141c);
    border: 1px solid rgba(228, 181, 32, 0.3);
  }
  .topbar-brand img { width: 22px; height: auto; }
  .page-title-wrap { gap: 10px; }
  .page-eyebrow { display: none; }
  .page-title { font-size: 18px; }
  .fx-pill { padding: 6px 10px; }
  .fx-pill .label { display: none; }
  .theme-toggle { width: 36px; height: 36px; border-radius: 11px; }

  .content {
    padding: 16px 14px calc(var(--bottom-nav-h) + 28px + env(safe-area-inset-bottom));
  }

  /* Barra de navegación inferior */
  .bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    height: var(--bottom-nav-h);
    padding: 6px;
    z-index: 90;
    border-radius: 20px;
    background: rgba(10, 15, 21, 0.92);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 14px;
    color: #8d9aab;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    min-width: 0;
    transition: color var(--t-fast), background var(--t-fast);
  }
  .bottom-nav-item svg { width: 22px; height: 22px; }
  .bottom-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .bottom-nav-item.active { color: #1a1404; background: linear-gradient(180deg, var(--gold-bright), var(--gold)); box-shadow: 0 6px 16px -6px rgba(228, 181, 32, 0.8); }
  .bottom-nav-item:active { transform: scale(0.95); }

  /* Rejillas a una columna; los KPI en dos para aprovechar el ancho */
  .grid-2, .grid-3, .form-grid-2, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid > .kpi { padding: 14px 14px 12px; }
  .kpi-label { font-size: 10.5px; padding-right: 30px; margin-bottom: 6px; }
  .kpi-value { font-size: 22px; }
  .kpi-value-sub { font-size: 11.5px; margin-top: 4px; }
  .kpi-mark { width: 28px; height: 28px; top: 12px; right: 12px; border-radius: 9px; }
  .kpi-action { margin-top: 10px; padding-top: 8px; }

  .card { padding: 16px; border-radius: 18px; }

  /* Filas de lista (Inicio): en el teléfono pasan de columnas fijas a dos
     líneas — arriba el nombre, abajo estado, monto y acción a la derecha */
  .list-row {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 14px;
  }
  .list-row > * { min-width: 0; }
  .list-row > :has(> .td-strong:not(.td-mono)) { flex: 1 1 60%; }
  .list-row > :last-child { margin-left: auto; }
  .card-header { margin-bottom: 14px; padding-bottom: 12px; flex-wrap: wrap; }

  .action-bar { margin-bottom: 16px; }
  .action-bar-title { font-size: 22px; }
  .action-bar-right { width: 100%; }
  .action-bar-right .btn { flex: 1; }

  /* Campos grandes y cómodos al tacto */
  .input, .select, .textarea, .search-box input { font-size: 16px; min-height: 46px; }
  .btn { min-height: 44px; padding: 11px 16px; }
  .btn-sm { min-height: 38px; }
  .search-box { max-width: none; width: 100%; }
  .table-toolbar { padding: 12px; }

  .td-actions .btn-icon,
  .btn-icon { width: 40px; height: 40px; }

  /* ===== Tablas como tarjetas =====
     ui.js pone data-label en cada celda con el título de su columna */
  .table-wrap, .card:has(> table) { overflow: visible; }
  .table-wrap { background: transparent; border: none; box-shadow: none; }
  table.has-labels, table.has-labels tbody { display: block; }
  table.has-labels thead { display: none; }
  table.has-labels tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 12px 14px;
    margin: 0 0 10px;
    border-radius: 16px;
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-grad) 100%);
    border: 1px solid var(--border);
    border-bottom-color: var(--border-strong);
    box-shadow: var(--shadow-card);
  }
  table.has-labels tbody tr:hover { background: var(--surface); }
  table.has-labels tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border-light);
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  table.has-labels tbody td:last-child { border-bottom: none; }
  table.has-labels tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-3);
    text-align: left;
    flex-shrink: 0;
    max-width: 45%;
  }
  table.has-labels tbody td[data-label=""]::before { display: none; }
  /* La primera celda funciona como título de la tarjeta */
  table.has-labels tbody td:first-child {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    padding-bottom: 8px;
    justify-content: flex-start;
    text-align: left;
  }
  table.has-labels tbody td:first-child::before { display: none; }
  table.has-labels tbody td.td-actions {
    justify-content: flex-end;
    padding-top: 8px;
    border-bottom: none;
  }
  table.has-labels tbody td.td-actions::before { display: none; }
  table.has-labels tbody td[colspan] { justify-content: center; text-align: center; }
  table.has-labels tbody td[colspan]::before { display: none; }
  table.has-labels tfoot { display: block; }
  table.has-labels tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
  table.has-labels tfoot td { border: none; padding: 2px 0; }

  /* Modales como hojas que suben desde abajo */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal-lg {
    max-width: none;
    max-height: calc(100vh - 28px - env(safe-area-inset-top));
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    animation: sheetUp var(--t-slow);
  }
  .modal-header { padding: 20px 18px 14px; position: relative; }
  .modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 99px;
    background: var(--border-strong);
  }
  .modal-title { font-size: 18px; }
  .modal-body { padding: 18px; }
  .modal-footer {
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
  }
  .modal-footer .btn { flex: 1; }

  .toast-stack {
    left: 14px;
    right: 14px;
    bottom: calc(var(--bottom-nav-h) + 22px + env(safe-area-inset-bottom));
  }
  .toast { min-width: 0; max-width: none; }

  /* Login a una columna */
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: calc(36px + env(safe-area-inset-top)) 24px 36px; min-height: 0; }
  .login-art-logo-img { width: 84px; margin-bottom: 16px; }
  .login-art-mark { font-size: 32px; }
  .login-quote { display: none; }
  .login-form-side { padding: 0 16px 32px; margin-top: -20px; position: relative; z-index: 2; }
  .login-form { padding: 26px 20px; }
}

@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }

@media (min-width: 761px) {
  .sidebar-scrim { display: none; }
}

/* Al abrir la app instalada (pantalla completa) en tablet, respetar la muesca */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); }
}

/* ============================================================================
   IMPRESIÓN
   ============================================================================
   Para imprimir solo una parte de la vista, marcarla con class="print-area".
   ============================================================================ */

@media print {
  :root, :root[data-theme="dark"] {
    --ink: #000; --ink-1: #000; --ink-2: #222; --ink-3: #444; --ink-4: #555;
    --surface: #fff; --surface-2: #f2f2f2; --surface-3: #e8e8e8; --surface-grad: #fff;
    --border: #999; --border-light: #ccc; --border-strong: #777;
  }
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
  }

  .sidebar,
  .sidebar-scrim,
  .sidebar-toggle,
  .bottom-nav,
  .theme-toggle,
  .topbar-actions,
  .action-bar-right,
  .table-toolbar,
  .btn,
  .btn-icon,
  .toast-stack,
  .modal-backdrop,
  .fx-pill,
  .kpi-action,
  .empty-state-icon,
  .no-print {
    display: none !important;
  }

  .app { display: block; }
  .content { padding: 0; max-width: none; animation: none; }
  .topbar {
    position: static;
    border-bottom: 1px solid #000;
    padding: 0 0 8pt;
    height: auto;
    background: none;
    backdrop-filter: none;
  }

  .card,
  .kpi,
  .table-wrap {
    border: 1px solid #999 !important;
    box-shadow: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
    background: #fff !important;
  }
  .kpi::before { display: none; }

  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr, img { break-inside: avoid; page-break-inside: avoid; }
  thead th {
    background: #eee !important;
    color: #000 !important;
    border-bottom: 1px solid #000;
    position: static;
  }
  tbody td { color: #000 !important; }
  tbody tr:hover { background: none !important; }

  .badge {
    border: 1px solid #666 !important;
    background: none !important;
    color: #000 !important;
  }
  .badge::before { display: none; }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }

  body:has(.print-area) .app > *:not(.main),
  body:has(.print-area) .main > *:not(.content) {
    display: none !important;
  }

  @page { margin: 14mm; }
}

/* Íconos de línea en línea con el texto (utils.js → appIcon) */
.app-icon {
  width: 1.1em;
  height: 1.1em;
  display: inline-block;
  vertical-align: -0.18em;
  flex-shrink: 0;
}

/* ============== BUSCADOR SOBRE SELECT (ui.js → select[data-search]) ============== */

.ss-wrap { position: relative; width: 100%; }
.ss-field { position: relative; }
.ss-search {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
}
.ss-input.input { padding-left: 38px; padding-right: 38px; font-weight: 600; }
.ss-input.input::placeholder { font-weight: 500; }
.ss-wrap.open .ss-input.input {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.ss-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: none;
  place-items: center;
  color: var(--ink-3);
}
.ss-clear svg { width: 15px; height: 15px; }
.ss-clear:hover { background: var(--surface-3); color: var(--ink); }
.ss-wrap.has-value .ss-clear { display: grid; }

.ss-list {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(340px, 50vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  animation: fadeIn 0.12s ease;
}
.ss-list[hidden] { display: none; }
.ss-option {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 11px;
  border-radius: 9px;
  cursor: pointer;
}
.ss-option + .ss-option { margin-top: 2px; }
.ss-option:hover, .ss-option.active { background: var(--surface-2); }
.ss-option.active { box-shadow: inset 3px 0 0 var(--accent); }
.ss-option.selected .ss-main::after {
  content: '  ✓';
  color: var(--accent);
  font-weight: 800;
}
.ss-main { font-size: 14px; font-weight: 600; color: var(--ink); }
.ss-sub { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ss-option mark {
  background: var(--gold-tint);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
.ss-empty, .ss-more {
  padding: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
}
.ss-more { font-size: 12px; border-top: 1px dashed var(--border); margin-top: 4px; }

@media (max-width: 760px) {
  .ss-list { max-height: 46vh; }
  .ss-option { padding: 12px; }
  .ss-main { font-size: 15px; }
}

/* ============== VENTAS: PANEL "AGREGAR PRODUCTO" ============== */

.sale-composer {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(400px 120px at 0% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    var(--surface-2);
}
.sc-search-wrap { position: relative; }
.sc-search-icon {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 19px; height: 19px; color: var(--ink-4); pointer-events: none;
}
.input.sc-search {
  min-height: 50px;
  padding-left: 44px;
  font-size: 15.5px;
  font-weight: 600;
  border-radius: 14px;
  background: var(--surface);
}
.sc-results {
  position: absolute; z-index: 70; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(380px, 55vh); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-3);
}
.sc-results[hidden] { display: none; }
.sc-option { padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.sc-option + .sc-option { margin-top: 2px; }
.sc-option:hover, .sc-option.active { background: var(--surface-2); }
.sc-option.active { box-shadow: inset 3px 0 0 var(--accent); }
.sc-opt-main { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.sc-opt-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; font-variant-numeric: tabular-nums; }
.sc-nostock { color: var(--danger); font-weight: 700; }
.sc-option mark, .ss-option mark { background: var(--gold-tint); color: inherit; border-radius: 3px; padding: 0 1px; }
.sc-empty { padding: 16px; text-align: center; font-size: 13.5px; color: var(--ink-3); }

.sc-picked {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 14px; margin-bottom: 14px;
  border-radius: 14px; background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.sc-picked-info { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sc-code { font-size: 12px; font-weight: 700; color: var(--accent-ink); }
.sc-name { font-size: 15.5px; font-weight: 800; color: var(--ink); }
.sc-stock { font-size: 12px; color: var(--ink-3); }
.sc-stock.none { color: var(--danger); font-weight: 700; }

.sc-fields {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(260px, 1.6fr) minmax(120px, 1fr) auto auto;
  gap: 12px 14px;
  align-items: end;
}
.sc-seg {
  display: flex; padding: 3px; gap: 3px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border);
}
.sc-seg button {
  flex: 1; min-height: 36px; padding: 6px 10px; border-radius: 9px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-3);
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.sc-seg button:hover { color: var(--ink); }
.sc-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }
.sc-exempt { min-height: 42px; font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.sc-add { min-height: 42px; }

@media (max-width: 1100px) {
  .sc-fields { grid-template-columns: 1fr 1fr; }
  .sc-types { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .sale-composer { padding: 14px; }
  .sc-fields { grid-template-columns: 1fr 1fr; }
  .sc-add { grid-column: 1 / -1; width: 100%; min-height: 50px; font-size: 15px; }
  .sc-exempt { grid-column: 1 / -1; min-height: 32px; }
  .sc-seg button { min-height: 42px; }
}
.ss-native {
  position: absolute !important;
  left: 14px;
  bottom: 0;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0;
  pointer-events: none;
}
