/* ==========================================================================
   KIPU CONTABLE — SISTEMA VISUAL INSTITUCIONAL Y RESPONSIVO
   ========================================================================== */

:root {
  --bg-canvas: #F3F6FA;
  --bg-surface: #FFFFFF;
  --bg-surface-ivory: #FCFCFD;
  --bg-surface-alt: #F8FAFC;
  --bg-header: rgba(255, 255, 255, 0.94);
  --bg-panel-accent: linear-gradient(180deg, rgba(240, 249, 255, 0.82) 0%, rgba(238, 242, 255, 0.62) 100%);
  --border-panel-accent: rgba(186, 230, 253, 0.72);

  --bg-sidebar: #F4F7FB;
  --bg-sidebar-header: #FFFFFF;
  --bg-sidebar-active: #E0F2FE;
  --bg-sidebar-hover: #E7EFF8;
  --bg-sidebar-sub-active: rgba(2, 132, 199, 0.12);
  --border-sidebar: #DCE4EE;
  --sidebar-sublist-border: #CBD5E1;
  --sidebar-active-shadow: 0 2px 8px rgba(2, 132, 199, 0.1);
  --sidebar-btn-bg: #FFFFFF;
  --sidebar-btn-border: #CBD5E1;
  --sidebar-btn-hover-bg: #EAF1F8;
  --sidebar-btn-text: #1E293B;

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-sidebar: #334155;
  --text-sidebar-strong: #0F172A;
  --text-sidebar-muted: #64748B;
  --text-sidebar-active: #0369A1;

  --border-subtle: rgba(226, 232, 240, 0.9);
  --border-row: rgba(226, 232, 240, 0.7);
  --border-col-num: rgba(226, 232, 240, 0.6);
  --border-strong: #CBD5E1;
  --border-ledger-rule: #CBD5E1;

  --brand-primary: #0284C7;
  --brand-primary-hover: #0369A1;
  --brand-indigo: #4F46E5;
  --brand-accent: #0EA5E9;
  --brand-accent-soft: rgba(240, 249, 255, 0.75);
  --brand-accent-pill: #E0F2FE;
  --brand-accent-border: rgba(186, 230, 253, 0.75);
  --brand-accent-text: #075985;
  --brand-accent-deep: #082F49;

  --amber-solid: #D97706;
  --amber-bright: #38BDF8;
  --amber-soft: rgba(255, 251, 235, 0.8);
  --amber-pill: #FEF3C7;
  --amber-border: rgba(253, 230, 138, 0.75);
  --amber-text: #92400E;
  --amber-deep: #451A03;

  --emerald-solid: #059669;
  --emerald-soft: rgba(236, 253, 245, 0.8);
  --emerald-pill: #D1FAE5;
  --emerald-border: rgba(167, 243, 208, 0.72);
  --emerald-text: #065F46;
  --emerald-deep: #022C22;

  --rose-solid: #BE123C;
  --rose-soft: rgba(255, 241, 242, 0.8);
  --rose-pill: #FFE4E6;
  --rose-border: rgba(254, 205, 211, 0.75);
  --rose-text: #9F1239;

  --row-hover: rgba(248, 250, 252, 0.88);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 4px 12px -4px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 18px 40px -14px rgba(15, 23, 42, 0.22);
}

html.dark {
  --bg-canvas: #0B1120;
  --bg-surface: #111827;
  --bg-surface-ivory: #131C2E;
  --bg-surface-alt: #0F172A;
  --bg-header: rgba(15, 23, 42, 0.94);
  --bg-panel-accent: linear-gradient(180deg, rgba(14, 116, 144, 0.16) 0%, rgba(49, 46, 129, 0.16) 100%);
  --border-panel-accent: rgba(56, 189, 248, 0.28);

  --bg-sidebar: #162033;
  --bg-sidebar-header: #1B273D;
  --bg-sidebar-active: rgba(56, 189, 248, 0.18);
  --bg-sidebar-hover: rgba(148, 163, 184, 0.12);
  --bg-sidebar-sub-active: rgba(56, 189, 248, 0.14);
  --border-sidebar: #26354D;
  --sidebar-sublist-border: rgba(148, 163, 184, 0.25);
  --sidebar-active-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  --sidebar-btn-bg: rgba(255, 255, 255, 0.08);
  --sidebar-btn-border: rgba(148, 163, 184, 0.24);
  --sidebar-btn-hover-bg: rgba(255, 255, 255, 0.14);
  --sidebar-btn-text: #F1F5F9;

  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-sidebar: #CBD5E1;
  --text-sidebar-strong: #F8FAFC;
  --text-sidebar-muted: #94A3B8;
  --text-sidebar-active: #7DD3FC;

  --border-subtle: rgba(51, 65, 85, 0.78);
  --border-row: rgba(51, 65, 85, 0.55);
  --border-col-num: rgba(51, 65, 85, 0.5);
  --border-strong: #475569;
  --border-ledger-rule: #475569;

  --brand-primary: #0284C7;
  --brand-primary-hover: #0EA5E9;
  --brand-indigo: #6366F1;
  --brand-accent: #38BDF8;
  --brand-accent-soft: rgba(14, 165, 233, 0.14);
  --brand-accent-pill: rgba(14, 165, 233, 0.2);
  --brand-accent-border: rgba(56, 189, 248, 0.3);
  --brand-accent-text: #7DD3FC;
  --brand-accent-deep: #E0F2FE;

  --amber-solid: #D97706;
  --amber-bright: #38BDF8;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --amber-pill: rgba(245, 158, 11, 0.2);
  --amber-border: rgba(251, 191, 36, 0.3);
  --amber-text: #FCD34D;
  --amber-deep: #FEF3C7;

  --emerald-solid: #10B981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --emerald-pill: rgba(16, 185, 129, 0.2);
  --emerald-border: rgba(52, 211, 153, 0.3);
  --emerald-text: #6EE7B7;
  --emerald-deep: #D1FAE5;

  --rose-solid: #E11D48;
  --rose-soft: rgba(244, 63, 94, 0.14);
  --rose-pill: rgba(244, 63, 94, 0.2);
  --rose-border: rgba(251, 113, 133, 0.3);
  --rose-text: #FDA4AF;

  --row-hover: rgba(30, 41, 59, 0.68);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.22);
  --shadow-hover: 0 6px 18px -6px rgba(0, 0, 0, 0.38);
  --shadow-modal: 0 22px 44px -14px rgba(0, 0, 0, 0.6);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: clip;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fadeIn { animation: fadeIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-scaleUp { animation: scaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.animate-slideDown { animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.35); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.55); }

/* ==================== PANTALLA DE ACCESO (LOGIN / REGISTRO) ==================== */
html:not(.dark) .logo-for-dark {
  display: none !important;
}

html.dark .logo-for-light {
  display: none !important;
}

.auth-boot-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 12% 16%, rgba(2, 132, 199, 0.14), transparent 44%),
    radial-gradient(circle at 88% 84%, rgba(79, 70, 229, 0.11), transparent 46%),
    var(--bg-canvas);
}

.auth-boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.auth-boot-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.auth-boot-spinner-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 12% 16%, rgba(2, 132, 199, 0.14), transparent 44%),
    radial-gradient(circle at 88% 84%, rgba(79, 70, 229, 0.11), transparent 46%),
    var(--bg-canvas);
}

.auth-card {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}

.auth-hero {
  background:
    radial-gradient(circle at 88% 12%, rgba(14, 165, 233, 0.16), transparent 44%),
    radial-gradient(circle at 10% 92%, rgba(79, 70, 229, 0.12), transparent 48%),
    linear-gradient(160deg, #EFF6FF 0%, #F4F7FB 56%, #EEF2FF 100%);
  color: var(--text-primary);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  border-right: 1px solid var(--border-subtle);
}

html.dark .auth-hero {
  background:
    radial-gradient(circle at 88% 12%, rgba(56, 189, 248, 0.2), transparent 42%),
    radial-gradient(circle at 10% 92%, rgba(79, 70, 229, 0.22), transparent 48%),
    linear-gradient(160deg, #0F172A 0%, #111C33 58%, #0B1120 100%);
  color: #F8FAFC;
  border-right-color: rgba(226, 232, 240, 0.1);
}

.auth-hero-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-hero-logo {
  height: 42px;
  width: auto;
  display: block;
}

.auth-hero-chip {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--brand-accent-text);
  background: var(--brand-accent-pill);
  border: 1px solid var(--brand-accent-border);
  padding: 4px 10px;
  border-radius: 9999px;
}

html.dark .auth-hero-chip {
  color: #7DD3FC;
  background: rgba(14, 165, 233, 0.16);
  border-color: rgba(56, 189, 248, 0.34);
}

.auth-hero h1 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.24;
  color: var(--text-primary);
}

html.dark .auth-hero h1 {
  color: #FFFFFF;
}

.auth-hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.89rem;
  line-height: 1.58;
}

html.dark .auth-hero p {
  color: #CBD5E1;
}

.auth-features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 0.87rem;
  color: var(--text-secondary);
}

html.dark .auth-features li {
  color: #E2E8F0;
}

.auth-feature-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

html.dark .auth-feature-icon {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: none;
}

.auth-demo-box {
  background: var(--bg-surface);
  border: 1px solid var(--brand-accent-border);
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-card);
}

html.dark .auth-demo-box {
  background: rgba(15, 23, 42, 0.62);
  border-color: rgba(56, 189, 248, 0.28);
  backdrop-filter: blur(8px);
  box-shadow: none;
}

.auth-demo-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.auth-demo-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--brand-accent-text);
}

html.dark .auth-demo-title {
  color: #7DD3FC;
}

.auth-demo-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-demo-row {
  color: var(--text-secondary);
  font-size: 12.5px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.auth-demo-row span {
  color: var(--text-muted);
  font-weight: 500;
}

.auth-demo-row strong {
  color: var(--text-primary);
  font-weight: 600;
  overflow-wrap: anywhere;
}

html.dark .auth-demo-row {
  color: #E2E8F0;
}

html.dark .auth-demo-row span {
  color: #94A3B8;
}

html.dark .auth-demo-row strong {
  color: #FFFFFF;
}

.auth-demo-fill-btn {
  margin-top: 12px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--brand-accent-border);
  background: var(--brand-accent-soft);
  color: var(--brand-accent-text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.auth-demo-fill-btn:hover {
  background: var(--brand-accent-pill);
  border-color: var(--brand-primary);
}

html.dark .auth-demo-fill-btn {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(2, 132, 199, 0.24);
  color: #E0F2FE;
}

html.dark .auth-demo-fill-btn:hover {
  background: rgba(2, 132, 199, 0.38);
  border-color: rgba(125, 211, 252, 0.78);
}

.auth-form-panel {
  padding: 36px 32px;
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.auth-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-bottom: 22px;
}

.auth-mobile-logo {
  display: none;
  align-items: center;
}

.auth-mobile-logo-img {
  height: 34px;
  width: auto;
  display: block;
}

.auth-mobile-demo {
  display: none;
  margin-top: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-surface-alt);
  overflow: hidden;
}

.auth-mobile-demo-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.auth-mobile-demo-summary::-webkit-details-marker {
  display: none;
}

.auth-mobile-demo-summary:hover {
  background: var(--row-hover);
  color: var(--text-primary);
}

.auth-mobile-demo-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.auth-login-header {
  margin-bottom: 18px;
}

.auth-login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--brand-accent-soft);
  border: 1px solid var(--brand-accent-border);
  color: var(--brand-accent-text);
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 10px;
}

.auth-login-header h2 {
  margin: 0;
  font-size: 1.38rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.auth-login-header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-remember-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.auth-remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.auth-submit-btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 13.5px;
  margin-top: 4px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-error {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--rose-soft);
  color: var(--rose-text);
  border: 1px solid var(--rose-border);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* ==================== ESTRUCTURA PRINCIPAL ==================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar-strong);
  border-right: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.2s ease, transform 0.22s ease;
}

.sidebar.collapsed {
  width: 74px;
}

.sidebar-brand {
  height: 64px;
  padding: 0 14px;
  background-color: var(--bg-sidebar-header);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-brand-logo {
  height: 40px;
  width: auto;
  max-width: 192px;
  display: block;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 0 8px;
}

.sidebar.collapsed .sidebar-brand-logo-full {
  display: none !important;
}

.desktop-collapse-btn {
  flex-shrink: 0;
  border-color: transparent;
  color: var(--text-secondary);
}

.desktop-collapse-btn .collapse-chevron-icon {
  transition: transform 0.2s ease;
}

.sidebar.collapsed .desktop-collapse-btn .collapse-chevron-icon {
  transform: rotate(180deg);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sidebar-muted);
  padding: 10px 12px 4px;
}

.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge {
  display: none;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: none;
  border-left: 4px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-sidebar);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--text-sidebar-strong);
}

.nav-item.active {
  background-color: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 600;
  border-left-color: var(--brand-primary);
  box-shadow: var(--sidebar-active-shadow);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.96;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

iconify-icon.flat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
}

.nav-badge {
  margin-left: auto;
  background-color: var(--amber-solid);
  color: #020617;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 9999px;
}

.sidebar-footer {
  position: relative;
  z-index: 45;
  padding: 12px;
  border-top: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}

.sidebar.collapsed .sidebar-footer {
  align-items: center;
  padding: 12px 8px;
  gap: 8px;
}

.sidebar-credit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-sidebar);
  text-align: center;
  user-select: none;
}

.sidebar-credit-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sidebar-credit-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.sidebar-credit-name {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-sidebar-strong);
}

.sidebar-credit-copy {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-sidebar-muted);
  line-height: 1.3;
}

.sidebar.collapsed .sidebar-credit {
  padding-top: 6px;
}

.sidebar.collapsed .sidebar-credit-name,
.sidebar.collapsed .sidebar-credit-copy {
  display: none;
}

.sidebar-theme-wrapper {
  position: relative;
  width: 100%;
}

.sidebar.collapsed .sidebar-theme-wrapper {
  width: auto;
}

.sidebar-theme-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--sidebar-btn-border);
  background: var(--sidebar-btn-bg);
  color: var(--sidebar-btn-text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.sidebar-theme-btn:hover,
.sidebar-theme-btn[aria-expanded="true"] {
  background: var(--sidebar-btn-hover-bg);
  border-color: var(--brand-primary);
}

.sidebar-theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-theme-chevron {
  margin-left: auto;
  opacity: 0.8;
  transition: transform 0.16s ease;
}

.sidebar-theme-btn[aria-expanded="true"] .sidebar-theme-chevron {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-theme-label,
.sidebar.collapsed .sidebar-theme-chevron {
  display: none;
}

.sidebar.collapsed .sidebar-theme-btn {
  width: 38px;
  height: 36px;
  padding: 0;
  justify-content: center;
}

.sidebar-theme-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  right: 0;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 13px;
  padding: 6px;
  box-shadow: var(--shadow-modal);
  z-index: 60;
  animation: fadeIn 0.15s ease;
}

.sidebar-theme-dropdown.open {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar.collapsed .sidebar-theme-dropdown {
  left: calc(100% + 10px);
  right: auto;
  bottom: 0;
  width: 192px;
}

.sidebar-theme-dropdown-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 5px 8px 4px;
}

.theme-option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.theme-option-btn:hover {
  background: var(--bg-surface-alt);
  color: var(--text-primary);
}

.theme-option-btn.active {
  background: var(--brand-accent-soft);
  color: var(--brand-accent-text);
}

.theme-option-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-option-check {
  opacity: 0;
  font-weight: 800;
  font-size: 12px;
}

.theme-option-btn.active .theme-option-check {
  opacity: 1;
}

.main-wrapper {
  flex: 1;
  margin-left: 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

body.sidebar-collapsed .main-wrapper {
  margin-left: 74px;
}

.glass-header {
  position: sticky;
  top: 0;
  z-index: 35;
  min-height: 64px;
  background-color: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 24px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px 16px;
  transition: box-shadow 0.18s ease, background-color 0.18s ease;
}

.glass-header.is-scrolled {
  box-shadow: 0 6px 20px -6px rgba(15, 23, 42, 0.14);
}

html.dark .glass-header.is-scrolled {
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.45);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-title-group {
  min-width: 0;
  flex: 1;
}

.topbar-module-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-company-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.header-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-actions-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.header-actions-group > .btn,
.quick-create-trigger {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.quick-create-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.quick-create-chevron {
  opacity: 0.9;
  transition: transform 0.16s ease;
}

.quick-create-trigger[aria-expanded="true"] .quick-create-chevron {
  transform: rotate(180deg);
}

.quick-create-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(300px, calc(100vw - 24px));
  max-height: min(76vh, 480px);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  padding: 6px;
  z-index: 70;
  animation: slideDown 0.15s ease;
}

.quick-create-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-create-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 10px 3px;
}

.quick-create-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 8px;
}

.quick-create-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.quick-create-item:hover,
.quick-create-item:focus-visible {
  background: var(--bg-surface-alt);
  outline: none;
}

.quick-create-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}

.quick-create-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.quick-create-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.quick-create-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.25;
}

.company-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  padding: 0 10px;
  border-radius: 10px;
  flex: 0 1 240px;
  min-width: 165px;
  max-width: 100%;
}

.company-switcher svg,
.company-switcher iconify-icon {
  flex-shrink: 0;
}

.company-switcher select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 600;
  font-size: 12.5px;
  outline: none;
  cursor: pointer;
  padding: 2px 2px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
}

.user-menu-wrap {
  position: relative;
  min-width: 0;
  max-width: 100%;
  flex-shrink: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 6px 0 10px;
  border-radius: 10px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  min-width: 0;
  max-width: 100%;
}

.floating-confirm-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(296px, calc(100vw - 24px));
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-modal);
  z-index: 60;
  animation: slideDown 0.16s ease;
}

.floating-confirm-menu.open {
  display: block;
}

.floating-confirm-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.floating-confirm-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--rose-soft);
  color: var(--rose-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.floating-confirm-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.floating-confirm-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.floating-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.user-pill-info {
  font-size: 12px;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
}

.user-pill-name {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.user-pill-role {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.theme-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.theme-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.theme-btn:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-sidebar-hover);
}

.theme-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.main-content {
  flex: 1;
  padding: 24px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

.app-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* Encabezados de Módulos */
.module-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.module-header > div:first-child,
.module-header-info {
  min-width: 0;
  flex: 1 1 260px;
}

.module-header-title {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.52rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: break-word;
}

.module-header-subtitle {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.module-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  max-width: 100%;
}

/* Tarjetas y Grillas — Estilo Papel Contable */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  min-width: 0;
}

.card-ivory {
  background-color: var(--bg-surface-ivory);
}

.card-accent,
.panel-accent {
  background: var(--bg-panel-accent);
  border: 1px solid var(--border-panel-accent);
}

.card-selected,
.is-selected {
  border: 2px solid var(--brand-accent) !important;
  background-color: rgba(240, 249, 255, 0.35);
}

html.dark .card-selected,
html.dark .is-selected {
  background-color: rgba(14, 165, 233, 0.14);
}

.draft-box {
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background-color: var(--bg-surface-ivory);
}

.card-interactive {
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.16s ease, border-color 0.16s ease;
}

.card-interactive:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
  border-color: var(--brand-accent-border);
}

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

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

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

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

.kpi-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
  position: relative;
}

.kpi-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.kpi-body,
.kpi-card-top > div:first-child {
  min-width: 0;
  flex: 1;
}

.kpi-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 0;
  overflow-wrap: break-word;
}

.kpi-mini-badge {
  font-size: 10px;
  padding: 1px 7px;
}

.kpi-value {
  margin-top: 6px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(1.05rem, 1.5vw, 1.38rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.24;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.kpi-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
  overflow-wrap: break-word;
}

.kpi-icon-pill {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--brand-accent-text);
  flex-shrink: 0;
}

.kpi-icon-pill iconify-icon {
  font-size: 22px;
  width: 22px;
  height: 22px;
}

.kpi-clickable {
  cursor: pointer;
}

.kpi-clickable:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

.kpi-tone-amber {
  background-color: var(--amber-soft);
  border-color: var(--amber-border);
}
.kpi-tone-amber .kpi-label { color: var(--amber-text); }
.kpi-tone-amber .kpi-value { color: var(--amber-deep); }
.kpi-tone-amber .kpi-icon-pill {
  background-color: var(--amber-pill);
  border-color: var(--amber-border);
  color: var(--amber-text);
}

.kpi-tone-rose {
  background-color: var(--rose-soft);
  border-color: var(--rose-border);
}
.kpi-tone-rose .kpi-label { color: var(--rose-text); }
.kpi-tone-rose .kpi-value { color: var(--rose-text); }
.kpi-tone-rose .kpi-icon-pill {
  background-color: var(--rose-pill);
  border-color: var(--rose-border);
  color: var(--rose-text);
}

.kpi-tone-emerald {
  background-color: var(--emerald-soft);
  border-color: var(--emerald-border);
}
.kpi-tone-emerald .kpi-label { color: var(--emerald-text); }
.kpi-tone-emerald .kpi-value { color: var(--emerald-deep); }
.kpi-tone-emerald .kpi-icon-pill {
  background-color: var(--emerald-pill);
  border-color: var(--emerald-border);
  color: var(--emerald-text);
}

.kpi-tone-blue {
  background-color: var(--brand-accent-soft);
  border-color: var(--brand-accent-border);
}
.kpi-tone-blue .kpi-label { color: var(--brand-accent-text); }
.kpi-tone-blue .kpi-value { color: var(--brand-accent-deep); }
.kpi-tone-blue .kpi-icon-pill {
  background-color: var(--brand-accent-pill);
  border-color: var(--brand-accent-border);
  color: var(--brand-accent-text);
}

/* Barra de Widgets en Tiempo Real */
.widget-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-panel-accent);
  border: 1px solid var(--border-panel-accent);
}

.widget-live-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  min-width: 0;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 9999px;
  background: var(--emerald-soft);
  color: var(--emerald-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--emerald-solid);
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.82); }
}

.widget-live-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.widget-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

@keyframes spinIcon {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.is-spinning .refresh-icon {
  animation: spinIcon 0.7s linear infinite;
}

.widget-config-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.widget-config-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-surface-alt);
  cursor: pointer;
}

.widget-config-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--brand-primary);
}

.widget-config-info {
  min-width: 0;
  flex: 1;
}

.widget-config-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.widget-config-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Utilidades responsivas para tarjetas y listas */
.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.card-head-row > strong {
  min-width: 0;
  overflow-wrap: break-word;
}

.list-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-row);
  transition: background-color 0.14s ease;
}

.list-row-card:last-child {
  border-bottom: none;
}

.list-row-card:hover {
  background-color: var(--row-hover);
}

.list-row-main {
  min-width: 0;
  flex: 1 1 160px;
}

.list-row-title {
  font-weight: 600;
  color: var(--text-primary);
  overflow-wrap: break-word;
}

.list-row-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  overflow-wrap: break-word;
}

.list-row-amount {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.mini-stat-box {
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--bg-panel-accent);
  border: 1px solid var(--border-panel-accent);
  min-width: 0;
}

.mini-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.mini-stat-val {
  margin-top: 3px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.obligation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.obligation-row:last-child {
  border-bottom: none;
}

.obligation-row-text {
  min-width: 0;
  flex: 1 1 180px;
  overflow-wrap: break-word;
}

.filter-bar-grid {
  grid-template-columns: 2fr 1fr 1fr auto;
  align-items: end;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 100%;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.is-busy {
  pointer-events: none;
  cursor: wait;
  opacity: 0.8;
}

.btn.is-busy::before {
  content: '';
  width: 13px;
  height: 13px;
  border-radius: 9999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  display: inline-block;
  flex-shrink: 0;
  animation: kipuBtnSpin 0.65s linear infinite;
}

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(2, 132, 199, 0.22);
}

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

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline {
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn-outline:hover {
  background-color: var(--bg-surface-alt);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-amber {
  background-color: var(--amber-solid);
  color: #020617;
  font-weight: 700;
}

.btn-danger {
  background-color: var(--rose-solid);
  color: #ffffff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-icon {
  padding: 6px;
  width: 34px;
  height: 34px;
}

/* Pestañas */
.tabs-bar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
  margin-bottom: 18px;
}

.tabs-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-alt);
}

.tab-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
}

/* Etiquetas de Estado (Semántica Pastel) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-blue { background: var(--brand-accent-pill); color: var(--brand-accent-text); border-color: var(--brand-accent-border); }
.badge-emerald { background: var(--emerald-pill); color: var(--emerald-text); border-color: var(--emerald-border); }
.badge-amber { background: var(--amber-pill); color: var(--amber-text); border-color: var(--amber-border); }
.badge-rose { background: var(--rose-pill); color: var(--rose-text); border-color: var(--rose-border); }
.badge-neutral { background: var(--bg-surface-alt); color: var(--text-secondary); border-color: var(--border-subtle); }

/* Tablas — Papel Contable con Filetes Sutiles */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-ivory);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background-color: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-row);
  color: var(--text-primary);
  vertical-align: middle;
}

thead th.text-right,
tbody td.text-right,
tbody td.num,
tfoot td.text-right {
  border-left: 1px solid var(--border-col-num);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Subtotales (filete simple superior) y Totales Contables (doble filete inferior) */
tfoot tr td,
.ledger-total td,
.ledger-total {
  border-top: 1px solid var(--border-ledger-rule);
  border-bottom: 4px double var(--border-ledger-rule);
  font-weight: 700;
  background-color: var(--bg-surface-alt);
}

.ledger-subtotal td,
.ledger-subtotal {
  border-top: 1px solid var(--border-ledger-rule);
  font-weight: 600;
}

.table-row-interactive {
  transition: background-color 0.12s ease;
}

.table-row-interactive:hover {
  background-color: var(--row-hover);
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.font-mono,
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.num { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Formularios */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 780px;
  max-height: 92dvh;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 0;
  flex: 1;
  overflow-wrap: break-word;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--bg-surface-alt);
}

/* Notificaciones */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  left: auto;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--border-subtle);
  animation: slideDown 0.2s ease;
  max-width: min(380px, calc(100vw - 32px));
}

.toast-success { background: var(--emerald-soft); color: var(--emerald-text); border-color: var(--emerald-solid); }
.toast-error { background: var(--rose-soft); color: var(--rose-text); border-color: var(--rose-solid); }
.toast-warning { background: var(--amber-soft); color: var(--amber-text); border-color: var(--amber-solid); }
.toast-info { background: var(--brand-accent-soft); color: var(--brand-accent-text); border-color: var(--brand-accent); }

.toast-rich {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  font-weight: 500;
}

.toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.toast-body {
  font-size: 12.5px;
  line-height: 1.4;
  opacity: 0.95;
}

.toast-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.toast-action-btn {
  appearance: none;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.toast-action-btn:hover {
  opacity: 0.8;
}

.toast-close {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.72;
}

.toast-close:hover {
  opacity: 1;
}

/* Móvil Overlay */
.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  z-index: 35;
}

.mobile-menu-btn {
  display: none;
}

/* ==================== BREAKPOINTS RESPONSIVOS ==================== */
@media (max-width: 1340px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1140px) and (max-width: 1340px) {
  body.sidebar-collapsed .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  .glass-header {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px 20px;
    row-gap: 8px;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
  .header-controls-group {
    flex: 1 1 auto;
  }
  .company-switcher {
    flex: 1 1 210px;
    max-width: 300px;
  }
}

@media (max-width: 1180px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .glass-header { padding: 10px 18px; }
}

@media (max-width: 960px) {
  .auth-screen { padding: 18px 14px; }
  .auth-card { grid-template-columns: 1fr; max-width: 460px; }
  .auth-hero { display: none; }
  .auth-mobile-logo { display: flex; }
  .auth-mobile-demo { display: block; }
  .auth-form-panel { padding: 26px 22px; }
  .filter-bar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .sidebar {
    width: 270px;
    max-width: 86vw;
    transform: translateX(-100%);
  }
  .sidebar.collapsed { width: 270px; }
  .sidebar.mobile-open { transform: translateX(0); }
  .mobile-backdrop.open { display: block; }
  .mobile-menu-btn { display: inline-flex; }
  .main-wrapper, body.sidebar-collapsed .main-wrapper { margin-left: 0; }

  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .main-content { padding: 14px; }
  .glass-header {
    position: static;
    padding: 8px 12px;
    min-height: 52px;
    row-gap: 6px;
  }
  .header-right {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }
  .header-controls-group {
    display: flex;
    width: 100%;
  }
  .company-switcher {
    padding: 3px 8px;
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
  }
  .global-search-kbd { display: none; }
  .global-search-dropdown { left: 0; right: 0; width: 100%; }
  .quick-create-menu { left: 0; right: auto; }
  .header-actions-group {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .module-header { flex-direction: column; align-items: stretch; }
  .module-actions { width: 100%; }
  .module-actions .btn { flex: 1 1 auto; }
  .voucher-meta-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .auth-screen { padding: 14px 12px; }
  .auth-card { border-radius: 16px; }
  .auth-form-panel { padding: 22px 18px; }
  .auth-panel-top { margin-bottom: 16px; }
  .grid-4, .grid-3, .grid-2, .form-grid, .filter-bar-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px 15px; border-radius: 14px; }
  thead th, tbody td { padding: 9px 10px; font-size: 12px; }
  .topbar-company-meta { display: none; }
  .header-controls-group {
    grid-template-columns: minmax(0, 1fr);
  }
  .header-actions-group {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .user-menu-wrap { flex: 1 1 auto; min-width: 0; }
  .user-pill { width: 100%; justify-content: space-between; padding: 3px 5px 3px 8px; }
  .user-pill-role { display: none; }
  .floating-confirm-menu { width: 100%; }
  .modal-backdrop { padding: 10px; }
  .modal-header, .modal-body, .modal-footer { padding: 14px 16px; }
  .modal-footer .btn { flex: 1 1 120px; }
  .toast-stack { left: 16px; right: 16px; bottom: 14px; }
  .toast { max-width: 100%; }
  .widget-toolbar-actions { width: 100%; }
  .widget-toolbar-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  .line-row-grid,
  .line-row-grid-bill {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px;
  }
}

@media (max-width: 440px) {
  .auth-form-panel { padding: 18px 14px; }
  .auth-login-header h2 { font-size: 1.24rem; }
  .auth-mobile-logo-img { height: 30px; }
  .theme-btn { padding: 4px 7px; font-size: 11.5px; }
  .btn { white-space: normal; text-align: center; }
  .header-right .btn { white-space: nowrap; }
}

/* Reglas de Impresión */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .auth-screen, .sidebar, .glass-header, .app-footer, .no-print, .toast-stack, .modal-backdrop { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .main-content { padding: 0 !important; max-width: 100% !important; }
  body { background: #ffffff !important; color: #000000 !important; }
  .card { box-shadow: none !important; border: 1px solid #d1d5db !important; page-break-inside: avoid; }
  body.printing-voucher .app-shell { display: none !important; }
  body.printing-voucher .print-voucher-root { display: block !important; padding: 0; margin: 0; }
}

/* Modo solo vista y estados vacíos */
body.read-only-mode .write-action,
body.read-only-mode #main-content button:not(.global-search-item):not(.global-search-clear),
body.read-only-mode #btn-quick-create {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(0.35);
  box-shadow: none !important;
}

.readonly-badge {
  white-space: nowrap;
}

.empty-state-card {
  text-align: center;
  padding: 40px 24px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 16px;
}

/* ==================== SUBMÓDULOS EXPANDIBLES EN SIDEBAR ==================== */
.nav-group-wrap {
  display: flex;
  flex-direction: column;
}

.nav-item-chevron {
  margin-left: auto;
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.nav-badge + .nav-item-chevron {
  margin-left: 6px;
}

.nav-item.expanded .nav-item-chevron {
  transform: rotate(90deg);
}

.nav-sublist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 6px 18px;
  padding-left: 10px;
  border-left: 1.5px solid var(--sidebar-sublist-border);
}

.nav-subitem {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-sidebar);
  font-size: 12.2px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-subitem:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-strong);
}

.nav-subitem.active {
  background: var(--bg-sidebar-sub-active);
  color: var(--text-sidebar-active);
  font-weight: 700;
}

.nav-subitem-dot {
  width: 5px;
  height: 5px;
  border-radius: 9999px;
  background: currentColor;
  opacity: 0.55;
  flex-shrink: 0;
}

.nav-subitem.active .nav-subitem-dot {
  background: var(--brand-primary);
  opacity: 1;
}

.sidebar.collapsed .nav-sublist,
.sidebar.collapsed .nav-item-chevron {
  display: none !important;
}

/* ==================== FORMULARIOS MULTILÍNEA Y TOTALES ==================== */
.modal-card.modal-lg {
  max-width: 920px;
}

.line-items-box {
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg-surface-ivory);
}

.line-items-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.line-row-grid {
  display: grid;
  grid-template-columns: 1.5fr 1.8fr 0.65fr 1fr 0.65fr 1.1fr auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.line-row-grid-bill {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1.6fr 0.65fr 1fr 1.1fr auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.line-row-grid input,
.line-row-grid select,
.line-row-grid-bill input,
.line-row-grid-bill select {
  padding: 6px 8px;
  font-size: 12.5px;
}

.line-items-totals {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 10px 4px 8px;
  border-top: 1px solid var(--border-ledger-rule);
  border-bottom: 4px double var(--border-ledger-rule);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

@media (max-width: 768px) {
  .line-row-grid,
  .line-row-grid-bill {
    grid-template-columns: 1fr 1fr;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-strong);
  }
}

/* ==================== ALERTAS NCF Y COMPROBANTES IMPRIMIBLES ==================== */
.alert-banner {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.alert-banner-warning {
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid var(--amber-solid);
}

.alert-banner-error {
  background: var(--rose-soft);
  color: var(--rose-text);
  border: 1px solid var(--rose-solid);
}

.alert-banner-success {
  background: var(--emerald-soft);
  color: var(--emerald-text);
  border: 1px solid var(--emerald-solid);
}

.dgii-compliance-strip {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dgii-compliance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.dgii-compliance-list {
  margin: 2px 0 0;
  padding-left: 18px;
}

.input-dgii-invalid {
  border-color: var(--rose-solid) !important;
  box-shadow: 0 0 0 2px var(--rose-soft);
}

.print-voucher-root {
  display: none;
}

.voucher-sheet {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px 28px;
  font-size: 13px;
  line-height: 1.5;
}

.voucher-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 18px;
  border-bottom: 2px solid #1e3a8a;
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.voucher-company-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1e3a8a;
}

.voucher-doc-box {
  text-align: right;
  background: linear-gradient(180deg, rgba(240, 249, 255, 0.85), rgba(238, 242, 255, 0.65));
  border: 1px solid rgba(186, 230, 253, 0.8);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 220px;
}

.voucher-doc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #075985;
  letter-spacing: 0.05em;
}

.voucher-doc-num {
  font-size: 1.05rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  color: #0F172A;
}

.voucher-meta-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  margin-bottom: 16px;
}

.voucher-meta-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.voucher-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.voucher-table th {
  background: #1e3a8a;
  color: #ffffff;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  text-align: left;
}

.voucher-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  color: #111827;
}

.voucher-footer-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}

.voucher-totals-box {
  min-width: 240px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 14px;
  background: #f9fafb;
}

.voucher-total-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.voucher-total-row.grand {
  margin-top: 6px;
  padding: 6px 0;
  border-top: 1px solid #CBD5E1;
  border-bottom: 4px double #CBD5E1;
  font-size: 14.5px;
  font-weight: 700;
  color: #0F172A;
}

.voucher-qr-box {
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11px;
  color: #475569;
  max-width: 340px;
}

.clickable-account-row {
  cursor: pointer;
}

.clickable-account-row:hover td:first-child {
  color: var(--brand-accent);
  text-decoration: underline;
}

/* ==================== BÚSQUEDA GLOBAL EN RESUMEN GERENCIAL ==================== */
.dashboard-search-section {
  margin-bottom: 16px;
}

.global-search-wrap {
  position: relative;
  width: 100%;
  max-width: 680px;
}

.global-search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0 14px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.nav-item:focus-visible,
.nav-subitem:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
  background-color: var(--bg-sidebar-hover);
  color: var(--text-sidebar-strong);
}

.nav-item.active:focus-visible {
  background-color: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}

.nav-subitem.active:focus-visible {
  background-color: var(--bg-sidebar-sub-active);
  color: var(--text-sidebar-active);
}

.global-search-box:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
  background: var(--bg-surface);
}

.global-search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.global-search-input {
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  padding: 2px 0;
}

.global-search-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.global-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.global-search-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.global-search-clear:hover {
  background: var(--border-subtle);
  color: var(--text-primary);
}

.global-search-kbd {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 1px 5px;
  line-height: 1.4;
  flex-shrink: 0;
  user-select: none;
}

.global-search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  width: 100%;
  max-height: min(460px, 70vh);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  z-index: 65;
  padding: 6px;
  animation: slideDown 0.15s ease;
}

.global-search-dropdown.open {
  display: block;
}

.global-search-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.global-search-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.global-search-item:hover,
.global-search-item.is-selected {
  background: var(--bg-surface-alt);
}

.global-search-item-main {
  min-width: 0;
  flex: 1;
}

.global-search-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
}

.global-search-item-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.global-search-item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.global-search-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.global-search-item-amount {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.global-search-item-date {
  font-size: 10.5px;
  color: var(--text-muted);
}

.global-search-empty {
  padding: 18px 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

.global-search-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
}

@keyframes searchRowFlash {
  0% { background-color: rgba(37, 99, 235, 0.22); }
  70% { background-color: rgba(37, 99, 235, 0.12); }
  100% { background-color: transparent; }
}

tr.search-row-highlight {
  animation: searchRowFlash 2.2s ease-out;
}

/* ==================== FILTROS DE TABLA Y MENÚ DE ACCIONES ==================== */
.table-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.table-filter-input {
  flex: 1 1 220px;
  max-width: 360px;
}

.table-filter-select {
  flex: 0 1 200px;
  width: auto !important;
  min-width: 150px;
}

.row-actions-cell {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-action-menu {
  position: relative;
  display: inline-block;
}

.row-action-menu > summary {
  list-style: none;
  cursor: pointer;
}

.row-action-menu > summary::-webkit-details-marker {
  display: none;
}

.row-action-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 168px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: var(--shadow-modal);
  padding: 5px;
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-action-popover button {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
}

.row-action-popover button:hover {
  background: var(--bg-surface-alt);
}

.btn-link {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--brand-accent);
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.loading-state {
  text-align: center;
  padding: 28px 18px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ==================== BARRA DE PROGRESO SUPERIOR Y BLOQUEO ==================== */
@keyframes kipuBtnSpin {
  to { transform: rotate(360deg); }
}

@keyframes kipuTopProgress {
  0% { transform: translateX(-100%) scaleX(0.35); }
  50% { transform: translateX(25%) scaleX(0.6); }
  100% { transform: translateX(220%) scaleX(0.35); }
}

.app-top-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.18s ease;
  background: rgba(2, 132, 199, 0.14);
}

.app-top-progress.is-active {
  opacity: 1;
}

.app-top-progress::after {
  content: '';
  display: block;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--brand-primary), var(--brand-accent), transparent);
  animation: kipuTopProgress 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

body.is-global-loading {
  cursor: progress;
}

.global-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

html.dark .global-loading-overlay {
  background: rgba(2, 6, 23, 0.56);
}

.global-loading-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.global-loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-modal);
  transform: translateY(6px) scale(0.98);
  transition: transform 0.18s ease;
}

.global-loading-overlay.is-active .global-loading-card {
  transform: translateY(0) scale(1);
}

.global-loading-spinner {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 2.5px solid var(--border-subtle);
  border-top-color: var(--brand-primary);
  animation: kipuBtnSpin 0.75s linear infinite;
}

.global-loading-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.global-loading-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.global-loading-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

.auth-screen.is-authenticating button:disabled,
.auth-screen.is-authenticating input:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  pointer-events: none;
}

/* ==================== SPARKLINE D3 EN TARJETA DE INGRESOS ==================== */
.kpi-chart-slot {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
  width: 100%;
  min-width: 0;
}

.kpi-sparkline-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: default;
}

.kpi-sparkline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-sparkline-delta {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 9999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.kpi-sparkline-delta.is-up {
  color: var(--emerald-text);
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
}

.kpi-sparkline-delta.is-down {
  color: var(--rose-text);
  background: var(--rose-soft);
  border-color: var(--rose-border);
}

.kpi-sparkline {
  width: 100%;
  height: 66px;
  display: block;
}

.spark-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.spark-baseline {
  stroke: var(--border-subtle);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

.spark-area {
  transition: opacity 0.25s ease;
}

.spark-line {
  fill: none;
  stroke: var(--brand-primary);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark-dot {
  fill: var(--bg-surface);
  stroke: var(--brand-primary);
  stroke-width: 1.8;
  transition: r 0.16s ease, stroke-width 0.16s ease;
  cursor: pointer;
}

.spark-dot.is-last {
  fill: var(--brand-primary);
  stroke: #ffffff;
  stroke-width: 1.5;
}

.spark-dot:hover {
  r: 4.2;
  stroke-width: 2.2;
}

.spark-axis-label {
  font-family: 'Inter', sans-serif;
  font-size: 8.5px;
  font-weight: 600;
  fill: var(--text-muted);
}

/* ==================== SKELETON SCREENS & TRANSICIONES ==================== */
@keyframes kipuShimmer {
  0% { background-position: -220% 0; }
  100% { background-position: 220% 0; }
}

@keyframes kipuCardEnter {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.16) 25%,
    rgba(148, 163, 184, 0.30) 50%,
    rgba(148, 163, 184, 0.16) 75%
  );
  background-size: 220% 100%;
  animation: kipuShimmer 1.35s ease-in-out infinite;
}

html.dark .skeleton {
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.10) 25%,
    rgba(148, 163, 184, 0.22) 50%,
    rgba(148, 163, 184, 0.10) 75%
  );
  background-size: 220% 100%;
}

.skeleton-screen {
  animation: fadeIn 0.18s ease forwards;
}

.skeleton-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.skeleton-line {
  height: 12px;
}

.skeleton-line.skeleton-lg {
  height: 20px;
}

.skeleton-pill {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex-shrink: 0;
}

.skeleton-btn {
  width: 112px;
  height: 34px;
  border-radius: 10px;
}

.skeleton-chart {
  height: 58px;
  width: 100%;
  border-radius: 10px;
  margin-top: 4px;
}

.skeleton-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.skeleton-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.skeleton-table-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.file-loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
}

.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-35 { width: 35%; }
.w-45 { width: 45%; }
.w-55 { width: 55%; }
.w-65 { width: 65%; }
.w-75 { width: 75%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }

/* Transiciones escalonadas en tarjetas KPI y listas */
.grid-4 > .kpi-card {
  animation: kipuCardEnter 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.grid-4 > .kpi-card:nth-child(2) { animation-delay: 25ms; }
.grid-4 > .kpi-card:nth-child(3) { animation-delay: 50ms; }
.grid-4 > .kpi-card:nth-child(4) { animation-delay: 75ms; }
.grid-4 > .kpi-card:nth-child(5) { animation-delay: 100ms; }
.grid-4 > .kpi-card:nth-child(6) { animation-delay: 125ms; }
.grid-4 > .kpi-card:nth-child(7) { animation-delay: 150ms; }
.grid-4 > .kpi-card:nth-child(8) { animation-delay: 175ms; }

.modal-card,
.list-row-card {
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

/* ==================== PLANES DE SUSCRIPCIÓN Y CANDADOS ==================== */
.nav-lock-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 9999px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
  flex-shrink: 0;
}

.nav-item.is-locked,
.nav-subitem.is-locked {
  opacity: 0.85;
}

.upgrade-wall {
  text-align: center;
  padding: 28px 20px;
}

.upgrade-wall-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
  margin-bottom: 10px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  text-align: left;
  margin-top: 18px;
}

.pricing-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 18px;
  background: var(--bg-surface);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.pricing-card.is-featured {
  border-color: var(--brand-primary);
  box-shadow: 0 8px 24px -10px rgba(2, 132, 199, 0.25);
}

.pricing-card.is-current {
  border-color: var(--emerald-solid);
  background: var(--bg-surface-alt);
}

.pricing-price {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 4px 0;
}

.pricing-price span {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.pricing-features {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.quota-track {
  height: 8px;
  border-radius: 9999px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  margin-top: 6px;
}

.quota-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  border-radius: 9999px;
  transition: width 0.3s ease;
}

@media (max-width: 960px) {
  .pricing-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .animate-fadeIn,
  .animate-scaleUp,
  .animate-slideDown,
  .skeleton,
  .skeleton-screen,
  .grid-4 > .kpi-card,
  .btn.is-busy::before,
  .app-top-progress::after {
    animation: none !important;
  }
  .btn,
  .card,
  .list-row-card,
  .modal-card,
  .app-top-progress {
    transition: none !important;
  }
}


