@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&display=swap');

/* Tema Oscuro (por defecto) */
:root{
  --bg:#2f3a4b;
  --sidebar:#2b3444;
  --topbar:#2f3a4b;
  --card:#364154;
  --card2:#3b465a;
  --border:rgba(255,255,255,.08);
  --text:#e8eefc;
  --muted:#a7b3c7;
  --blue:#2b93ff;
  --blue2:#1f7fe6;
  --danger:#ff5a5a;
  --shadow:0 14px 40px rgba(0,0,0,.28);
  --radius:6px;
  --input:#e8f0fe;
}

/* =========================
   CIERRES DE CAJA (MODULO)
   ========================= */
.cierre-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 1.15fr);
  gap: 18px;
  align-items: start;
}

.cierre-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.02) 0%, rgba(255,255,255,.00) 70%);
  padding: 16px;
}

.cierre-form-panel #cierreForm > .cierre-step,
.cierre-form-panel #cierreForm > .cierre-resumen-live,
.cierre-form-panel #cierreForm > .actions-right {
  grid-column: 1 / -1;
}

.cierre-form-panel #cierreForm {
  row-gap: 12px;
}

.cierre-panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: .2px;
}

.cierre-panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.cierre-step {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
  padding: 12px;
  margin-top: 10px;
}

.cierre-step .grid {
  align-items: end;
}

.cierre-step-fecha .grid {
  align-items: start;
}

.cierre-step-fecha .field input {
  text-align: center;
  font-weight: 700;
  letter-spacing: .2px;
}

.cierre-step-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .18px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.turno-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.turno-btn {
  border: 1px solid var(--border);
  background: var(--card2);
  border-radius: 10px;
  padding: 10px 8px;
  color: var(--text);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.turno-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.45);
}

.turno-btn.active {
  border-color: #f4f4f4;
  background: rgba(255,255,255,.14);
  box-shadow: inset 2px 0 0 #ffffff;
}

.turno-btn .turno-name {
  display: block;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 3px;
}

.turno-btn .turno-time {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.cierre-quick-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.cierre-page-card :focus-visible {
  outline: 2px solid #9fd0ff;
  outline-offset: 2px;
}

.turno-btn,
.btn-kpi-usar,
.cierre-kpi-actions .btn,
.cierre-quick-actions .btn,
.actions-right .btn {
  min-height: 42px;
}

#cierreForm .field input,
#cierreForm .field select,
#cierreForm .field textarea,
.cierre-kpi-filters .field input,
.cierre-kpi-filters .field select {
  min-height: 44px;
}

.cierre-resumen-live {
  border: 1px dashed rgba(255,255,255,.35);
  border-radius: 12px;
  padding: 11px 12px;
  margin-top: 8px;
}

.resumen-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .35px;
  color: var(--muted);
}

.resumen-line {
  margin-top: 6px;
  font-size: 13px;
}

.resumen-line.strong {
  font-weight: 700;
  font-size: 15px;
}

.cierre-kpi-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.kpi-chip {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(255,255,255,.02);
}

.kpi-chip span {
  display: block;
  font-size: 11px;
  letter-spacing: .25px;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-chip strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.kpi-chip.pendiente strong { color: #f59e0b; }
.kpi-chip.ok strong { color: #10b981; }
.kpi-chip.duplicado strong { color: #ef4444; }

.cierre-kpi-filters {
  margin-top: 12px;
}

.cierre-kpi-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.cierre-kpi-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
  padding-right: 2px;
}

.kpi-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--card2);
}

.kpi-row.pendiente {
  border-color: rgba(245, 158, 11, .45);
  background: rgba(245, 158, 11, .08);
}

.kpi-row.ok {
  border-color: rgba(16, 185, 129, .45);
  background: rgba(16, 185, 129, .08);
}

.kpi-row.duplicado {
  border-color: rgba(239, 68, 68, .5);
  background: rgba(239, 68, 68, .09);
}

.kpi-row-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 12px;
}

.kpi-turno {
  color: var(--muted);
}

.kpi-status {
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .24px;
}

.kpi-status.pendiente { color: #f59e0b; }
.kpi-status.ok { color: #10b981; }
.kpi-status.duplicado { color: #ef4444; }

.kpi-row-meta {
  margin-top: 4px;
  font-size: 12px;
}

.kpi-row-detail {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.kpi-row-subdetail {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}

.kpi-dup {
  color: #ef4444;
  font-size: 11px;
  font-weight: 700;
}

.kpi-empty,
.kpi-loading {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

html[data-theme="light"] .turno-btn.active {
  border-color: #111111;
  background: rgba(0,0,0,.08);
  box-shadow: inset 2px 0 0 #111111;
}

html[data-theme="light"] .cierre-resumen-live {
  border-color: rgba(0,0,0,.25);
}

@media (max-width: 1200px) {
  .cierre-layout {
    grid-template-columns: 1fr;
  }

  .cierre-kpi-list {
    max-height: none;
  }
}

@media (max-width: 700px) {
  .cierre-panel {
    padding: 12px;
  }

  .cierre-step {
    padding: 10px;
  }

  .turno-picker {
    grid-template-columns: 1fr;
  }

  .cierre-step-fecha .grid .field,
  .cierre-kpi-filters .field {
    grid-column: span 12;
  }

  .cierre-kpi-summary {
    grid-template-columns: 1fr;
  }

  .kpi-row {
    grid-template-columns: 1fr;
  }

  .kpi-row-actions {
    justify-self: start;
  }

  .kpi-row-actions .btn {
    width: 100%;
  }

  .cierre-kpi-actions {
    justify-content: stretch;
  }

  .cierre-kpi-actions .btn {
    flex: 1 1 100%;
  }
}

/* Tema Claro */
[data-theme="light"]{
  --bg:#f5f7fa;
  --sidebar:#ffffff;
  --topbar:#ffffff;
  --card:#ffffff;
  --card2:#f8f9fb;
  --border:rgba(0,0,0,.08);
  --text:#1a202c;
  --muted:#475569;
  --blue:#2b93ff;
  --blue2:#1f7fe6;
  --danger:#ff5a5a;
  --shadow:0 2px 8px rgba(0,0,0,.08);
  --radius:6px;
  --input:#1a202c;
}

/* Sobreescrituras específicas para tema claro (mejorar legibilidad) */
[data-theme="light"] .section-subtitle {
  color: #334155;
}

[data-theme="light"] .section-title {
  color: #0f172a;
}

[data-theme="light"] .table th {
  background: rgba(0,0,0,.05);
  color: #0f172a;
}

[data-theme="light"] .note {
  color: #475569;
}

[data-theme="light"] .nav-item {
  color: #334155;
}

[data-theme="light"] .nav-item:hover {
  color: #0f172a;
}

[data-theme="light"] .nav-item.active {
  color: #0f172a;
}

[data-theme="light"] .user-badge {
  color: #334155;
}

[data-theme="light"] .brand {
  color: #0f172a;
}

[data-theme="light"] .topbar-right {
  color: #334155;
}

[data-theme="light"] label {
  color: #1e293b;
}

[data-theme="light"] .mobile-item {
  color: #334155;
  background: rgba(0,0,0,.03);
  border: 1px solid rgba(0,0,0,.1);
  font-weight: 600;
}

[data-theme="light"] .mobile-item:hover {
  color: #1e293b;
  background: rgba(0,0,0,.06);
  border-color: rgba(0,0,0,.15);
}

[data-theme="light"] .mobile-item.active {
  color: #1e40af;
  background: rgba(37,99,235,.1);
  border-color: rgba(37,99,235,.3);
  font-weight: 700;
}

/* Mejorar topbar en tema claro */
[data-theme="light"] .topbar {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-bottom: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

[data-theme="light"] .nav-item {
  color: #475569;
  font-weight: 600;
}

[data-theme="light"] .nav-item:hover {
  background: rgba(0,0,0,.06);
  color: #1e293b;
}

[data-theme="light"] .nav-item.active {
  background: rgba(37,99,235,.1);
  color: #1e40af;
  font-weight: 700;
}

[data-theme="light"] .user-badge {
  background: rgba(0,0,0,.05);
  border: 1px solid rgba(0,0,0,.1);
  color: #334155;
  font-weight: 600;
}

[data-theme="light"] .btn-logout {
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

[data-theme="light"] .btn-logout:hover {
  background: #1d4ed8;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}

/* Mobile drawer en tema claro */
[data-theme="light"] .mobile-drawer {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-left: 1px solid rgba(0,0,0,.12);
  box-shadow: -2px 0 8px rgba(0,0,0,.1);
}

[data-theme="light"] .mobile-drawer-head {
  border-bottom: 1px solid rgba(0,0,0,.12);
}

[data-theme="light"] .drawer-close {
  border: 1px solid rgba(0,0,0,.15);
  background: rgba(0,0,0,.05);
  color: #1e293b;
}

[data-theme="light"] .drawer-close:hover {
  background: rgba(0,0,0,.08);
  border-color: rgba(0,0,0,.2);
}

[data-theme="light"] .drawer-overlay {
  background: rgba(0,0,0,.3);
}

/* Asegurar inputs legibles en tema claro */
[data-theme="light"] .field input,
[data-theme="light"] .field select,
[data-theme="light"] .field textarea {
  background: rgba(0,0,0,.04);
  color: #0f172a !important;
  border: 1px solid rgba(0,0,0,.15);
}

[data-theme="light"] .field input::placeholder,
[data-theme="light"] .field textarea::placeholder {
  color: #94a3b8;
}

[data-theme="light"] .field select option {
  background-color: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .modal-content {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.1);
}

[data-theme="light"] .modal-header {
  border-bottom: 1px solid rgba(0,0,0,.1);
}

[data-theme="light"] .modal-header h3 {
  color: #0f172a;
}

[data-theme="light"] .modal-footer {
  background: rgba(0,0,0,.02);
  border-top: 1px solid rgba(0,0,0,.1);
}

[data-theme="light"] .btn-close {
  color: #475569;
}

[data-theme="light"] .btn-close:hover {
  background: rgba(0,0,0,.08);
  color: #0f172a;
}

[data-theme="light"] .password-toggle {
  color: #475569 !important;
  opacity: 0.8 !important;
}

[data-theme="light"] .password-toggle:hover {
  opacity: 1 !important;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: 'Manrope', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Login ---------- */
.login-wrap{
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.login-card{
  width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card .login-body{
  padding:26px;
}
.login-icon{
  width:64px;height:64px;border-radius:50%;
  border:2px solid rgba(255,255,255,.35);
  display:flex;align-items:center;justify-content:center;
  margin: 8px auto 14px;
  opacity:.9;
}
.login-title{
  text-align:center;
  font-weight:700;
  margin:0 0 16px;
}
.login-field{
  margin: 10px 0;
}
.login-field-error{
  margin-top: 6px;
  margin-left: 2px;
  line-height: 1.35;
  font-size: 12px;
  font-weight: 600;
}
.login-field .input.input-invalid,
.login-card .input:has(input.input-invalid){
  border-color: #ef4444;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.35);
}
.remember-login{
  display:flex;
  align-items:center;
  gap:8px;
  margin:12px 0 14px;
  cursor:pointer;
  font-size:13px;
  color:var(--muted);
  user-select:none;
}
.remember-login input{
  width:16px;
  height:16px;
  cursor:pointer;
  flex: 0 0 auto;
}
.input{
  width:100%;
  display:flex;
  align-items:center;
  background: var(--input);
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
  overflow:hidden;
  margin: 0;
  position: relative;
}
.input span{
  width:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#6b7280;
  flex: 0 0 auto;
}
.input input{
  width:100%;
  border:0;
  padding:12px 10px;
  outline:none;
  background:transparent;
  min-width: 0;
}
.login-input-password input{
  padding-right: 48px;
}

/* Botón de mostrar/ocultar contraseña */
.password-toggle {
  position: absolute !important;
  background: none !important;
  border: none !important;
  cursor: pointer !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: .3px !important;
  padding: 4px !important;
  opacity: 0.6 !important;
  transition: opacity 0.2s !important;
  z-index: 10 !important;
  line-height: 1 !important;
}

.password-toggle:hover {
  opacity: 1 !important;
}

/* Para el login (dentro de .input) */
.input .password-toggle {
  right: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
}

/* Para campos normales (field) */
.field .password-toggle {
  right: 8px !important;
  top: 34px !important;
}
.btn{
  border:0;
  cursor:pointer;
  border-radius:2px;
  padding:12px 14px;
  font-weight:700;
}
.btn-primary{
  background: var(--blue);
  color:#fff;
}
.btn-primary:hover{ background: var(--blue2); }

.shortcut-hint{
  font-size: 0.72em;
  opacity: 0.6;
  margin-left: 6px;
  font-weight: 400;
}

/* ---------- Cards + Form ---------- */
.card{
  background: var(--card);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
  margin-bottom:16px;
}
.card-header{
  padding:12px 14px;
  background: var(--card2);
  border-bottom:1px solid var(--border);
  font-weight:700;
}
.card-body{ padding:14px; }

.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:12px;
}
.field{ grid-column: span 12; }
.span12{ grid-column: span 12; }
@media (min-width: 980px){
  .span6{ grid-column: span 6; }
  .span4{ grid-column: span 4; }
  .span3{ grid-column: span 3; }
  .span8{ grid-column: span 8; }
  .span9{ grid-column: span 9; }
}
label{
  display:block;
  font-size:12px;
  color: var(--muted);
  margin: 0 0 6px;
  min-height: 18px;
}

/* Clearfix para labels con elementos flotantes (checkbox Recordar) */
.field > label {
  overflow: hidden;
  line-height: 18px;
  position: relative;
}

.field > label::after {
  content: "";
  display: table;
  clear: both;
}

/* Asegurar que labels anidados no aumenten la altura */
.field > label > label {
  position: absolute;
  right: 0;
  top: 0;
  margin: 0;
  line-height: 18px;
}
.field input, .field select, .field textarea{
  width:100%;
  padding:10px 10px;
  border-radius:3px;
  border:1px solid rgba(255,255,255,.22);
  outline:none;
  background: rgba(255,255,255,.04);
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: rgba(255,255,255,.34);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #ffffff;
  background: rgba(255,255,255,.07);
  box-shadow: 0 0 0 3px rgba(255,255,255,.14);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a8a8ac;
}
.field select option {
  background-color: var(--card);
  color: var(--text);
}
.field textarea{ min-height: 90px; resize: vertical; }

/* Dropzone — drag & drop comprobante */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.dropzone:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, .05);
}
.dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(99, 102, 241, .1);
}
.dropzone.has-file {
  border-color: #10b981;
  background: rgba(16, 185, 129, .06);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.dropzone-icon { font-size: 28px; }
.dropzone-text {
  font-size: 13px;
  color: var(--muted);
}

/* Validación en tiempo real */
.field input.error,
.field select.error,
.field textarea.error {
  border-color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.1) !important;
}

.field input.success,
.field select.success {
  border-color: #22c55e !important;
}

/* Estilo para select de turno automático */
.field select.turno-auto {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--text);
  font-weight: 500;
  cursor: default;
  opacity: 1;
}

.field select.turno-auto:disabled {
  opacity: 1;
  -webkit-text-fill-color: var(--text);
}

.field-error {
  color: #ef4444;
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.field input.input-invalid,
.field textarea.input-invalid,
.login-card input.input-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.35);
}

.field-success {
  color: #22c55e;
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
}
.btn-ghost{
  background: rgba(255,255,255,.06);
  color: var(--text);
  border:1px solid var(--border);
}
.btn-danger{
  background: rgba(255,90,90,.14);
  color:#ffd2d2;
  border:1px solid rgba(255,90,90,.35);
}

.note{
  font-size:12px;
  color: var(--muted);
}

/* ===============================
   LAYOUT SIN SIDEBAR (EGRESOS)
   =============================== */
.app-nosidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- TOPBAR ---------- */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.brand-pill { font-weight: 800; color: #9fd0ff; }

/* ---------- TOP NAV ---------- */
.topnav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.12);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  transition: background .15s ease, border-color .15s ease;
}
.topnav a:hover { background: rgba(255,255,255,.08); }
.topnav a.active {
  background: rgba(43,147,255,.18);
  border-color: rgba(43,147,255,.35);
  color: #cfe6ff;
}

/* ---------- CONTENT ---------- */
.content-wrap {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}
.page {
  max-width: 1180px;
  margin: 0 auto;
}

/* ---------- UTILS ---------- */
.hidden { display: none !important; }

/* ===============================
   NUEVO: SECCIONES DEL FORM
   =============================== */
.section{
  grid-column: span 12;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,.06);
  overflow: hidden;
}
.section-head{
  padding: 12px 14px;
  background: rgba(0,0,0,.10);
  border-bottom: 1px solid var(--border);
  display:flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title{
  font-weight: 800;
  font-size: 14px;
  color: #dbe8ff;
}
.section-subtitle{
  font-size: 12px;
  color: var(--muted);
}
.section-body{
  padding: 12px 14px;
}

/* Sticky actions */
.actions-sticky{
  position: sticky;
  bottom: 10px;
  z-index: 10;
  padding: 10px 12px;
  background: rgba(25,30,40,.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
}
.actions-left{
  max-width: 700px;
}
.actions-right{
  display:flex;
  gap:10px;
  align-items:center;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 900px) {
  .topbar {
    height: auto;
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .topbar-right { align-self: flex-end; }
  .topnav a { font-size: 12px; padding: 6px 10px; }
}
@media (max-width: 600px) {
  .page { padding: 0; }
  .actions-sticky{
    bottom: 8px;
  }
}

/* ===== Usuarios (tabla) ===== */
.table-wrap{
  width:100%;
  overflow:auto;
  border:1px solid var(--border);
  border-radius:10px;
  background: rgba(0,0,0,.06);
}

.table{
  width:100%;
  border-collapse: collapse;
  min-width: 860px;
}
.table th, .table td{
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-align: left;
  font-size: 13px;
}
.table th{
  background: rgba(0,0,0,.10);
  color: #dbe8ff;
  font-weight: 800;
}
.table td.muted{
  color: var(--muted);
}
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 4px 8px;
  border-radius: 999px;
  border:1px solid var(--border);
  font-size: 12px;
}
.badge.ok{ background: rgba(40,180,99,.12); }
.badge.no{ background: rgba(255,90,90,.12); }

.users-toolbar{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.users-search{
  flex: 1;
  min-width: 240px;
  padding: 10px 10px;
  border-radius: 8px;
  border:1px solid rgba(255,255,255,.22);
  outline:none;
  background: rgba(255,255,255,.04);
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.users-search:hover {
  border-color: rgba(255,255,255,.34);
}

.users-search:focus {
  border-color: #ffffff;
  background: rgba(255,255,255,.07);
  box-shadow: 0 0 0 3px rgba(255,255,255,.14);
}
.row-actions{
  display:flex;
  gap:8px;
  flex-wrap: wrap;
}
.btn-small{
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 8px;
}

/* Logs: que el detalle no rompa la tabla */
.table td[title]{
  cursor: help;
}

/* =========================
   TOPBAR – REDISEÑO
   ========================= */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, #1e2430 0%, #1b2130 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.topbar-inner{
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}

/* Marca */
.brand{
  display: flex;
  align-items: center;
}

/* Indicador de conexión */
#connectionDot{
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  transition: background-color 0.3s;
}
.conn-ok{ background: #28a745; }
.conn-warn{ background: #ffc107; animation: pulse-dot 1.5s infinite; }
.conn-off{ background: #dc3545; }
@keyframes pulse-dot{
  0%,100%{ opacity:1; }
  50%{ opacity:0.4; }
}

.brand-name{
  font-weight: 800;
  letter-spacing: .3px;
  color: #e8eefc;
  font-size: 18px;
}

/* Navegación */
.nav-main{
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-item{
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  color: #c9d4ea;
  border: 1px solid transparent;
  transition: all .15s ease;
}

.nav-item:hover{
  background: rgba(255,255,255,.06);
  color: #ffffff;
}

.nav-item.active{
  background: rgba(59,130,246,.18);
  border-color: rgba(59,130,246,.35);
  color: #eaf2ff;
}

/* Acciones */
.nav-actions{
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill{
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
}

/* Botón compacto */
.btn-compact{
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 999px;
}

/* Responsive */
@media (max-width: 900px){
  .topbar-inner{
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .nav-main{
    justify-content: flex-start;
  }
  .nav-actions{
    justify-content: flex-end;
  }
}

/* =========================
   TOPBAR – ALINEACIÓN FINAL
   ========================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg, #1c2330, #1a202c);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 64px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 20px;
}

/* Marca */
.topbar-left {
  display: flex;
  align-items: center;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  color: #e5e7eb;
}

/* Navegación */
.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;

  height: 36px;
  padding: 0 16px;

  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;

  color: #cbd5e1;
  background: transparent;
  border: none;
  cursor: pointer;

  transition: background .15s ease, color .15s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-item.active {
  background: rgba(59,130,246,.22);
  color: #eaf2ff;
}

/* Acciones */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;

  font-size: 12px;
  line-height: 1;
  color: #cbd5e1;

  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;

  height: 36px;
  padding: 0 18px;

  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;

  background: #2563eb;
  color: #fff;
  border: none;
  cursor: pointer;
}

.btn-logout:hover {
  background: #1d4ed8;
}

/* Botón de tema claro/oscuro */
.btn-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-theme:hover {
  background: rgba(255,255,255,.15);
  transform: scale(1.05);
}

.btn-theme:active {
  transform: scale(0.95);
}

[data-theme="light"] .btn-theme {
  background: rgba(0,0,0,.08);
  border: 1px solid rgba(0,0,0,.15);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

[data-theme="light"] .btn-theme:hover {
  background: rgba(0,0,0,.14);
  border-color: rgba(0,0,0,.2);
  box-shadow: 0 2px 4px rgba(0,0,0,.08);
}

/* Responsive */
@media (max-width: 900px) {
  .topbar-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px;
    gap: 10px;
  }

  .topbar-center {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-end;
  }
}


/* =========================
   MOBILE NAV (hamburger + drawer)
   ========================= */
.hamburger{
  display:none;
  flex-direction:column;
  width:42px;
  height:42px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  cursor:pointer;
  align-items:center;
  justify-content:center;
  gap:5px;
  transition: all 0.3s ease;
}
.hamburger:hover{
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.20);
}
.hamburger span{
  display:block;
  width:20px;
  height:2.5px;
  background:#e5e7eb;
  border-radius:2px;
  transition: all 0.3s ease;
}
.hamburger:active span{
  background:#fff;
}

.mobile-drawer{
  position: fixed;
  top:0;
  right:-320px;
  width: 320px;
  max-width: 90vw;
  height: 100vh;
  background: linear-gradient(180deg, #1c2330, #1a202c);
  border-left: 1px solid rgba(255,255,255,.08);
  z-index: 200;
  transition: right .2s ease;
  display:flex;
  flex-direction: column;
  padding: 14px;
  gap: 14px;
}
.mobile-drawer.open{
  right:0;
}

.drawer-overlay{
  position: fixed;
  inset:0;
  background: rgba(0,0,0,.45);
  z-index: 150;
  opacity:0;
  pointer-events:none;
  transition: opacity .2s ease;
}
.drawer-overlay.show{
  opacity:1;
  pointer-events:auto;
}

.mobile-drawer-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap:10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.drawer-close{
  width:42px;
  height:42px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  color:#e5e7eb;
  cursor:pointer;
  font-size: 16px;
}

.mobile-nav{
  display:flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-item{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color:#e5e7eb;
  text-decoration:none;
  font-weight:700;
  font-size: 14px;
  cursor:pointer;
}
.mobile-item:hover{
  background: rgba(255,255,255,.08);
}
.mobile-item.active{
  background: rgba(59,130,246,.22);
  border-color: rgba(59,130,246,.35);
}
.mobile-btn{
  border:1px solid rgba(255,255,255,.10);
}

.mobile-actions{
  margin-top:auto;
  display:flex;
  flex-direction: column;
  gap: 10px;
}

/* =========================
   MOBILE SAVE BAR
   ========================= */
.mobile-savebar{
  display:none;
  position: sticky;
  bottom: 0;
  margin-top: 10px;
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(26,32,44,0) 0%, rgba(26,32,44,.95) 35%, rgba(26,32,44,.98) 100%);
  border-top: 1px solid rgba(255,255,255,.08);
}
.mobile-savebtn{
  width:100%;
  height: 44px;
  border-radius: 14px;
}

/* =========================
   RESPONSIVE SWITCH
   ========================= */
@media (max-width: 900px){
  .nav-desktop{ display:none !important; }
  .hamburger{ display:flex; }

  /* en mobile conviene que la topbar sea más compacta */
  .topbar-inner{
    height: 56px;
    padding: 0 14px;
  }

  /* mostrar barra de guardar */
  .mobile-savebar{ display:block; }

  /* asegurar que el contenido no quede tapado por la barra de guardar */
  .content-wrap{
    padding-bottom: 90px;
  }
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  position: relative;
  z-index: 10000;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  pointer-events: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--card2);
}

/* Validación de formularios */
.validation-error {
  color: #dc3545;
  font-weight: 500;
  padding: 4px 8px;
  background: #fee2e2;
  border-left: 3px solid #dc3545;
  border-radius: 4px;
}

.validation-success {
  color: #28a745;
  font-weight: 500;
  padding: 4px 8px;
  background: #d1fae5;
  border-left: 3px solid #28a745;
  border-radius: 4px;
}

/* Sistema de notificaciones */
.btn-notification {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .2s, border-color .2s, color .2s;
  min-height: 36px;
  line-height: 1;
}

.btn-notification .notif-bell {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: block;
}

.btn-notification .notif-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .92;
}

.btn-notification:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
}

[data-theme="light"] .btn-notification:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
}

.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #dc3545;
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}

.notification-panel {
  position: fixed;
  top: 70px;
  right: 20px;
  width: 380px;
  max-height: 500px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.notification-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.notification-panel-header h3 {
  margin: 0;
  font-size: 18px;
  color: #1f2937;
}

.close-notification-panel {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.close-notification-panel:hover {
  background: #f3f4f6;
  color: #1f2937;
}

.notification-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: 400px;
}

.notification-empty {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
  font-size: 14px;
}

.notification-item {
  padding: 12px;
  margin-bottom: 8px;
  background: #f9fafb;
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
  cursor: pointer;
  transition: all 0.2s;
}

.notification-item:hover {
  background: #f3f4f6;
}

.notification-item.unread {
  background: #eff6ff;
  border-left-color: #2563eb;
}

.notification-item.success {
  border-left-color: #10b981;
}

.notification-item.warning {
  border-left-color: #f59e0b;
}

.notification-item.error {
  border-left-color: #ef4444;
}

.notification-title {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
  margin-bottom: 4px;
}

.notification-message {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 4px;
}

.notification-time {
  font-size: 11px;
  color: #9ca3af;
}

.notification-panel-footer {
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
}

.btn-clear-notifications {
  width: 100%;
  padding: 8px;
  background: #f3f4f6;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear-notifications:hover {
  background: #e5e7eb;
  color: #1f2937;
}

/* Toast notifications - Diseño oscuro, simple y formal */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  min-width: 320px;
  background: #1a1a1a;
  padding: 14px 16px;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  border-left: 3px solid #3b82f6;
  animation: slideIn 0.3s ease-out;
  display: flex;
  align-items: start;
  gap: 12px;
  backdrop-filter: blur(10px);
}

.toast.success {
  border-left-color: #10b981;
}

.toast.warning {
  border-left-color: #f59e0b;
}

.toast.error {
  border-left-color: #ef4444;
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 13px;
  color: #f5f5f5;
  margin-bottom: 3px;
  line-height: 1.3;
}

.toast-message {
  font-size: 12px;
  color: #b0b0b0;
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s ease;
  opacity: 0.7;
}

.toast-close:hover {
  color: #f5f5f5;
  opacity: 1;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .modal-content {
    max-width: 100%;
    max-height: 95vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-header h3 {
    font-size: 18px;
  }

  .modal-body {
    padding: 16px;
  }
}

/* =========================
   REFRESH VISUAL CASINO
   ========================= */
:root {
  --bg: #0f0f10;
  --sidebar: #141415;
  --topbar: #171718;
  --card: #1c1c1d;
  --card2: #222224;
  --border: rgba(255,255,255,.14);
  --text: #f2f2f2;
  --muted: #b5b5b8;
  --blue: #d6d6d8;
  --blue2: #ffffff;
  --danger: #8d8d90;
  --shadow: 0 18px 40px rgba(0,0,0,.45);
  --radius: 10px;
  --input: #ececef;
}

body {
  background:
    radial-gradient(circle at 15% -10%, rgba(255,255,255,.08), transparent 28%),
    radial-gradient(circle at 90% 0%, rgba(255,255,255,.05), transparent 24%),
    var(--bg);
}

.topbar {
  background: rgba(20,20,21,.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.topbar-inner {
  max-width: 1320px;
  height: 68px;
  padding: 0 24px;
  gap: 14px;
}

.brand {
  font-size: 22px;
  letter-spacing: .5px;
  color: #ffffff;
}

.topbar-center {
  flex: 1;
  justify-content: center;
}

.nav-item {
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #cfcfd2;
  text-transform: uppercase;
  letter-spacing: .3px;
  font-size: 12px;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.18);
}

.nav-item.active {
  background: #f5f5f5;
  color: #111111;
  border-color: #f5f5f5;
}

.user-badge {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.14);
  color: #cfcfd2;
}

.btn-logout,
.btn-primary {
  background: #efefef;
  color: #141414;
  border: 1px solid #efefef;
}

.btn-logout:hover,
.btn-primary:hover {
  background: #ffffff;
  color: #000000;
}

.btn-theme {
  width: auto;
  min-width: 70px;
  height: 36px;
  border-radius: 7px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.18);
  color: #d8d8da;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 0 10px;
}

.btn-theme:hover {
  transform: none;
  background: rgba(255,255,255,.12);
}

.mobile-drawer {
  background: #161617;
  border-left: 1px solid rgba(255,255,255,.14);
}

.mobile-item.active {
  background: #f2f2f2;
  color: #111111;
  border-color: #f2f2f2;
}

.card-header,
.section-head,
.table th {
  color: #f8f8f8;
}

.section-title,
.table th {
  color: #ffffff;
}

/* Correcciones específicas para modo claro */
[data-theme="light"] {
  --bg: #f3f4f6;
  --sidebar: #ffffff;
  --topbar: #ffffff;
  --card: #ffffff;
  --card2: #f8f8f9;
  --border: rgba(0,0,0,.15);
  --text: #131313;
  --muted: #5f636a;
  --blue: #2f343a;
  --blue2: #111111;
  --danger: #6f737a;
  --shadow: 0 10px 28px rgba(0,0,0,.10);
  --input: #111111;
}

[data-theme="light"] body {
  background:
    radial-gradient(circle at 15% -10%, rgba(0,0,0,.07), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(0,0,0,.05), transparent 24%),
    var(--bg);
}

[data-theme="light"] .topbar {
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid rgba(0,0,0,.12);
}

[data-theme="light"] .brand,
[data-theme="light"] .section-title,
[data-theme="light"] .card-header,
[data-theme="light"] .table th {
  color: #111111;
}

[data-theme="light"] .nav-item {
  color: #3f454c;
  border-color: transparent;
}

[data-theme="light"] .nav-item:hover {
  background: rgba(0,0,0,.06);
  border-color: rgba(0,0,0,.12);
}

[data-theme="light"] .nav-item.active {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

[data-theme="light"] .user-badge {
  background: rgba(0,0,0,.04);
  border: 1px solid rgba(0,0,0,.12);
  color: #2f343a;
}

[data-theme="light"] .btn-theme {
  background: #f3f4f6;
  border-color: rgba(0,0,0,.16);
  color: #1a1a1a;
}

[data-theme="light"] .btn-theme:hover {
  background: #eceef1;
}

[data-theme="light"] .btn-logout,
[data-theme="light"] .btn-primary {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

[data-theme="light"] .btn-logout:hover,
[data-theme="light"] .btn-primary:hover {
  background: #000000;
  color: #ffffff;
}

[data-theme="light"] .mobile-drawer {
  background: #ffffff;
  border-left: 1px solid rgba(0,0,0,.12);
}

[data-theme="light"] .mobile-item.active {
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

/* =========================
   LEFT SIDEBAR NAV (desktop)
   ========================= */
@media (min-width: 901px) {
  .app-nosidebar {
    display: block;
    min-height: 100vh;
    --sidebar-width: 252px;
  }

  .app-nosidebar .topbar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    height: 100vh;
    border-right: 1px solid var(--border);
    border-bottom: none;
    background: rgba(20,20,21,.96);
    padding: 18px 14px;
    z-index: 120;
    transition: width .22s ease;
  }

  .app-nosidebar .topbar-inner {
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .app-nosidebar .topbar-left {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 8px 12px;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-collapse-btn {
    height: 30px;
    min-width: 82px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.05);
    color: var(--text);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .35px;
    cursor: pointer;
  }

  .sidebar-collapse-btn:hover {
    background: rgba(255,255,255,.12);
  }

  .app-nosidebar .brand {
    font-size: 24px;
    line-height: 1.1;
    letter-spacing: 0.4px;
  }

  .app-nosidebar .hamburger {
    display: none !important;
  }

  .app-nosidebar .mobile-drawer,
  .app-nosidebar .drawer-overlay {
    display: none !important;
  }

  .app-nosidebar .topbar-center.nav-desktop {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    flex: 1;
    gap: 8px;
    overflow-y: auto;
    padding: 4px;
  }

  .app-nosidebar .topbar-center.nav-desktop .nav-item {
    width: 100%;
    min-height: 42px;
    justify-content: flex-start;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 0 12px;
    font-size: 12px;
    position: relative;
    gap: 8px;
  }

  .app-nosidebar .topbar-center.nav-desktop .nav-item::before {
    content: 'MN';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .25px;
    color: #ffffff;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.15);
    flex-shrink: 0;
  }

  .app-nosidebar .topbar-center.nav-desktop .nav-item[href*="egreso.html"]::before { content: 'RT'; }
  .app-nosidebar .topbar-center.nav-desktop .nav-item[href*="consulta-egresos.html"]::before { content: 'HS'; }
  .app-nosidebar .topbar-center.nav-desktop .nav-item[href*="flujo-usd.html"]::before { content: 'FX'; }
  .app-nosidebar .topbar-center.nav-desktop .nav-item[href*="cierres-caja.html"]::before { content: 'CJ'; }
  .app-nosidebar .topbar-center.nav-desktop .nav-item[href*="saldos.html"]::before { content: 'SD'; }
  .app-nosidebar .topbar-center.nav-desktop .nav-item[href*="usuarios.html"]::before { content: 'US'; }
  .app-nosidebar .topbar-center.nav-desktop .nav-item[href*="logs.html"]::before { content: 'LG'; }

  .app-nosidebar .topbar-center.nav-desktop .nav-item:hover {
    border-color: rgba(255,255,255,.18);
  }

  .app-nosidebar .topbar-center.nav-desktop .nav-item.active {
    border-color: rgba(255,255,255,.35);
    box-shadow: inset 3px 0 0 #ffffff;
    background: rgba(255,255,255,.16);
    color: #ffffff;
  }

  .app-nosidebar .topbar-center.nav-desktop .nav-item.active::before {
    background: #ffffff;
    border-color: #ffffff;
    color: #111111;
  }

  .app-nosidebar .topbar-right.nav-desktop {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: auto;
    padding: 10px 4px 0;
    border-top: 1px solid var(--border);
  }

  .app-nosidebar .topbar-right.nav-desktop .btn-theme,
  .app-nosidebar .topbar-right.nav-desktop .btn-logout,
  .app-nosidebar .topbar-right.nav-desktop .btn-notification,
  .app-nosidebar .topbar-right.nav-desktop .user-badge {
    width: 100%;
    justify-content: center;
    min-height: 36px;
    border-radius: 8px;
  }

  .app-nosidebar .topbar-right.nav-desktop .btn-notification {
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.04);
    order: -1;
  }

  [data-theme="light"] .app-nosidebar .topbar-right.nav-desktop .btn-notification {
    border-color: rgba(0,0,0,.14);
    background: rgba(0,0,0,.03);
  }

  .app-nosidebar .content-wrap {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 20px 22px;
    transition: margin-left .22s ease;
  }

  .app-nosidebar .page {
    max-width: 1260px;
  }

  [data-theme="light"] .app-nosidebar .topbar {
    background: rgba(255,255,255,.95);
    border-right: 1px solid rgba(0,0,0,.12);
  }

  [data-theme="light"] .sidebar-collapse-btn {
    background: rgba(0,0,0,.04);
    border-color: rgba(0,0,0,.16);
    color: #111111;
  }

  [data-theme="light"] .sidebar-collapse-btn:hover {
    background: rgba(0,0,0,.08);
  }

  [data-theme="light"] .app-nosidebar .topbar-center.nav-desktop .nav-item::before {
    background: rgba(0,0,0,.08);
    border-color: rgba(0,0,0,.12);
    color: #111111;
  }

  [data-theme="light"] .app-nosidebar .topbar-center.nav-desktop .nav-item.active {
    background: #111111;
    color: #ffffff;
    border-color: #111111;
    box-shadow: inset 3px 0 0 #ffffff;
  }

  [data-theme="light"] .app-nosidebar .topbar-center.nav-desktop .nav-item.active::before {
    background: #ffffff;
    color: #111111;
    border-color: #ffffff;
  }

  html.sidebar-collapsed .app-nosidebar {
    --sidebar-width: 80px;
  }

  html.sidebar-collapsed .app-nosidebar .topbar {
    padding: 8px 0;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-left {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0 10px;
  }

  html.sidebar-collapsed .app-nosidebar .brand {
    display: none;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-center.nav-desktop {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 2px 0;
    overflow-y: auto;
    overflow-x: hidden;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-center.nav-desktop .nav-item {
    width: 42px;
    height: 42px;
    min-height: 42px;
    display: grid;
    place-items: center;
    gap: 0;
    padding: 0;
    font-size: 0;
    line-height: 0;
    color: transparent;
    text-indent: 0;
    border-radius: 10px;
    overflow: hidden;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-center.nav-desktop .nav-item::before {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-center.nav-desktop .nav-item.active {
    box-shadow: none;
    border-color: rgba(255,255,255,.45);
  }

  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop {
    width: 100%;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0 0;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-theme,
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-logout,
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .user-badge {
    width: 42px;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    min-width: 0;
    padding: 0;
    border-radius: 10px;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-center.nav-desktop .nav-item,
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-theme,
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-logout,
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .user-badge,
  html.sidebar-collapsed .app-nosidebar .sidebar-collapse-btn {
    margin-inline: auto;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-theme::before,
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-logout::before,
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .user-badge::before {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .25px;
  }

  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-theme::before { content: 'TM'; }
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .btn-logout::before { content: 'OUT'; }
  html.sidebar-collapsed .app-nosidebar .topbar-right.nav-desktop .user-badge::before { content: 'USR'; }

  html.sidebar-collapsed .app-nosidebar .sidebar-collapse-btn {
    min-width: 34px;
    width: 34px;
    height: 32px;
    font-size: 0;
    border-radius: 9px;
  }

  html.sidebar-collapsed .app-nosidebar .sidebar-collapse-btn::before {
    content: 'EXP';
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .2px;
  }

  html[data-theme="light"].sidebar-collapsed .app-nosidebar .topbar-center.nav-desktop .nav-item.active {
    box-shadow: none;
    border-color: #111111;
  }
}

/* =========================
   CONFIGURACIÓN PAGE
   ========================= */
.config-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.config-tab {
  padding: 10px 20px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: var(--card);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s, color .2s;
}

.config-tab.active {
  background: var(--blue);
  color: #fff;
}

.config-tab:hover:not(.active) {
  background: var(--card2);
  color: var(--text);
}

.config-panel .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.config-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
}

.btn-order {
  background: none;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--muted);
  border-radius: 4px;
  width: 24px;
  height: 20px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  padding: 0;
}

.btn-order:hover:not(:disabled) {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.btn-order:disabled {
  opacity: .25;
  cursor: not-allowed;
}

.row-inactive {
  opacity: .45;
}

.config-flag {
  text-align: center;
  color: var(--blue);
  font-weight: 700;
}

/* Toggle switch */
.config-toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.config-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.config-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.12);
  border-radius: 11px;
  cursor: pointer;
  transition: background .2s;
}

.config-toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}

.config-toggle input:checked + .config-toggle-slider {
  background: var(--blue);
}

.config-toggle input:checked + .config-toggle-slider::before {
  transform: translateX(18px);
}

/* Checkbox labels en modal */
.config-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
}

.config-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.api-key-intro {
  margin: 0 0 14px;
  line-height: 1.45;
}

.api-key-example {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
}

.api-key-example-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 6px;
}

.api-key-example code,
.api-key-secret {
  display: block;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  color: var(--text);
}

.api-key-warning {
  margin: 0 0 12px;
  color: var(--danger);
  font-weight: 700;
  font-size: 13px;
}

.api-key-secret-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.api-key-secret-wrap .api-key-secret {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--card2);
  border: 1px solid var(--border);
}

.api-key-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.api-key-status-ok {
  background: rgba(46, 204, 113, .16);
  color: #7ee0a6;
}

.api-key-status-off {
  background: rgba(255, 90, 90, .14);
  color: #ffd2d2;
}

@media (max-width: 720px) {
  .api-key-secret-wrap {
    flex-direction: column;
  }
}
