/* =====================================================
   TALLER TESNET — Sistema de Gestión
   Tema: Tech Dark con gradiente azul-violeta
   Colores oficiales: #2b3f55 navy, #b2c2d3 light
   Logo gradient: #5b3cff → #2196f3
===================================================== */

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

:root {
  /* Backgrounds */
  --bg-base:        #0a1220;
  --bg-elevated:    #0f1828;
  --bg-surface:     #1a2538;
  --bg-surface-hi:  #1f2c43;
  --bg-input:       #0f1828;
  --bg-hover:       #243352;

  /* Borders */
  --border:         #2b3f55;
  --border-hi:      #3d5475;

  /* Text */
  --text:           #e8edf5;
  --text-secondary: #b2c2d3;
  --text-muted:     #6b7a92;

  /* Brand */
  --brand-purple:   #5b3cff;
  --brand-blue:     #2196f3;
  --brand-cyan:     #06b6d4;
  --brand-gradient: linear-gradient(135deg, #5b3cff 0%, #2196f3 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(91,60,255,.18) 0%, rgba(33,150,243,.18) 100%);

  /* Status */
  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #3b82f6;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.3);
  --shadow:     0 4px 12px rgba(0,0,0,.35);
  --shadow-lg:  0 16px 40px rgba(0,0,0,.5);
  --glow:       0 0 0 3px rgba(91,60,255,.18);

  /* Sizes */
  --radius:     10px;
  --radius-sm:  6px;
  --radius-lg:  14px;
  --sidebar-w:  260px;
}

/* ============ TEMA CLARO ============ */
html[data-theme="light"] {
  --bg-base:        #eef2f8;
  --bg-elevated:    #ffffff;
  --bg-surface:     #ffffff;
  --bg-surface-hi:  #f4f7fb;
  --bg-input:       #ffffff;
  --bg-hover:       #eaeff7;
  --border:         #d6deea;
  --border-hi:      #bccadd;
  --text:           #16202e;
  --text-secondary: #43536a;
  --text-muted:     #7c8ba1;
  --shadow-sm:  0 1px 2px rgba(20,40,80,.08);
  --shadow:     0 4px 14px rgba(20,40,80,.10);
  --shadow-lg:  0 16px 40px rgba(20,40,80,.16);
  --glow:       0 0 0 3px rgba(91,60,255,.14);
}
/* En claro, atenúa las auroras de fondo para que no ensucien */
html[data-theme="light"] body::before,
html[data-theme="light"] body::after { opacity: .35 !important; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Background con sutiles auroras */
body::before {
  content:'';
  position: fixed; inset: 0;
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(91,60,255,.10), transparent 60%),
    radial-gradient(900px 600px at 110% 110%, rgba(33,150,243,.08), transparent 60%);
  pointer-events: none; z-index: 0;
}

.hidden { display: none !important; }

/* =========================================
   SPLASH
========================================= */
.splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 24px;
  background: var(--bg-base);
  z-index: 1000;
}
.splash-logo {
  width: 96px; height: 96px;
  filter: drop-shadow(0 8px 24px rgba(91,60,255,.4));
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%     { transform: scale(1.05); opacity: .85; }
}
.splash-bar {
  width: 220px; height: 4px;
  background: var(--bg-surface);
  border-radius: 4px; overflow: hidden;
}
.splash-bar-inner {
  height: 100%;
  background: var(--brand-gradient);
  width: 30%;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0%   { margin-left: -30%; width: 30%; }
  50%  { margin-left: 50%; width: 30%; }
  100% { margin-left: 100%; width: 30%; }
}
#splashMsg {
  color: var(--text-secondary);
  font-size: 13px; letter-spacing: .5px;
}

/* =========================================
   APP LAYOUT
========================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  position: relative; z-index: 1;
}

/* Sidebar ----------------------------- */
.sidebar {
  background: linear-gradient(180deg, #0d1828 0%, #0a1220 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 22px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand img {
  width: 44px; height: 44px;
  filter: drop-shadow(0 4px 12px rgba(91,60,255,.4));
}
.sidebar-brand h1 {
  font-size: 16px; font-weight: 700;
  letter-spacing: .5px;
  background: var(--brand-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar-brand span {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
}

.nav { padding: 12px 8px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin: 2px 0;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 500; font-size: 13.5px;
  position: relative;
  transition: all .15s;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover {
  background: var(--bg-surface);
  color: var(--text);
}
.nav-link.active {
  background: var(--brand-gradient-soft);
  color: var(--text);
}
.nav-link.active::before {
  content: '';
  position: absolute; left: 0; top: 18%; bottom: 18%;
  width: 3px;
  background: var(--brand-gradient);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-footer a {
  color: var(--text-secondary);
  text-decoration: none; font-size: 12px;
}
.sidebar-footer a:hover { color: var(--brand-blue); }
.sidebar-footer small { color: var(--text-muted); font-size: 10.5px; letter-spacing: .5px; }

/* Main ----------------------------- */
.main {
  display: flex; flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.topbar-title h2 {
  font-size: 22px; font-weight: 700;
  margin-bottom: 2px;
}
.topbar-title span {
  font-size: 13px; color: var(--text-muted);
}
.topbar-actions {
  display: flex; align-items: center; gap: 10px;
}

.search-wrap {
  position: relative;
  display: flex; align-items: center;
}
.search-wrap svg {
  position: absolute; left: 12px;
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-wrap input {
  width: 320px;
  padding: 10px 12px 10px 38px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 13.5px;
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: var(--glow);
}

.view {
  flex: 1; overflow-y: auto;
  padding: 24px 28px 32px;
}

/* =========================================
   BUTTONS
========================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--brand-gradient);
  color: white;
  box-shadow: 0 4px 14px rgba(91,60,255,.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(91,60,255,.5); }
.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--bg-surface-hi);
  border-color: var(--border-hi);
}
.btn-ghost {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-secondary);
  padding: 10px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.3);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-success {
  background: rgba(16,185,129,.14);
  border-color: rgba(16,185,129,.3);
  color: var(--success);
}
.btn-success:hover { background: rgba(16,185,129,.22); }
.btn-warning {
  background: rgba(245,158,11,.12);
  border-color: rgba(245,158,11,.35);
  color: var(--warning);
}
.btn-warning:hover { background: rgba(245,158,11,.22); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* =========================================
   CARDS / KPI
========================================= */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 {
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.card-header h3 svg { width: 18px; height: 18px; color: var(--brand-blue); }
.card-actions { display: flex; gap: 8px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative; overflow: hidden;
  transition: all .2s;
}
.kpi:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.kpi::before {
  content:''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--brand-gradient);
}
.kpi-label {
  font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .8px;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px;
}
.kpi-label svg { width: 14px; height: 14px; }
.kpi-value {
  font-size: 26px; font-weight: 700;
  letter-spacing: -.4px;
  margin-bottom: 6px;
}
.kpi-trend {
  font-size: 12px;
  display: flex; align-items: center; gap: 4px;
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-muted); }

/* Variantes de color para KPIs */
.kpi.kpi-success::before { background: linear-gradient(135deg, #10b981, #059669); }
.kpi.kpi-warning::before { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi.kpi-danger::before  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.kpi.kpi-info::before    { background: linear-gradient(135deg, #06b6d4, #0891b2); }

/* =========================================
   TABLE
========================================= */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-toolbar {
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.table-toolbar .search-wrap input { width: 260px; }
.table-toolbar select, .table-toolbar input[type="text"], .table-toolbar input[type="date"] {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
}
.table-toolbar .spacer { flex: 1; }

.table-scroll { overflow-x: auto; max-height: calc(100vh - 280px); }
table.data {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data thead {
  background: var(--bg-elevated);
  position: sticky; top: 0; z-index: 1;
}
table.data thead th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  cursor: pointer;
  user-select: none;
}
table.data thead th:hover { color: var(--text); }
table.data thead th.sorted::after {
  content: ' ▾'; color: var(--brand-blue);
}
table.data thead th.sorted-asc::after { content: ' ▴'; color: var(--brand-blue); }

table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data tbody tr.row-paid      { background: rgba(16,185,129,.06); }
table.data tbody tr.row-pending   { background: rgba(245,158,11,.06); }
table.data tbody tr.row-warranty  { background: rgba(59,130,246,.06); }
/* Reparaciones */
table.data tbody tr.row-rep-en    { background: rgba(245,158,11,.14); }   /* EN REPARACION — amarillo */
table.data tbody tr.row-rep-diag  { background: rgba(139,92,246,.14); }   /* DIAGNOSTICADO — púrpura */
table.data tbody tr.row-rep-listo { background: rgba(59,130,246,.13); }   /* LISTO — azul */
table.data tbody tr.row-rep-ent   { background: rgba(16,185,129,.13); }   /* ENTREGADO — verde */

td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.actions { text-align: right; }
td.actions button { margin-left: 4px; }

/* ── Columnas de precio en reparaciones: compactas ── */
/* Costo(9), Precio(10), Utilidad(11) */
#tblRep th:nth-child(n+9):nth-child(-n+11),
#tblRep td:nth-child(n+9):nth-child(-n+11) {
  padding-left: 6px;
  padding-right: 6px;
  max-width: 78px;
  min-width: 58px;
  text-align: right;
}
#tblRep th:nth-child(n+9):nth-child(-n+11) {
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  font-size: 10.5px;
  vertical-align: bottom;
}

/* ── Columnas de precio en inventario: compactas ── */
/* Costo(7), Costo total(8), Venta sugerida(9), Precio venta(10), Ganancia(11) */
#tblInv th:nth-child(n+7):nth-child(-n+11),
#tblInv td:nth-child(n+7):nth-child(-n+11) {
  padding-left: 6px;
  padding-right: 6px;
  max-width: 78px;
  min-width: 58px;
  text-align: right;
}
#tblInv th:nth-child(n+7):nth-child(-n+11) {
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  font-size: 10.5px;
  vertical-align: bottom;
}

/* ── Columna de acciones siempre visible (sticky derecha) ── */
.table-scroll table th:last-child,
.table-scroll table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--bg-surface);
  box-shadow: -3px 0 8px rgba(0,0,0,0.25);
}
.table-scroll table thead th:last-child {
  background: var(--bg-elevated);
  z-index: 3;
}

td.serial { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--text-secondary); }

.empty-state {
  padding: 48px 20px; text-align: center;
  color: var(--text-muted);
}
.empty-state svg {
  width: 48px; height: 48px; opacity: .4;
  margin-bottom: 12px;
}

/* Pagination */
.pagination {
  padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary);
}
.pagination-controls { display: flex; gap: 6px; align-items: center; }
.pagination button {
  padding: 6px 10px; min-width: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit; font-size: 12.5px;
}
.pagination button:hover:not(:disabled) {
  background: var(--bg-hover); color: var(--text);
  border-color: var(--border-hi);
}
.pagination button.active {
  background: var(--brand-gradient); color: white; border-color: transparent;
}
.pagination button:disabled { opacity: .35; cursor: not-allowed; }

/* =========================================
   BADGES (estados)
========================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  border: 1px solid transparent;
}
.badge-disponible { background: rgba(33,150,243,.14); color: #4aa3f0; border-color: rgba(33,150,243,.3); }
.badge-pagado     { background: rgba(16,185,129,.14); color: #34d399; border-color: rgba(16,185,129,.3); }
.badge-por-pagar  { background: rgba(245,158,11,.14); color: #fbbf24; border-color: rgba(245,158,11,.3); }
.badge-garantia   { background: rgba(91,60,255,.14); color: #a89aff; border-color: rgba(91,60,255,.3); }
.badge-default    { background: var(--bg-elevated); color: var(--text-secondary); border-color: var(--border); }

.badge-entregado    { background: rgba(16,185,129,.14); color: #34d399; border-color: rgba(16,185,129,.3); }
.badge-listo        { background: rgba(33,150,243,.14); color: #4aa3f0; border-color: rgba(33,150,243,.3); }
.badge-reparacion   { background: rgba(245,158,11,.14); color: #fbbf24; border-color: rgba(245,158,11,.3); }
.badge-diagnosticado{ background: rgba(91,60,255,.14); color: #a89aff; border-color: rgba(91,60,255,.3); }

/* =========================================
   FORMS
========================================= */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.full { grid-column: 1 / -1; }
.form-row label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .4px;
  display: flex; align-items: center; gap: 6px;
}
.form-row label .req { color: var(--brand-blue); }
.form-row input, .form-row select, .form-row textarea {
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
}
.form-row textarea { min-height: 70px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: var(--glow);
}
.form-row .hint {
  font-size: 11.5px; color: var(--text-muted);
}
.form-row .computed {
  padding: 10px 12px;
  background: rgba(33,150,243,.06);
  border: 1px dashed rgba(33,150,243,.3);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--brand-blue);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* =========================================
   MODAL
========================================= */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,9,18,.75);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(720px, 92vw);
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: scaleIn .15s;
}
.modal.modal-lg { width: min(960px, 96vw); }
@keyframes scaleIn { from { transform: scale(.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
  background: transparent; border: 0;
  color: var(--text-muted);
  font-size: 24px; line-height: 1;
  cursor: pointer; padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { color: var(--text); background: var(--bg-surface); }

.modal-body {
  padding: 20px 22px;
  overflow-y: auto; flex: 1;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* =========================================
   TOAST
========================================= */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1500;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-blue);
  padding: 12px 16px 12px 14px;
  border-radius: var(--radius);
  min-width: 280px; max-width: 380px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 10px;
  animation: slideRight .25s;
}
@keyframes slideRight {
  from { transform: translateX(100%); opacity: 0 }
  to   { transform: translateX(0); opacity: 1 }
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast-msg { font-size: 13.5px; line-height: 1.45; flex: 1; }
.toast-close {
  background: transparent; border: 0; color: var(--text-muted);
  font-size: 18px; cursor: pointer; line-height: 1;
}

/* =========================================
   DASHBOARD widgets
========================================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
.dashboard-grid > .card { min-height: 280px; }

.recent-list {
  display: flex; flex-direction: column;
}
.recent-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.recent-item:last-child { border-bottom: 0; }
.recent-item-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--brand-gradient-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.recent-item-icon svg { width: 18px; height: 18px; color: var(--brand-blue); }
.recent-item-body { flex: 1; min-width: 0; }
.recent-item-title { font-size: 13.5px; font-weight: 500; }
.recent-item-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.recent-item-value { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

.bar-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.bar-label { font-size: 12.5px; min-width: 110px; color: var(--text-secondary); }
.bar-track {
  flex: 1; height: 8px;
  background: var(--bg-input);
  border-radius: 4px; overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: 4px;
  transition: width .4s ease;
}
.bar-value { font-size: 12.5px; font-weight: 600; min-width: 50px; text-align: right; font-variant-numeric: tabular-nums; }

/* =========================================
   UTIL CLASSES
========================================= */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* =========================================
   RESPONSIVE — Tablet
========================================= */
@media (max-width: 1024px) {
  :root { --sidebar-w: 72px; }
  .sidebar-brand h1, .sidebar-brand span { display: none; }
  .nav-link { font-size: 0; justify-content: center; }
  .nav-link svg { width: 22px; height: 22px; }
  .sidebar-brand { justify-content: center; padding: 18px 8px; }
  .sidebar-brand img { width: 40px; height: 40px; }
  .sidebar-footer { display: none; }
  .search-wrap input { width: 200px; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* =========================================
   BOTTOM NAV
========================================= */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: none;   /* oculto en desktop; se muestra solo en mobile */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav::-webkit-scrollbar { display: none; }

.bnav-item {
  flex: 0 0 auto;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.bnav-item svg {
  width: 22px; height: 22px;
  flex-shrink: 0;
}
.bnav-item.active {
  color: var(--brand-blue);
}
.bnav-item.active svg {
  filter: drop-shadow(0 0 6px rgba(33,150,243,.5));
}
.bnav-item:active {
  background: var(--bg-hover);
}

/* =========================================
   RESPONSIVE — Móvil
========================================= */
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }

  html, body { overflow: hidden; }

  /* Corregir grid: sin sidebar el main caía en columna 0px */
  .app { grid-template-columns: 1fr !important; height: 100vh; }
  .main { overflow: hidden; height: 100%; }

  .sidebar { display: none !important; }

  /* Mostrar bottom nav */
  .bottom-nav { display: flex; }
  /* Ocultar el bottom nav cuando el app está oculto */
  #app.hidden ~ .bottom-nav { display: none !important; }

  /* Topbar compacta */
  .topbar {
    padding: 12px 16px;
    gap: 8px;
  }
  .topbar-title h2 { font-size: 17px; }
  .topbar-title span { display: none; }
  .topbar-actions .search-wrap { display: none !important; }
  .btn-mobile-logout { display: inline-flex !important; }

  /* Contenido con espacio para bottom nav + safe area */
  .view {
    padding: 14px 14px calc(90px + env(safe-area-inset-bottom));
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
  }

  /* Tablas: scroll horizontal — restar altura del bottom nav (~70px) para que la paginación quede visible */
  .table-scroll {
    max-height: calc(100vh - 200px - 80px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap { border-radius: var(--radius); }

  /* Toolbar de tabla: apilado en móvil */
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }
  .table-toolbar .search-wrap { width: 100%; }
  .table-toolbar .search-wrap input { width: 100%; }
  .table-toolbar .spacer { display: none; }
  .table-toolbar .ss-wrap { width: 100%; }
  .table-toolbar .ss-wrap > div:first-child { width: 100%; }
  .table-toolbar .ss-input { width: 100% !important; min-width: unset !important; }

  /* Formularios: 1 columna */
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }

  /* Modal: pantalla completa */
  .modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    height: 100vh;
    border-radius: 0 !important;
    border: none !important;
  }
  .modal-backdrop {
    align-items: flex-end;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }
  .modal-footer .btn { flex: 1; min-width: 120px; justify-content: center; }

  /* KPIs: 2 columnas en móvil */
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .kpi-value { font-size: 18px !important; }
  .kpi-label { font-size: 10px; }

  /* Dashboard grid: 1 columna */
  .dashboard-grid { grid-template-columns: 1fr !important; }

  /* Quick actions: 2 columnas */
  .quick-actions { grid-template-columns: 1fr 1fr !important; }
  .btn-quick { padding: 12px 10px; }
  .btn-quick strong { font-size: 12px; }

  /* Toasts: ancho completo */
  .toast-container { left: 12px; right: 12px; top: auto; bottom: calc(70px + env(safe-area-inset-bottom) + 8px); }
  .toast { min-width: unset; max-width: 100%; }

  /* Botones de acción en tablas: más grandes para touch */
  td.actions button { padding: 8px; }

  /* ── Inventario: ocultar columnas secundarias en móvil ── */
  /* Distribuidor(3), Serial(6), Costo(7), Costo total(8), Venta sugerida(9), Ganancia(11) */
  #tblInv th:nth-child(3), #tblInv td:nth-child(3),
  #tblInv th:nth-child(6), #tblInv td:nth-child(6),
  #tblInv th:nth-child(7), #tblInv td:nth-child(7),
  #tblInv th:nth-child(8), #tblInv td:nth-child(8),
  #tblInv th:nth-child(9), #tblInv td:nth-child(9),
  #tblInv th:nth-child(11), #tblInv td:nth-child(11) { display: none; }

  /* ── Reparaciones: ocultar columnas secundarias en móvil ── */
  /* Tipo(4), Modelo(6), Serial(7), Costo(9), Utilidad(11), Pago(12) */
  #tblRep th:nth-child(4), #tblRep td:nth-child(4),
  #tblRep th:nth-child(6), #tblRep td:nth-child(6),
  #tblRep th:nth-child(7), #tblRep td:nth-child(7),
  #tblRep th:nth-child(9), #tblRep td:nth-child(9),
  #tblRep th:nth-child(11), #tblRep td:nth-child(11),
  #tblRep th:nth-child(12), #tblRep td:nth-child(12) { display: none; }

  /* Login: sin margen extra */
  .login-card { padding: 28px 22px; margin: 16px; max-width: 100%; }
}

/* Ocultar botón logout móvil en desktop */
.btn-mobile-logout { display: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-surface); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-surface-hi); }

/* ════════════════════════════════════════════
   LOGIN SCREEN
════════════════════════════════════════════ */
.login-screen {
  position: fixed; inset: 0;
  background: var(--bg-base);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-logo {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px;
}
.login-logo img { width: 52px; height: auto; }
.login-logo h1 {
  font-size: 22px; font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-logo span { font-size: 11px; color: var(--text-muted); display: block; }
.login-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.4);
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-footer {
  margin-top: 20px; text-align: center;
  font-size: 12px; color: var(--text-muted);
}
.login-footer a { color: var(--brand-blue); text-decoration: none; }

/* ════════════════════════════════════════════
   SIDEBAR USER INFO
════════════════════════════════════════════ */
.user-info {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px; color: var(--text-muted);
  overflow: hidden;
}
.user-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ════════════════════════════════════════════
   QUICK ACTIONS (Dashboard)
════════════════════════════════════════════ */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.btn-quick {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s, opacity .15s;
  font-family: inherit;
}
.btn-quick:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.25); }
.btn-quick:active { transform: translateY(0); }
.btn-quick svg { width: 28px; height: 28px; flex-shrink: 0; }
.btn-quick strong { display: block; font-size: 14px; font-weight: 700; }
.btn-quick small { display: block; font-size: 12px; opacity: .75; margin-top: 2px; }
.btn-quick-primary { background: linear-gradient(135deg, #5b3cff22, #2196f322); border-color: rgba(91,60,255,.35); color: var(--text); }
.btn-quick-primary svg, .btn-quick-primary strong { color: #7b6fff; }
.btn-quick-info { background: linear-gradient(135deg, #2196f322, #06b6d422); border-color: rgba(33,150,243,.35); color: var(--text); }
.btn-quick-info svg, .btn-quick-info strong { color: #38bdf8; }
.btn-quick-ghost { background: var(--bg-elevated); border-color: var(--border); color: var(--text); }
.btn-quick-ghost:hover { border-color: var(--brand-blue); }
.btn-quick-warning { background: linear-gradient(135deg, #f59e0b22, #ef444422); border-color: rgba(245,158,11,.35); color: var(--text); }
.btn-quick-warning svg, .btn-quick-warning strong { color: #f59e0b; }

/* ════════════════════════════════════════════
   STOCK ALERT BANNER
════════════════════════════════════════════ */
.alert-stock {
  display: flex; align-items: center; gap: 12px;
  background: rgba(234,179,8,.1);
  border: 1px solid rgba(234,179,8,.35);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--warning);
  font-size: 13px;
}
.alert-stock svg { width: 20px; height: 20px; flex-shrink: 0; }
.alert-stock div { flex: 1; }

/* ════════════════════════════════════════════
   BADGES adicionales
════════════════════════════════════════════ */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-info    { background: rgba(33,150,243,.15); color: #60a5fa; }
.badge-warning { background: rgba(234,179,8,.15);  color: var(--warning); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger); }

/* ════════════════════════════════════════════
   PRINT STYLES
════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .toast-container, .modal-backdrop,
  .btn, button, .table-toolbar, .pagination { display: none !important; }
  body { background: #fff; color: #000; }
  .main { margin: 0; padding: 0; }
  .view { padding: 0; }
}

/* ============ Punto de Venta (POS) ============ */
.pos-grid { display: grid; grid-template-columns: 1fr 330px; gap: 16px; align-items: start; }
.pos-main { min-width: 0; }
.pos-side { position: sticky; top: 16px; }
.pos-ticket {
  background: linear-gradient(160deg, #5b3cff, #7c5cff);
  color: #fff; border-radius: 16px; padding: 22px;
  box-shadow: 0 20px 50px -20px rgba(91,60,255,.6);
}
.pos-ticket-label { font-size: 11px; opacity: .8; text-transform: uppercase; letter-spacing: .1em; }
.pos-ticket-folio { font-size: 27px; font-weight: 800; margin-top: 2px; letter-spacing: .5px; }
.pos-ticket-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.25); }
.pos-ticket-total strong { font-size: 26px; font-weight: 800; }
.pos-ticket-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; font-size: 13.5px; }
.pos-ticket-rows > div { display: flex; justify-content: space-between; align-items: center; }
.pos-ticket-rows .check { display: flex; align-items: center; gap: 6px; cursor: pointer; color: #fff; }
.pos-ticket-rows .check input { accent-color: #fff; width: 15px; height: 15px; }
.pos-add { display: grid; grid-template-columns: 150px 1fr 78px 130px auto; gap: 8px; align-items: stretch; }
.pos-add input, .pos-add select {
  width: 100%; padding: 11px 12px;
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
}
.pos-add input::placeholder { color: var(--text-muted); }
.pos-add input:focus, .pos-add select:focus { outline: none; border-color: var(--brand-purple); box-shadow: var(--glow); }
.pos-codigo-wrap { position: relative; display: flex; }
.pos-codigo-wrap input { padding-right: 40px; }
.pos-scan-btn {
  position: absolute; right: 4px; top: 4px; bottom: 4px; width: 34px;
  display: grid; place-items: center; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--brand-gradient); color: #fff;
}
.pos-scan-btn svg { width: 18px; height: 18px; }
.table-wrap { overflow-x: auto; }
.pos-table td, .pos-table th { white-space: nowrap; }
.pos-table td:first-child { white-space: normal; }

/* Overlay de cámara para código de barras */
.scan-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; }
.scan-overlay video { width: min(92vw, 460px); border-radius: 14px; border: 2px solid var(--brand-purple); }
.scan-overlay .scan-hint { color: #fff; font-size: 14px; text-align: center; }

@media (max-width: 900px) {
  .pos-grid { grid-template-columns: 1fr; }
  .pos-side { position: static; }
  .pos-add { grid-template-columns: 1fr 1fr; }
  .pos-add .pos-codigo-wrap, .pos-add > input[id="vProd"], .pos-add > button { grid-column: 1 / -1; }
}
