:root {
  --ar-primary: var(--ynk-primary);
  --ar-primary-hover: var(--ynk-primary-hover);
  --ar-primary-light: var(--ynk-primary-light);
  --ar-surface: var(--ynk-bg);
  --ar-border: var(--ynk-border);
  --ar-text: var(--ynk-text);
  --ar-muted: var(--ynk-text-muted);
  --ar-radius: var(--ynk-radius-lg);
  --tblr-primary: var(--ynk-primary);
  --tblr-primary-rgb: 59, 0, 255;
  --tblr-font-sans-serif: var(--ynk-font);
  --tblr-body-font-family: var(--tblr-font-sans-serif);
  --ar-section-gap: 1.75rem;
  --ar-section-title-gap: 0.35rem;
  --ar-section-content-gap: 1rem;
}

.presupuesto-shell {
  min-height: calc(100vh - 80px);
  color: var(--ar-text);
}

.presupuesto-shell .container-xl {
  max-width: 1760px;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

/* ── Dashboard section spacing ── */

.presupuesto-shell .dashboard-section {
  margin-bottom: 0.75rem;
}

.presupuesto-shell .dashboard-section:last-child {
  margin-bottom: 0;
}

.presupuesto-shell .page-title {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  margin: 0;
}

.presupuesto-shell .page-subtitle {
  color: var(--ar-muted);
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
}

.presupuesto-shell .presupuesto-page-actions:empty {
  display: none;
}

/* ── Cards ── */

.presupuesto-shell .card {
  border-radius: var(--ar-radius);
  border: 1px solid var(--ar-border);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.presupuesto-shell .card-title {
  color: var(--ynk-text);
}

/* ── Section titles ── */

.presupuesto-shell .section-title {
  font-size: 1.6rem;
  margin: 0 0 var(--ar-section-title-gap);
  letter-spacing: -0.01em;
}

.presupuesto-shell .section-subtitle {
  color: var(--ar-muted);
  margin: 0 0 var(--ar-section-content-gap);
  font-size: 0.95rem;
}

/* ── Tables ── */

.presupuesto-shell .table thead th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ynk-text-secondary);
  background: var(--ynk-surface-secondary);
  border-bottom: 1px solid var(--ynk-border);
}

.presupuesto-shell .table td {
  vertical-align: middle;
}

.presupuesto-shell .table a {
  color: var(--ar-primary);
  font-weight: 600;
  text-decoration: none;
}

.presupuesto-shell .table a:hover {
  color: var(--ar-primary-hover);
  text-decoration: underline;
}

/* ── Buttons (global — applies to modals moved to body) ── */

body .btn-primary {
  background: var(--ar-primary);
  border-color: var(--ar-primary);
}

body .btn-primary:hover,
body .btn-primary:focus,
body .btn-primary:active {
  background: var(--ar-primary-hover);
  border-color: var(--ar-primary-hover);
}

/* ── Buttons (shell-scoped) ── */

.presupuesto-shell .btn-primary {
  background: var(--ar-primary);
  border-color: var(--ar-primary);
}

.presupuesto-shell .btn-primary:hover,
.presupuesto-shell .btn-primary:focus,
.presupuesto-shell .btn-primary:active {
  background: var(--ar-primary-hover);
  border-color: var(--ar-primary-hover);
}

.presupuesto-shell .btn-outline-primary {
  color: var(--ar-primary);
  border-color: rgba(59, 0, 255, 0.45);
}

.presupuesto-shell .btn-outline-primary:hover,
.presupuesto-shell .btn-outline-primary:focus,
.presupuesto-shell .btn-outline-primary:active {
  background: var(--ar-primary);
  border-color: var(--ar-primary);
  color: #fff;
}

/* ── Ghost primary button ── */

.presupuesto-shell .btn-ghost-primary {
  color: var(--ar-primary);
}

.presupuesto-shell .btn-ghost-primary:hover,
.presupuesto-shell .btn-ghost-primary:focus,
.presupuesto-shell .btn-ghost-primary:active {
  color: var(--ar-primary-hover);
  background: var(--ar-primary-light);
}

/* ── Form check ── */

.presupuesto-shell .form-check-input:checked {
  background-color: var(--ar-primary);
  border-color: var(--ar-primary);
}

.presupuesto-shell .form-check-input:focus {
  border-color: var(--ar-primary);
  box-shadow: 0 0 0 0.25rem rgba(59, 0, 255, 0.25);
}

/* ── Tabler color overrides ── */

body .text-primary {
  color: var(--ar-primary);
}

body .bg-blue-lt,
body .bg-azure-lt {
  background: var(--ynk-primary-light);
  color: var(--ar-primary);
}

body .badge.bg-blue-lt,
body .badge.bg-azure-lt {
  background: var(--ynk-primary-light);
  color: var(--ar-primary);
  font-weight: 600;
}

/* ── Empty state ── */

.empty-state-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--ynk-text-subtle);
  text-align: center;
}

.empty-state-box svg {
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state-box h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ynk-text-muted);
  margin: 0 0 0.35rem;
}

.empty-state-box p {
  font-size: 0.9rem;
  margin: 0;
  max-width: 400px;
}

/* ── Utility classes (replaces inline styles) ── */

.text-sm { font-size: var(--ynk-text-sm); }
.text-xs { font-size: var(--ynk-text-xs); }
.text-base { font-size: var(--ynk-text-base); }
.whitespace-nowrap { white-space: nowrap; }
.form-select-auto { width: auto; }
.link-unstyled { text-decoration: none; }
.link-unstyled:hover { text-decoration: underline; }
.alert-sm { font-size: var(--ynk-text-sm); }
.btn-wide { min-width: 180px; }
.cursor-pointer { cursor: pointer; }
.td-indent { padding-left: 1rem; }
.td-indent-lg { padding-left: 1.5rem; }
.opacity-65 { opacity: 0.65; }
.cursor-default { cursor: default; }
.provider-label { font-size: 0.72rem; opacity: 0.72; }
.disabled-item { opacity: 0.65; cursor: default; }

/* ── EERR table classes ── */

.table-sticky-col {
  position: sticky;
  left: 0;
  background: var(--ynk-surface);
  z-index: var(--ynk-z-base);
}

.th-month { min-width: 80px; }
.th-total { min-width: 100px; }
.th-concept { min-width: 200px; }
.th-subsection { min-width: 150px; }

.row-header {
  background: var(--ynk-surface-secondary);
}

.row-subtotal {
  border-top: 2px solid var(--ynk-border);
}

/* ── Ajustes page (extracted from inline <style>) ── */

.ajustes-shell {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: start;
}

.ajustes-subnav {
  position: sticky;
  top: 1.25rem;
}

.ajustes-subnav-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.ajustes-subnav-item {
  position: relative;
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.85rem 1rem 0.85rem 1.15rem;
  text-align: left;
  box-shadow: none;
  transition: border-color var(--ynk-duration-fast) var(--ynk-ease-default),
              background-color var(--ynk-duration-fast) var(--ynk-ease-default),
              color var(--ynk-duration-fast) var(--ynk-ease-default),
              box-shadow var(--ynk-duration-fast) var(--ynk-ease-default);
}

.ajustes-subnav-item::before {
  content: "";
  position: absolute;
  left: 0.7rem;
  top: 50%;
  width: 3px;
  height: 1.1rem;
  border-radius: var(--ynk-radius-pill);
  background: transparent;
  transform: translateY(-50%);
  transition: background-color var(--ynk-duration-fast) var(--ynk-ease-default);
}

.ajustes-subnav-item:hover {
  border-color: rgba(59, 0, 255, 0.22);
  background: rgba(255, 255, 255, 0.96);
}

.ajustes-subnav-item.is-active {
  border-color: rgba(59, 0, 255, 0.5);
  background: linear-gradient(135deg, var(--ynk-primary-light), rgba(255, 255, 255, 0.96));
  box-shadow: 0 16px 32px rgba(59, 0, 255, 0.08);
}

.ajustes-subnav-item.is-active::before {
  background: var(--ynk-primary);
}

.ajustes-subnav-item-title {
  display: block;
  font-size: 0.94rem;
  font-weight: var(--ynk-font-bold);
  color: var(--ynk-text);
  padding-left: 0.45rem;
}

.ajustes-subnav-item-meta {
  display: none;
}

.ajustes-panel-stack {
  min-width: 0;
}

.ajustes-panel[hidden] {
  display: none !important;
}

.ajustes-panel-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.ajustes-panel-eyebrow {
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  font-weight: var(--ynk-font-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ynk-text-faint);
}

.ajustes-panel-title {
  margin: 0;
  font-size: var(--ynk-text-xl);
  font-weight: var(--ynk-font-bold);
  color: var(--ynk-text);
}

.ajustes-panel-copy {
  margin: 0.35rem 0 0;
  max-width: 56rem;
  font-size: var(--ynk-text-base);
  line-height: var(--ynk-leading-relaxed);
  color: var(--ynk-text-faint);
}

.ajustes-panel-summary {
  flex: 0 0 auto;
  text-align: right;
  font-size: var(--ynk-text-xs);
  line-height: 1.45;
  color: var(--ynk-text-faint);
}

@media (max-width: 992px) {
  .ajustes-shell {
    grid-template-columns: 1fr;
  }

  .ajustes-subnav {
    position: static;
  }

  .ajustes-subnav-list {
    display: flex;
    gap: 0.65rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    margin: 0.85rem -0.1rem 0;
  }

  .ajustes-subnav-item {
    min-width: 200px;
    flex: 0 0 auto;
  }
}

@media (max-width: 768px) {
  .ajustes-panel-intro {
    align-items: start;
    flex-direction: column;
  }

  .ajustes-panel-summary {
    text-align: left;
  }
}

/* ── Import reconcile page (extracted from inline <style>) ── */

.store-reconcile-editor {
  min-width: 430px;
}

.store-reconcile-name {
  margin-bottom: 0.5rem;
}

.store-reconcile-select-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, 0.8fr);
  gap: 0.5rem;
  align-items: start;
}

.store-reconcile-type {
  min-width: 0;
}

.store-reconcile-suggestion {
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--ynk-text-muted);
}

@media (max-width: 1200px) {
  .store-reconcile-editor {
    min-width: 360px;
  }
  .store-reconcile-select-row {
    grid-template-columns: 1fr;
  }
}

/* ── Breadcrumbs ── */

.pulse-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  margin: 0 0 0.5rem;
  list-style: none;
  font-size: var(--ynk-text-sm);
  color: var(--ynk-text-subtle);
}

.pulse-breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pulse-breadcrumb li + li::before {
  content: "›";
  color: var(--ynk-border-heavy);
  font-size: 1rem;
  line-height: 1;
}

.pulse-breadcrumb a {
  color: var(--ynk-text-subtle);
  text-decoration: none;
  transition: color var(--ynk-duration-fast) var(--ynk-ease-default);
}

.pulse-breadcrumb a:hover {
  color: var(--ynk-primary);
}

.pulse-breadcrumb .is-current {
  color: var(--ynk-text-secondary);
  font-weight: var(--ynk-font-medium);
}

/* ── Focus-visible (global accessibility) ── */

.presupuesto-shell .btn:focus-visible,
.presupuesto-shell .form-control:focus-visible,
.presupuesto-shell .form-select:focus-visible,
.presupuesto-shell a:focus-visible {
  outline: 2px solid rgba(59, 0, 255, 0.4);
  outline-offset: 2px;
  box-shadow: none;
}

/* ── Danger button ── */

.presupuesto-shell .btn-danger {
  background: var(--ynk-danger);
  border-color: var(--ynk-danger);
  color: #fff;
}

.presupuesto-shell .btn-danger:hover,
.presupuesto-shell .btn-danger:focus,
.presupuesto-shell .btn-danger:active {
  background: var(--ynk-danger-text);
  border-color: var(--ynk-danger-text);
  color: #fff;
}

/* ── Ghost danger button ── */

.presupuesto-shell .btn-ghost-danger {
  color: var(--ynk-danger);
}

.presupuesto-shell .btn-ghost-danger:hover,
.presupuesto-shell .btn-ghost-danger:focus,
.presupuesto-shell .btn-ghost-danger:active {
  color: var(--ynk-danger-text);
  background: var(--ynk-danger-light);
}

/* ── Badge sizes ── */

.badge-sm {
  font-size: var(--ynk-text-2xs);
}

.badge-xs {
  font-size: 0.6rem;
}

/* ── Interactive badges (clickable) ── */

.badge-interactive {
  border: none;
  cursor: pointer;
  transition: opacity var(--ynk-duration-fast) var(--ynk-ease-default);
}

.badge-interactive:hover {
  opacity: 0.8;
}

/* ── Table scroll indicator ── */

.table-responsive {
  position: relative;
}

.table-responsive::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 24px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.85));
  opacity: 0;
  transition: opacity var(--ynk-duration-base) var(--ynk-ease-default);
}

.table-responsive.is-scrollable::after {
  opacity: 1;
}

.table-responsive.is-scrolled-end::after {
  opacity: 0;
}

/* ── Confirm dialog ── */

.pulse-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--ynk-z-modal);
  background: var(--ynk-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--ynk-duration-base) var(--ynk-ease-default);
}

.pulse-confirm-overlay.is-visible {
  opacity: 1;
}

.pulse-confirm-dialog {
  background: var(--ynk-surface);
  border-radius: var(--ynk-radius-xl);
  box-shadow: var(--ynk-shadow-elevated);
  padding: 1.75rem 2rem;
  width: min(420px, calc(100vw - 2rem));
  transform: scale(0.95);
  transition: transform var(--ynk-duration-base) var(--ynk-ease-out);
}

.pulse-confirm-overlay.is-visible .pulse-confirm-dialog {
  transform: scale(1);
}

.pulse-confirm-message {
  margin: 0 0 1.25rem;
  font-size: var(--ynk-text-base);
  line-height: var(--ynk-leading-normal);
  color: var(--ynk-text);
}

.pulse-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ── */

@media (max-width: 1200px) {
  .presupuesto-shell .container-xl {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

@media (max-width: 768px) {
  :root {
    --ar-section-gap: 1.25rem;
    --ar-section-content-gap: 0.85rem;
  }
  .presupuesto-shell .container-xl {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }
  .presupuesto-shell .page-title {
    font-size: 1.35rem;
  }
  .presupuesto-shell .section-title {
    font-size: 1.35rem;
  }
}
