:root {
  --primary: #0B3C5D;
  --secondary: #1CA3D9;
  --accent: #00BCD4;
  --cta: #F57C00;
  --success: #4CAF50;
  --bg-dark: #0F172A;
  --text-light: #F1F5F9;
  --gray: #94A3B8;
  --surface: #FFFFFF;
  --surface-soft: rgba(255, 255, 255, 0.74);
  --surface-muted: #EEF4F8;
  --border: rgba(11, 60, 93, 0.10);
  --border-strong: rgba(11, 60, 93, 0.18);
  --text-main: #102234;
  --text-muted: #5F7389;
  --danger: #EF4444;
  --danger-dark: #DC2626;
  --warning: #D97706;
  --info: #0284C7;
  --background: #EEF6FB;
  --card-border: #D2E0EC;

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --font-main: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-ui-micro: 11.5px;
  --font-ui-caption: 12px;
  --font-ui-small: 13px;
  
  --shadow-sm: 0 4px 10px rgba(11, 60, 93, 0.05);
  --shadow-md: 0 8px 24px rgba(11, 60, 93, 0.08);
  --shadow-lg: 0 16px 32px rgba(11, 60, 93, 0.12);
  --shadow-glow: 0 0 20px rgba(28, 163, 217, 0.3);
}

/* Identidad institucional compartida con el ecosistema ASOSERLITUCAN. */
body { background: var(--background); }
.glass-card { background: #fff; border-color: var(--card-border); border-radius: 14px; box-shadow: 0 14px 34px rgba(11,60,93,.08); backdrop-filter: none; }
.btn { min-height: 42px; border-radius: 9px; font-weight: 800; }
.btn-primary { background: var(--primary); box-shadow: 0 8px 18px rgba(11,60,93,.18); }
.btn-primary:hover { background: #0e4d76; box-shadow: 0 12px 22px rgba(11,60,93,.22); }
.btn-cta { background: var(--cta); box-shadow: 0 8px 18px rgba(245,124,0,.22); }
.form-control { min-height: 43px; border-color: #c9d8e5; border-radius: 9px; }
.form-control:focus { border-color: #1083e8; box-shadow: 0 0 0 3px rgba(16,131,232,.14); }
.institutional-kicker { display:block; margin-bottom:.35rem; color:var(--cta); font-size:.74rem; font-weight:900; letter-spacing:.15em; }
.w-100 { width:100%; }

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
[hidden] { display: none !important; }

body {
  font-family: var(--font-main);
  background-color: var(--surface-muted);
  color: var(--text-main);
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(28, 163, 217, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(11, 60, 93, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Entrada compartida de los módulos internos, basada en la transición breve de Facturación. */
.route-content-enter {
  animation: routeContentIn 0.22s ease both;
}

@keyframes routeContentIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .route-content-enter,
  .billing-workspace-view,
  .operational-view-panel {
    animation: none !important;
  }
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: var(--font-main);
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: var(--font-main);
}

/* Glassmorphism Classes */
.glass-card {
  background: var(--surface-soft);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Base Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Typography utilities */
.h1, .h2, .h3, .h4 { color: var(--primary); font-weight: 700; }
.h1 { font-size: 2.5rem; line-height: 1.2; }
.h2 { font-size: 2rem; line-height: 1.3; }
.h3 { font-size: 1.5rem; }
.h4 { font-size: 1.25rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
  color: #fff;
}

.btn-cta {
  background: var(--cta);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.btn-cta:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-dark); }

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}
.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--primary);
}

.label-required::after {
  content: ' *';
  color: var(--danger);
}

.label-optional {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.label-optional::after {
  content: 'Opcional';
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.55rem;
}
.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-main);
  transition: all 0.3s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(28, 163, 217, 0.2);
}

input[type="number"].input-cantidad-ticket {
  min-width: 88px;
  text-align: center;
  color: var(--text-main);
  font-weight: 600;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  opacity: 1;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Utility Layouts */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-4 { margin-top: 2rem; }
.p-block { padding: 2rem; }
.wrap-mobile { flex-wrap: wrap; gap: 1rem; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 30000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--surface);
  color: var(--text-main);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  animation: slideInRight 0.3s ease forwards;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Global UI feedback */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.global-loading {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20050;
  height: 4px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
  transition: opacity .16s ease, transform .16s ease;
}
.global-loading.is-visible { opacity: 1; transform: translateY(0); }
.global-loading-track { display: block; width: 100%; height: 100%; background: rgba(119, 190, 221, .22); }
.global-loading-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, #18b8ed, #0787c3, #6bdcff);
  box-shadow: 0 0 12px rgba(20, 172, 224, .65);
  transition: width .28s ease, background .18s ease;
}
.global-loading.is-loading .global-loading-track i {
  background-size: 220% 100%;
  animation: globalProgressGlow 1.2s linear infinite;
}
.global-loading.is-success .global-loading-track i { background: var(--success, #17924d); }
.global-loading.is-error .global-loading-track i { background: var(--danger, #ef4444); }
@keyframes globalProgressGlow { to { background-position: -220% 0; } }

button.is-loading,
.action-button.is-loading,
.btn.is-loading {
  cursor: wait;
  opacity: .82;
}
.button-spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -.12em;
  animation: uiSpin .7s linear infinite;
}
@keyframes uiSpin { to { transform: rotate(360deg); } }

.toast-container {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
}
.toast {
  position: relative;
  align-items: start;
  width: 100%;
  min-height: 76px;
  padding: 17px 52px 17px 17px;
  border: 2px solid var(--color-border, #c3d6e2);
  border-left: 6px solid var(--primary, #0b4b70);
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 22px 52px rgba(4, 40, 65, .3);
}
.toast.toast-success { border-left-color: var(--success, #17924d); }
.toast.toast-error { border-left-color: var(--danger, #ef4444); }
.toast.toast-warning { border-left-color: #f59e0b; }
.toast.toast-info { border-left-color: #159ed2; }
.toast-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #eaf6fb;
  color: #0879ae;
}
.toast-success .toast-icon { background: #e9f8ef; color: #168747; }
.toast-error .toast-icon { background: #fff0f1; color: #d92f42; }
.toast-warning .toast-icon { background: #fff6df; color: #b96d00; }
.toast > div { display: grid; min-width: 0; gap: 5px; }
.toast strong { color: var(--text-main, #07385a); font-size: .95rem; line-height: 1.25; }
.toast p { margin: 0; color: var(--text-muted, #62798c); font-size: .84rem; line-height: 1.45; }
.toast-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted, #62798c);
  cursor: pointer;
}
.toast-close:hover { background: #edf5f9; color: #07385a; }
.toast-action {
  justify-self: start;
  margin-top: 6px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: #e7f3f9;
  color: #073f63;
  font: inherit;
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
}
.toast.is-leaving { opacity: 0; transform: translateY(-18px); transition: .2s ease; }

/* Confirmaciones operativas: siempre visibles delante de la aplicación. */
.toast-container{top:max(12px,env(safe-area-inset-top));right:auto;bottom:auto;left:50%;z-index:50000;transform:translateX(-50%);width:min(520px,calc(100vw - 32px));max-height:calc(100dvh - 24px);pointer-events:none}.toast{pointer-events:auto;animation:toastSlideDown .22s ease-out}@keyframes toastSlideDown{from{opacity:0;transform:translateY(-18px)}to{opacity:1;transform:translateY(0)}}

.route-loading-shell { display: grid; gap: 18px; width: min(100%, 1080px); margin: 0 auto; padding: 26px 30px; }
.route-loading-heading { display: grid; grid-template-columns: 48px 1fr; gap: 9px 14px; padding: 22px; border: 1px solid #d6e4ec; border-radius: 16px; background: #fff; }
.route-loading-heading i { grid-row: 1 / 3; width: 48px; height: 48px; border-radius: 12px; }
.route-loading-heading span { display: block; width: min(300px, 70%); height: 18px; border-radius: 6px; }
.route-loading-heading span:last-child { width: min(430px, 88%); height: 11px; }
.ui-skeleton-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.notification-list .ui-skeleton-grid { grid-template-columns: 1fr; padding: 12px; }
.ui-skeleton-grid article { display: grid; grid-template-columns: 38px 1fr; gap: 9px 12px; padding: 18px; border: 1px solid #d6e4ec; border-radius: 14px; background: #fff; }
.ui-skeleton-grid article > i { grid-row: 1 / 4; width: 38px; height: 38px; border-radius: 10px; }
.ui-skeleton-grid article > span { height: 10px; border-radius: 5px; }
.ui-skeleton-grid article > span:nth-of-type(2) { width: 75%; }
.ui-skeleton-grid article > span:nth-of-type(3) { width: 52%; }
.ui-skeleton-table { display: grid; overflow: hidden; border: 1px solid #d6e4ec; border-radius: 14px; background: #fff; }
.ui-skeleton-table > span { display: grid; grid-template-columns: 1.1fr 1.8fr 1fr .8fr; gap: 14px; padding: 17px; border-bottom: 1px solid #e5edf2; }
.ui-skeleton-table > span:last-child { border-bottom: 0; }
.ui-skeleton-table i,
.ui-skeleton-grid i,
.ui-skeleton-grid span,
.route-loading-heading i,
.route-loading-heading span {
  background: linear-gradient(90deg, #e9f0f4 25%, #f7fafc 45%, #e9f0f4 65%);
  background-size: 300% 100%;
  animation: skeletonShimmer 1.25s ease-in-out infinite;
}
.ui-skeleton-table i { height: 10px; border-radius: 5px; }
@keyframes skeletonShimmer { to { background-position: -150% 0; } }

.ui-empty-state { min-height: 230px; border: 1px dashed #bfd4e1; border-radius: 14px; background: rgba(255, 255, 255, .72); }
.ui-empty-state > svg { width: 36px; height: 36px; color: #59a8cf; }

.ui-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 21000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 18, 30, .68);
  backdrop-filter: blur(5px);
}
.app-modal.ui-confirm-modal {
  display: grid;
  width: min(100%, 500px);
  gap: 12px;
  padding: 26px;
  border: 1px solid #c9dce8;
  border-radius: 18px;
  background: var(--surface, #fff);
  box-shadow: 0 28px 80px rgba(1, 28, 47, .35);
}
.ui-confirm-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: #e8f5fb; color: #087aae; }
.app-modal.ui-confirm-modal h2 { margin: 0; color: var(--text-main, #07385a); font-size: 1.25rem; }
.app-modal.ui-confirm-modal p { margin: 0; color: var(--text-muted, #61798d); line-height: 1.5; }
.ui-confirm-consequence { display: flex; align-items: start; gap: 9px; padding: 12px; border-radius: 10px; background: #fff5e6; color: #86520c; font-size: .75rem; }
.app-modal.ui-confirm-modal label { display: grid; gap: 7px; color: var(--text-main, #07385a); font-size: .75rem; font-weight: 800; }
.app-modal.ui-confirm-modal footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.action-danger { border-color: #ef4351 !important; background: #ef4351 !important; color: #fff !important; }

.ui-progress-steps { display: grid; gap: 12px; margin-top: 14px; padding: 15px; border: 1px solid #cfe1ec; border-radius: 13px; background: #f6fafc; }
.ui-progress-steps header { display: flex; align-items: center; gap: 10px; }
.ui-progress-steps header > div { display: grid; gap: 2px; }
.ui-progress-steps header strong { color: #07385a; font-size: .8rem; }
.ui-progress-steps header small { color: #627d91; font-size: .7rem; }
.ui-progress-step-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 7px; }
.ui-progress-step-list span { display: flex; align-items: center; gap: 6px; min-width: 0; color: #7890a2; font-size: var(--font-ui-caption); line-height: 1.4; }
.ui-progress-step-list i { display: grid; flex: 0 0 22px; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #e2ecf2; color: #5b7689; font-style: normal; font-weight: 900; }
.ui-progress-step-list .is-current { color: #087cb2; font-weight: 800; }
.ui-progress-step-list .is-current i { background: #d9f3ff; color: #087cb2; box-shadow: 0 0 0 2px #8ed8f4; }
.ui-progress-step-list .is-complete { color: #167f46; }
.ui-progress-step-list .is-complete i { background: #dff6e8; color: #167f46; }
.ui-progress-step-list .is-error { color: #c52d3e; }
.ui-progress-step-list .is-error i { background: #ffe8eb; color: #c52d3e; }

:where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid rgba(22, 166, 221, .4);
  outline-offset: 2px;
}

/* Iconografía global: Lucide es la única familia de iconos de interfaz. */
.icon,
.lucide {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.125rem;
  height: 1.125rem;
  vertical-align: middle;
  stroke-width: 2;
}
.icon-sm { width: .875rem; height: .875rem; }
.icon-md { width: 1.25rem; height: 1.25rem; }
.icon-lg { width: 1.75rem; height: 1.75rem; }
.icon-muted { color: var(--text-muted, #61798d); }
.icon-accent { color: var(--secondary, #0b8fbd); }
:where(button, a, label, summary, .action-button, .table-action, .btn-icon) > .lucide {
  flex-shrink: 0;
}
