/* assets/css/style.css — Sistema Facturación Electrónica */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

/* ══ TEMA OSCURO (por defecto) ════════════════════════════════ */
:root {
  --bg:          #0d1117;
  --bg-2:        #161b22;
  --bg-3:        #1c2333;
  --border:      #30363d;
  --border-2:    #21262d;
  --accent:      #e8562a;
  --accent-2:    #f5863d;
  --accent-glow: rgba(232,86,42,.18);
  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-dim:    #484f58;
  --success:     #2ea043;
  --warning:     #d29922;
  --danger:      #da3633;
  --info:        #1f6feb;
  --sidebar-w:   260px;
  --sidebar-collapsed-w: 64px;
  --topbar-h:    64px;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,.40);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.30);
  --font-display:'Syne', sans-serif;
  --font-body:   'DM Sans', sans-serif;
  --transition:  .18s ease;
  --theme-icon:  '🌙';
}

/* ══ TEMA CLARO ═══════════════════════════════════════════════ */
[data-theme="light"] {
  --bg:          #f5f7fa;
  --bg-2:        #ffffff;
  --bg-3:        #eef1f6;
  --border:      #c8cdd8;
  --border-2:    #dde1ea;
  --accent:      #e8562a;
  --accent-2:    #c9440f;
  --accent-glow: rgba(232,86,42,.12);
  --text:        #1a1f2e;
  --text-muted:  #5a6378;
  --text-dim:    #9aa0b0;
  --success:     #1a7a38;
  --warning:     #9a6000;
  --danger:      #c0261f;
  --info:        #1357c4;
  --shadow:      0 4px 24px rgba(0,0,0,.08);
  --shadow-sm:   0 2px 8px rgba(0,0,0,.06);
  --theme-icon:  '☀️';
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  transition: background .25s ease, color .25s ease;
}

/* ── SCROLLBAR ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══ BOTÓN TEMA (modo claro / oscuro) ══════════════════════════ */
.btn-theme {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--border);
  cursor: pointer; font-size: 17px; transition: all .2s ease;
  flex-shrink: 0; line-height: 1;
}
.btn-theme:hover {
  background: var(--accent-glow); border-color: var(--accent); transform: rotate(20deg);
}
/* Floating en login */
.btn-theme-float {
  position: fixed; top: 16px; right: 16px; z-index: 999;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; transition: all .2s ease;
}
.btn-theme-float:hover { transform: rotate(25deg) scale(1.1); }

/* ══ AUTH LAYOUT ═══════════════════════════════════════════════ */
.auth-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-brand {
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg) 100%);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 60px; position: relative; overflow: hidden;
}
.auth-brand::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 80% at 50% 0%, var(--accent-glow), transparent);
  pointer-events: none;
}
.auth-brand .brand-logo {
  font-family: var(--font-display); font-size: 3rem; font-weight: 800;
  color: var(--text); letter-spacing: -2px; margin-bottom: 12px;
}
.auth-brand .brand-logo span { color: var(--accent); }
.auth-brand p { color: var(--text-muted); font-size: 1rem; max-width: 320px; text-align: center; }
.auth-brand .decorative-grid {
  position: absolute; bottom: 0; left: 0; right: 0; height: 200px;
  background-image: linear-gradient(var(--border-2) 1px, transparent 1px),
                    linear-gradient(90deg, var(--border-2) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(transparent, black); opacity: .4;
}
.auth-form-side {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; background: var(--bg-2);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; margin-bottom: 6px; }
.auth-card p { color: var(--text-muted); margin-bottom: 32px; }

/* ══ APP LAYOUT ════════════════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; }

/* ══ SIDEBAR ════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border-2);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: width .25s ease, transform .18s ease;
  overflow: hidden;
}
.sidebar-header {
  padding: 20px 20px;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-logo {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 800;
  color: var(--text); line-height: 1.2; letter-spacing: -0.5px;
  white-space: nowrap; transition: opacity .2s, width .2s;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-logo-sub {
  font-size: 10px; color: var(--text-dim); margin-top: 2px;
  white-space: nowrap; transition: opacity .2s;
}

/* Botón colapsar sidebar */
.btn-collapse {
  flex-shrink: 0;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--border-2);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s ease;
}
.btn-collapse:hover { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }
.btn-collapse svg { transition: transform .3s ease; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 0; }
.nav-section { padding: 8px 16px 4px; }
.nav-section-title {
  font-size: 10px; font-weight: 600; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-dim);
  white-space: nowrap; transition: opacity .15s;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; margin: 2px 8px;
  border-radius: var(--radius-sm); color: var(--text-muted);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: all var(--transition);
  position: relative; white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active {
  background: var(--accent-glow); color: var(--accent-2); font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 50%;
  transform: translateY(-50%); width: 3px; height: 60%;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-item svg { flex-shrink: 0; }
.nav-label { transition: opacity .15s, width .2s; }

.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border-2); flex-shrink: 0; }
.user-card { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; transition: opacity .15s, width .15s; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: 4px; flex-shrink: 0;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--danger); }

/* ══ SIDEBAR COLAPSADO ══════════════════════════════════════════ */
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }
.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .sidebar-logo-sub  { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .nav-section-title { opacity: 0; }
.sidebar.collapsed .nav-label         { opacity: 0; width: 0; overflow: hidden; margin: 0; }
.sidebar.collapsed .nav-item {
  justify-content: center; padding: 10px; margin: 2px 6px; gap: 0;
}
.sidebar.collapsed .nav-item.active::before { left: -6px; }
.sidebar.collapsed .user-info          { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .btn-logout         { display: none; }
.sidebar.collapsed .user-card          { justify-content: center; }
.sidebar.collapsed .btn-collapse svg   { transform: rotate(180deg); }

/* Tooltip en modo colapsado */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: var(--radius-sm);
  white-space: nowrap; box-shadow: var(--shadow-sm);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
  z-index: 200;
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* Main content con sidebar colapsado */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; transition: margin-left .25s ease; }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-w); }

/* ══ TOPBAR ════════════════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h); background: var(--bg-2);
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.menu-toggle {
  display: none; background: none; border: none;
  color: var(--text-muted); cursor: pointer; padding: 6px;
}

/* ══ PAGE BODY ═════════════════════════════════════════════════ */
.page-body { padding: 28px; flex: 1; }

/* ══ STATS CARDS ═══════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 20px 22px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.orange { background: var(--accent-glow); color: var(--accent); }
.stat-icon.green  { background: rgba(46,160,67,.15); color: var(--success); }
.stat-icon.blue   { background: rgba(31,111,235,.15); color: var(--info); }
.stat-icon.yellow { background: rgba(210,153,34,.15); color: var(--warning); }
.stat-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ══ CARD ══════════════════════════════════════════════════════ */
.card {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; }
.card-body { padding: 22px; }
.card-footer {
  padding: 14px 22px; border-top: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between;
}

/* ══ TABLE ═════════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 14px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border-2); white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-3); }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ══ FORMS ═════════════════════════════════════════════════════ */
.form-grid { display: grid; gap: 18px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
label {
  font-size: 12px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; color: var(--text-muted);
}
input, select, textarea {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--font-body); font-size: 14px;
  padding: 10px 14px; width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder { color: var(--text-dim); }
select option { background: var(--bg-3); color: var(--text); }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: var(--text-muted); }
.input-group { position: relative; }
.input-group input { padding-left: 38px; }
.input-group .input-prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px;
}

/* ══ BUTTONS ═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: all var(--transition); text-decoration: none; white-space: nowrap;
}
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 0 16px var(--accent-glow); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-3); border-color: var(--text-muted); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(218,54,51,.12); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-icon { padding: 7px; }
.btn-sri {
  background: linear-gradient(135deg, #1a3c6e, #1f6feb); color: #fff; border: none;
  box-shadow: 0 2px 12px rgba(31,111,235,.3);
}
.btn-sri:hover { filter: brightness(1.1); box-shadow: 0 4px 20px rgba(31,111,235,.5); }

/* ══ BADGE ═════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(46,160,67,.18); color: var(--success); }
.badge-danger  { background: rgba(218,54,51,.18); color: var(--danger); }
.badge-warning { background: rgba(210,153,34,.18); color: var(--warning); }
.badge-info    { background: rgba(31,111,235,.18); color: var(--info); }
.badge-muted   { background: rgba(125,133,144,.15); color: var(--text-muted); }
.badge-orange  { background: var(--accent-glow); color: var(--accent-2); }

/* ══ ALERTS ════════════════════════════════════════════════════ */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; margin-bottom: 16px; font-size: 13.5px;
}
.alert svg { flex-shrink: 0; }
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 18px; color: inherit; opacity: .6; }
.alert-close:hover { opacity: 1; }
.alert-success { background: rgba(46,160,67,.12); border-color: rgba(46,160,67,.3); color: var(--success); }
.alert-error   { background: rgba(218,54,51,.12);  border-color: rgba(218,54,51,.3);  color: var(--danger); }
.alert-warning { background: rgba(210,153,34,.12); border-color: rgba(210,153,34,.3); color: var(--warning); }
.alert-info    { background: rgba(31,111,235,.12); border-color: rgba(31,111,235,.3); color: var(--info); }

/* ══ PAGINATION — MODERNA ══════════════════════════════════════ */

/* Barra inferior de paginación (reemplaza card-footer) */
.pag-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-2);
  background: var(--bg-2);
}
.pag-left  { display: flex; align-items: center; gap: 12px; }
.pag-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Info: "Mostrando 1-15 de 47 registros" */
.pag-info { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.pag-info strong { color: var(--text); }

/* Selector de filas por página */
.pag-size-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.pag-size-select {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 12px; font-family: var(--font-body);
  padding: 4px 8px; cursor: pointer; outline: none;
  transition: border-color var(--transition);
}
.pag-size-select:focus { border-color: var(--accent); }

/* Botón individual de página */
.pag-btn {
  min-width: 34px; height: 34px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--border-2);
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: all .15s ease; line-height: 1; user-select: none;
}
.pag-btn:hover:not(.disabled):not(.dots) {
  background: var(--accent-glow); border-color: var(--accent); color: var(--accent);
}
.pag-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff; cursor: default;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.pag-btn.disabled { opacity: .3; cursor: not-allowed; pointer-events: none; }
.pag-btn.dots {
  background: none; border-color: transparent;
  color: var(--text-muted); cursor: default; letter-spacing: 1px;
}
.pag-btn.dots:hover { background: none; border-color: transparent; color: var(--text-muted); }
.pag-btn.nav svg { pointer-events: none; }

/* Compatibilidad con paginación PHP legacy */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-link {
  min-width: 34px; height: 34px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--border-2);
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: all .15s ease;
}
.page-link:hover  { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.page-link.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-link.disabled { opacity: .3; pointer-events: none; }

/* ══ FILTER BAR ════════════════════════════════════════════════ */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filter-bar .search-input { min-width: 240px; flex: 1; }

/* ══ IMAGES ════════════════════════════════════════════════════ */
.img-thumb { width: 42px; height: 42px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }

/* ══ MODAL ═════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px); animation: fadeIn .15s ease;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); max-width: 500px; width: 100%;
  box-shadow: var(--shadow); animation: slideUp .2s ease;
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border-2); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border-2); display: flex; justify-content: flex-end; gap: 10px; }

/* ══ INVOICE ═══════════════════════════════════════════════════ */
.invoice-wrapper { max-width: 960px; margin: 0 auto; }
.invoice-header-bar {
  background: linear-gradient(135deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--border-2); border-radius: var(--radius);
  padding: 24px 28px; margin-bottom: 20px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap;
}
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th {
  background: var(--bg-3); padding: 10px 12px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.detail-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); }
.detail-table tbody tr:hover td { background: rgba(232,86,42,.04); }
.detail-table tfoot td { padding: 9px 12px; font-weight: 600; border-top: 1px solid var(--border); }
.invoice-total-row { background: var(--accent-glow) !important; color: var(--accent-2); }
.totals-panel {
  min-width: 280px; background: var(--bg-3);
  border: 1px solid var(--border-2); border-radius: var(--radius); padding: 18px;
}
.totals-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; }
.totals-row.total-final {
  border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px;
  font-size: 1.1rem; font-weight: 700; color: var(--accent-2);
}
.product-row-delete { cursor: pointer; color: var(--danger); background: none; border: none; }

/* ══ UPLOAD ZONE ═══════════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 28px; text-align: center; cursor: pointer; transition: all var(--transition);
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-glow); }
.upload-preview { max-width: 120px; max-height: 120px; border-radius: var(--radius-sm); object-fit: cover; margin-top: 10px; }

/* ══ MISC ══════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { opacity: .3; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 6px; color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; background: var(--bg-3); border: 1px solid var(--border-2); font-size: 12px; color: var(--text-muted); }
.divider { height: 1px; background: var(--border-2); margin: 20px 0; }
.gain-bar-bg { height: 6px; background: var(--border-2); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.gain-bar-fill { height: 100%; border-radius: 3px; }
.loading-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }

/* ══ ANIMATIONS ════════════════════════════════════════════════ */
@keyframes fadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes slideUp { from { opacity:0; transform:translateY(20px) } to { opacity:1; transform:translateY(0) } }
@keyframes spin    { to { transform: rotate(360deg) } }

/* ══ PRINT ═════════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; }
}

/* ══ SIDEBAR OVERLAY ════════════════════════════════════════════ */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; }
.sidebar-overlay.show { display: block; }

/* ══ RESPONSIVE ════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main-content { margin-left: 0 !important; }
  .menu-toggle { display: flex; }
  .auth-wrapper { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .page-body { padding: 16px; }
  /* En mobile nunca usar collapsed */
  .sidebar.collapsed { width: var(--sidebar-w) !important; }
  .sidebar.collapsed .nav-label, .sidebar.collapsed .sidebar-logo,
  .sidebar.collapsed .sidebar-logo-sub, .sidebar.collapsed .nav-section-title,
  .sidebar.collapsed .user-info { opacity: 1 !important; width: auto !important; overflow: visible !important; }
  .sidebar.collapsed .nav-item { justify-content: flex-start !important; padding: 9px 16px !important; gap: 10px !important; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
