/* ===================================================================
   LUNAR IMPORT — Design tokens & global styles
   =================================================================== */

/* Indicador flotante de entorno de desarrollo (sólo se renderiza en Dev) */
.dev-badge {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  padding: 10px 22px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffffff;
  background: #dc2626;
  border: 1px solid #b91c1c;
  border-radius: 999px;
  box-shadow: none;
  pointer-events: auto;
  user-select: none;
  cursor: help;
}


:root {
  --color-bg: #f7f5fb;
  --color-surface: #ffffff;
  --color-surface-alt: #faf8ff;
  --color-border: #ece6f7;
  --color-border-strong: #d8ccef;
  --color-text: #1f1438;
  --color-text-muted: #6d6488;
  --color-text-soft: #8e85a8;

  --color-primary: #7c3aed;
  --color-primary-hover: #6d28d9;
  --color-primary-soft: #f3edff;
  --color-primary-deep: #4c1d95;
  --color-accent: #a855f7;

  --color-success: #16a34a;
  --color-success-soft: #dcfce7;
  --color-warning: #d97706;
  --color-warning-soft: #fef3c7;
  --color-danger: #dc2626;
  --color-danger-soft: #fee2e2;
  --color-info: #2563eb;
  --color-info-soft: #dbeafe;

  --gradient-brand: linear-gradient(135deg, #ffffff 0%, #c4b5fd 30%, #7c3aed 70%, #4c1d95 100%);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(31, 20, 56, 0.04);
  --shadow-sm: 0 1px 3px rgba(31, 20, 56, 0.08);
  --shadow-md: 0 6px 18px rgba(76, 29, 149, 0.08);
  --shadow-lg: 0 14px 40px rgba(76, 29, 149, 0.16);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --font-sans: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;

  --header-height: 60px;
  --sidebar-width: 248px;

  color-scheme: light;
}

/* =============== DARK THEME =============== */
html[data-theme="dark"] {
  --color-bg: #0f0d1f;
  --color-surface: #1a1730;
  --color-surface-alt: #221d3a;
  --color-border: #2d2748;
  --color-border-strong: #3f375c;
  --color-text: #ece6f7;
  --color-text-muted: #a89dcb;
  --color-text-soft: #847aa6;

  --color-primary: #8b5cf6;
  --color-primary-hover: #a78bfa;
  --color-primary-soft: rgba(139, 92, 246, 0.18);
  --color-primary-deep: #c4b5fd;
  --color-accent: #c084fc;

  --color-success: #4ade80;
  --color-success-soft: rgba(74, 222, 128, 0.16);
  --color-warning: #fbbf24;
  --color-warning-soft: rgba(251, 191, 36, 0.16);
  --color-danger: #f87171;
  --color-danger-soft: rgba(248, 113, 113, 0.16);
  --color-info: #60a5fa;
  --color-info-soft: rgba(96, 165, 250, 0.16);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* ajustes específicos en dark */
html[data-theme="dark"] .badge--success { background: rgba(74, 222, 128, 0.18); color: #86efac; }
html[data-theme="dark"] .badge--warning { background: rgba(251, 191, 36, 0.18); color: #fcd34d; }
html[data-theme="dark"] .badge--danger { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }
html[data-theme="dark"] .badge--info { background: rgba(96, 165, 250, 0.18); color: #93c5fd; }
html[data-theme="dark"] .badge--muted { background: rgba(255, 255, 255, 0.08); color: var(--color-text-muted); }
html[data-theme="dark"] .alert--success { background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.3); color: #86efac; }
html[data-theme="dark"] .alert--danger { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.3); color: #fca5a5; }
html[data-theme="dark"] .alert--warning { background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.3); color: #fcd34d; }
html[data-theme="dark"] .tile--accent { background: linear-gradient(135deg, #4c1d95, #7c3aed); }
html[data-theme="dark"] .locked-input { background: rgba(255, 255, 255, 0.04) !important; }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: var(--color-text-soft); }
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.45;
  min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--color-text); margin: 0 0 var(--space-3); }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }

.text-muted { color: var(--color-text-muted) !important; }
.text-soft { color: var(--color-text-soft); }
.text-mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- layout shell ---------- */
.app-shell {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  min-height: 100vh;
}

.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}

.app-header__brand {
  display: flex; align-items: center; gap: var(--space-3);
  font-weight: 600; font-size: 1.05rem; color: var(--color-text);
  text-decoration: none;
}
.app-header__brand:hover { text-decoration: none; color: var(--color-text); }

.app-brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: var(--shadow-sm);
}

.app-header__spacer { flex: 1; }

.app-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  background: transparent; border: 1px solid transparent; cursor: pointer;
  color: var(--color-text-muted); border-radius: var(--radius-sm);
}
.app-theme-toggle:hover { color: var(--color-primary); background: var(--color-primary-soft); }
.app-theme-toggle svg { width: 18px; height: 18px; }
html[data-theme="dark"] .app-theme-toggle .icon-sun { display: inline; }
html[data-theme="dark"] .app-theme-toggle .icon-moon { display: none; }
html:not([data-theme="dark"]) .app-theme-toggle .icon-sun { display: none; }
html:not([data-theme="dark"]) .app-theme-toggle .icon-moon { display: inline; }

.app-header__user { display: flex; align-items: center; gap: var(--space-3); color: var(--color-text-muted); font-size: 0.9rem; min-width: 0; }
.app-header__user form { margin: 0; }
.app-header__user .btn-link { padding: 0; color: var(--color-text-muted); }
.app-header__user-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
@media (max-width: 768px) {
  .app-header__user-name { display: none; }
}

.app-toggle {
  display: inline-flex;
  background: transparent; border: 0; cursor: pointer; padding: var(--space-2);
  color: var(--color-text);
  border-radius: var(--radius-sm);
}
.app-toggle:hover { color: var(--color-primary); background: var(--color-primary-soft); }

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: calc(100vh - var(--header-height));
  transition: grid-template-columns .18s ease;
}
body.sidebar-collapsed .app-body { grid-template-columns: 0 1fr; }

.app-sidebar__overlay { display: none; }

.app-sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-5) var(--space-3);
  overflow-y: auto;
  transition: transform .18s ease, width .18s ease, padding .18s ease;
}
body.sidebar-collapsed .app-sidebar { transform: translateX(-100%); width: 0; padding-left: 0; padding-right: 0; overflow: hidden; }

.app-sidebar__group {
  margin-bottom: var(--space-5);
}
.app-sidebar__group-title {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-text-soft);
  padding: 0 var(--space-3) var(--space-2);
  margin: 0;
}

.app-sidebar__link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 500; font-size: 0.92rem;
  transition: background 0.12s, color 0.12s;
}
.app-sidebar__link:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
  text-decoration: none;
}
.app-sidebar__link.active {
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
  font-weight: 600;
}
.app-sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

.app-content {
  padding: var(--space-6) var(--space-7);
  min-width: 0;
}

/* ---------- page layout ---------- */
.page-header {
  display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4);
  align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--space-6);
}
.page-header__title { margin-bottom: var(--space-1); }
.page-header__subtitle { color: var(--color-text-muted); font-size: 0.9rem; margin: 0; }
.page-header__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
}
.section__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.section__header h2, .section__header h3 { margin: 0; }
.section--flush { padding: 0; }
.section--flush .section__header { padding: var(--space-5) var(--space-6); margin: 0; border-bottom: 1px solid var(--color-border); }
.section--flush .section__body { padding: 0; }

.subsection { margin-bottom: var(--space-5); }
.subsection__title {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-soft); margin: 0 0 var(--space-3);
  font-weight: 600;
}

/* ---------- summary tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.tile__label { font-size: 0.78rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.tile__value { font-size: 1.5rem; font-weight: 600; color: var(--color-text); font-variant-numeric: tabular-nums; }
.tile__hint { font-size: 0.82rem; color: var(--color-text-soft); }
.tile--accent { background: linear-gradient(135deg, var(--color-primary-deep), var(--color-primary)); color: white; border-color: transparent; }
.tile--accent .tile__label { color: rgba(255,255,255,0.7); }
.tile--accent .tile__value, .tile--accent .tile__hint { color: white; }

/* ---------- forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.form-grid--cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.form-grid--cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid__full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field > button.btn,
.field > .btn {
  width: auto;
  align-self: flex-start;
  margin-top: auto;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  line-height: 1.4;
}
.field label, .field .form-label {
  font-size: 0.82rem; color: var(--color-text-muted); font-weight: 500;
  margin: 0;
}
.field input, .field select, .field textarea, .field .form-control, .field .form-select,
.app-content input[type="text"],
.app-content input[type="email"],
.app-content input[type="number"],
.app-content input[type="date"],
.app-content input[type="search"],
.app-content input[type="password"],
.app-content input[type="tel"],
.app-content select,
.app-content textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.field .form-control:focus, .field .form-select:focus,
.app-content input:focus,
.app-content select:focus,
.app-content textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.app-content input[type="checkbox"],
.app-content input[type="radio"] {
  width: 16px; height: 16px; padding: 0; accent-color: var(--color-primary); margin: 0;
}
/* compact controls inside data tables */
.table input, .table select, .table textarea {
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  min-width: 0;
}

/* Quitar las flechitas del input[type=number] en todos los browsers */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Tablas con líneas editables: forzar min-width para que no se compriman los inputs en mobile */
#tabla-detalles { min-width: 920px; }
#tabla-pagos, #tabla-pagos-prov { min-width: 760px; }
#tabla-pagos-prov { min-width: 880px; }
.app-no-scroll { overflow: hidden; }
.field textarea { min-height: 80px; resize: vertical; }
.field .field-hint { font-size: 0.78rem; color: var(--color-text-soft); margin-top: var(--space-1); }
.field .field-error { color: var(--color-danger); font-size: 0.78rem; margin-top: var(--space-1); }

.field-inline { display: flex; align-items: center; gap: var(--space-2); }
.field-inline input[type="checkbox"], .field-inline input[type="radio"] {
  width: 16px; height: 16px; accent-color: var(--color-primary); margin: 0;
}

.form-actions {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  justify-content: flex-end;
  padding-top: var(--space-5);
  margin-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 0.5rem 1rem;
  font-size: 0.92rem; font-weight: 500;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--color-surface-alt); border-color: var(--color-primary); color: var(--color-primary-deep); text-decoration: none; }
.btn:focus { outline: 0; box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18); }
.btn[disabled], .btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: white; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { color: var(--color-primary-deep); background: var(--color-primary-soft); border-color: transparent; }

.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: white; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: white; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }

.button-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-surface); }
.table {
  width: 100%; border-collapse: collapse; font-size: 0.92rem;
}
.table th, .table td { padding: 0.75rem 1rem; text-align: left; vertical-align: middle; }
.table th { font-weight: 600; color: var(--color-text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; background: var(--color-surface-alt); border-bottom: 1px solid var(--color-border); }
.table tbody tr { border-bottom: 1px solid var(--color-border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-primary-soft); }
.table .num, .table .right { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .actions { text-align: right; white-space: nowrap; }
.table-empty { padding: var(--space-6); text-align: center; color: var(--color-text-muted); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem; font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
}
.badge--success { background: var(--color-success-soft); color: #15803d; }
.badge--warning { background: var(--color-warning-soft); color: #b45309; }
.badge--danger { background: var(--color-danger-soft); color: #b91c1c; }
.badge--info { background: var(--color-info-soft); color: #1d4ed8; }
.badge--muted { background: #eef0f5; color: #4b5563; }

/* ---------- alerts ---------- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  margin-bottom: var(--space-4);
  font-size: 0.92rem;
}
.alert--success { background: var(--color-success-soft); border-color: #bbf7d0; color: #166534; }
.alert--danger { background: var(--color-danger-soft); border-color: #fecaca; color: #991b1b; }
.alert--warning { background: var(--color-warning-soft); border-color: #fde68a; color: #92400e; }

/* ---------- validation ---------- */
.text-danger, .field-validation-error { color: var(--color-danger); font-size: 0.78rem; }
.input-validation-error { border-color: var(--color-danger) !important; }

/* hide validation summary when there are no errors */
.alert.validation-summary-valid,
.alert:empty { display: none; }

/* ---------- fieldset reset (used as form group wrapper) ---------- */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] { opacity: 0.7; }

/* visual lock for inputs marked readonly via JS (venta confirmada) */
.locked-input { background: var(--color-surface-alt) !important; color: var(--color-text-muted) !important; cursor: not-allowed; }
select:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- venta · resumen pagos ---------- */
.resumen-pagos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}
.resumen-pagos__col {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 var(--space-3);
  border-left: 3px solid transparent;
}
.resumen-pagos__col:first-child { border-left-color: var(--color-primary); }
.resumen-pagos__col--falta { border-left-color: var(--color-danger); }
.resumen-pagos__col--ok { border-left-color: var(--color-success); }
.resumen-pagos__col--sobre { border-left-color: var(--color-warning); }
.resumen-pagos__label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-muted); font-weight: 600;
}
.resumen-pagos__value { font-size: 1.15rem; font-weight: 600; color: var(--color-text); }
.resumen-pagos__col--falta .resumen-pagos__value { color: var(--color-danger); }
.resumen-pagos__col--ok .resumen-pagos__value { color: var(--color-success); font-size: 1rem; }
.resumen-pagos__col--sobre .resumen-pagos__value { color: var(--color-warning); }

/* ---------- key-value list ---------- */
.kv {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  column-gap: var(--space-5);
  row-gap: var(--space-2);
  font-size: 0.92rem;
}
.kv dt { color: var(--color-text-muted); font-weight: 500; }
.kv dd { margin: 0; color: var(--color-text); font-variant-numeric: tabular-nums; }

/* ---------- chip group ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 0.25rem 0.6rem;
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  white-space: nowrap;
  margin: 2px 4px 2px 0;
}

/* ---------- login / identity wrappers ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  background: var(--gradient-brand);
  padding: var(--space-5);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  box-shadow: var(--shadow-lg);
}
.auth-card__brand { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.auth-card__brand .app-brand-mark { width: 56px; height: 56px; }
.auth-card h1 { font-size: 1.4rem; text-align: center; margin: 0; }
.auth-card .form-actions { border-top: 0; padding-top: var(--space-3); margin-top: var(--space-2); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  :root { --sidebar-width: 220px; }
  .app-content { padding: var(--space-5); }
}

@media (max-width: 768px) {
  .app-body { grid-template-columns: 1fr; }
  body.sidebar-collapsed .app-body { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed; top: var(--header-height); left: 0; bottom: 0;
    width: 270px; transform: translateX(-100%);
    transition: transform 0.18s ease;
    z-index: 40; box-shadow: var(--shadow-md);
  }
  body.sidebar-collapsed .app-sidebar { width: 270px; padding: var(--space-5) var(--space-3); }
  .app-sidebar.is-open { transform: translateX(0); }
  .app-sidebar__overlay {
    display: none;
    position: fixed; top: var(--header-height); left: 0; right: 0; bottom: 0;
    background: rgba(31, 20, 56, 0.32); z-index: 35;
  }
  .app-sidebar__overlay.is-open { display: block; }
  .app-content { padding: var(--space-4); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .table th, .table td { padding: 0.5rem 0.65rem; font-size: 0.85rem; }
}

@media (max-width: 480px) {
  .app-header { padding: 0 var(--space-3); }
  .app-content { padding: var(--space-3); }
  .section { padding: var(--space-4); border-radius: var(--radius-md); }
}

/* ---------- producto autocomplete ---------- */
.producto-autocomplete {
  position: relative;
  width: 100%;
}
.producto-autocomplete__input {
  width: 100%;
}
.producto-autocomplete__results {
  position: fixed;
  z-index: 200;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  min-width: 320px;
}
.producto-autocomplete__item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.producto-autocomplete__item:hover,
.producto-autocomplete__item.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary-deep);
}
.producto-autocomplete__row1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}
.producto-autocomplete__item.is-active .producto-autocomplete__row1,
.producto-autocomplete__item:hover .producto-autocomplete__row1 {
  color: var(--color-primary-deep);
}
.producto-autocomplete__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.producto-autocomplete__sku {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--color-text-soft);
  font-weight: 400;
}
.producto-autocomplete__row2 {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}
.producto-autocomplete__item.is-active .producto-autocomplete__row2,
.producto-autocomplete__item:hover .producto-autocomplete__row2 {
  color: var(--color-primary-deep);
  opacity: 0.85;
}
.producto-autocomplete__empty {
  padding: var(--space-2) var(--space-3);
  color: var(--color-text-soft);
  font-size: 0.85rem;
  font-style: italic;
}
