/* ========================================================================== 
   MOA FINANCE — PREMIUM VISUAL SYSTEM
   Rediseño exclusivamente visual. La lógica, IDs y contratos JS se conservan.
   ========================================================================== */

/* 1. Variables y tokens
   ========================================================================== */
:root {
  color-scheme: light;

  --bg: #eef6f4;
  --bg-deep: #e4f0ed;
  --surface: #ffffff;
  --surface-soft: #f8fcfb;
  --surface-muted: #f2f8f7;
  --surface-teal: #e9f7f5;
  --surface-pink: #fff1f6;
  --surface-yellow: #fff9e8;
  --surface-plum: #f7eff7;

  --ink: #14373b;
  --ink-strong: #092f34;
  --muted: #668085;
  --muted-strong: #48656a;
  --line: #d8e8e5;
  --line-strong: #c5dbd7;

  --teal-950: #073f45;
  --teal-900: #07565e;
  --teal-800: #086c74;
  --teal: #0b7b83;
  --teal-500: #16949c;
  --teal-300: #73c4c7;
  --pink: #ed1b59;
  --pink-dark: #bd174b;
  --pink-soft: #fff0f5;
  --yellow: #f5cf62;
  --yellow-dark: #b98519;
  --plum: #58144f;
  --plum-light: #8b377f;
  --green: #149b77;
  --amber: #e7a72f;
  --red: #dc3c59;
  --blue: #218aa4;

  --positive-bg: #eaf8f2;
  --negative-bg: #fff0f3;
  --warning-bg: #fff8e6;
  --info-bg: #eaf6fa;

  --font-sans: "Manrope", "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-numeric: "Manrope", ui-sans-serif, system-ui, sans-serif;

  --radius-2xl: 30px;
  --radius-xl: 24px;
  --radius-lg: 19px;
  --radius-md: 15px;
  --radius-sm: 11px;
  --radius-xs: 8px;

  --shadow-xs: 0 3px 12px rgba(7, 63, 69, .05);
  --shadow-sm: 0 10px 28px rgba(7, 63, 69, .07);
  --shadow: 0 18px 48px rgba(7, 63, 69, .10);
  --shadow-strong: 0 28px 72px rgba(7, 63, 69, .17);
  --shadow-teal: 0 16px 36px rgba(11, 123, 131, .22);
  --shadow-pink: 0 15px 34px rgba(237, 27, 89, .20);

  --focus-ring: 0 0 0 4px rgba(22, 148, 156, .18);
  --focus-ring-pink: 0 0 0 4px rgba(237, 27, 89, .14);

  --sidebar-width: 282px;
  --content-max: 1640px;
  --topbar-height: 102px;

  --duration-fast: 150ms;
  --duration: 220ms;
  --duration-slow: 420ms;
  --ease: cubic-bezier(.2, .75, .25, 1);
  --ease-bounce: cubic-bezier(.2, 1.25, .4, 1);
}

/* 2. Reset y estilos base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 91% 3%, rgba(245, 207, 98, .20), transparent 20rem),
    radial-gradient(circle at 76% 35%, rgba(237, 27, 89, .055), transparent 25rem),
    radial-gradient(circle at 22% 75%, rgba(22, 148, 156, .08), transparent 26rem),
    linear-gradient(180deg, #f8fcfb 0%, var(--bg) 38%, #edf5f3 100%);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .32;
  background-image:
    linear-gradient(rgba(7, 63, 69, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7, 63, 69, .025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent, #000 16%, #000 84%, transparent);
}

img, svg, canvas { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

::selection {
  color: #fff;
  background: var(--teal);
}

.hidden { display: none !important; }
.mobile-only { display: none; }

/* 3. Tipografía
   ========================================================================== */
h1, h2, h3, h4, strong {
  color: var(--ink-strong);
}

h1, h2, h3, h4, p { text-wrap: pretty; }

.eyebrow {
  display: block;
  margin: 0;
  color: var(--pink);
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .17em;
}

.amount-positive {
  color: #08775b !important;
  font-weight: 820;
}

.amount-negative {
  color: #c7294c !important;
  font-weight: 820;
}

/* 4. Login
   ========================================================================== */
body.pre-auth .app-shell,
body.pre-auth .toast-stack { display: none; }

#auth-screen { display: none; }
body.pre-auth #auth-screen { display: flex; }
body.authed #auth-screen { display: none; }
body.role-viewer [data-admin-only] { display: none !important; }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, rgba(22, 148, 156, .40), transparent 46%),
    radial-gradient(circle at 12% 84%, rgba(237, 27, 89, .14), transparent 30%),
    radial-gradient(circle at 90% 10%, rgba(245, 207, 98, .13), transparent 28%),
    linear-gradient(145deg, #086c74 0%, #07565e 48%, #052f34 100%);
  isolation: isolate;
}

.auth-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .12;
  background:
    linear-gradient(180deg, rgba(7, 63, 69, .10), rgba(7, 63, 69, .62)),
    url('/assets/moa-brand-pattern.png') center / cover no-repeat;
  mix-blend-mode: screen;
}

.auth-screen::after {
  content: "";
  position: absolute;
  z-index: 0;
  width: min(76vw, 760px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 50%;
  box-shadow:
    0 0 0 80px rgba(255, 255, 255, .025),
    0 0 0 160px rgba(255, 255, 255, .018);
}

/* Fluido interactivo (liquid-ether.js). Va encima del degradado y debajo
   de las figuras de marca. No captura clics: el puntero se lee por posición. */
.login-fluid {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 1.1s var(--ease);
}
.login-fluid.is-ready { opacity: .9; }
.login-fluid canvas { display: block; width: 100%; height: 100%; }

.login-canvas { position: absolute; inset: 0; z-index: 2; opacity: .82; }
.lglow { position: absolute; border-radius: 50%; pointer-events: none; }
.lglow-a {
  width: 62vmin;
  height: 62vmin;
  top: 31%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(22, 148, 156, .15), transparent 67%);
}
.lglow-b {
  width: 42vmin;
  height: 42vmin;
  right: -8vmin;
  bottom: -10vmin;
  background: radial-gradient(circle, rgba(245, 207, 98, .10), transparent 67%);
}

.lshape {
  position: absolute;
  transform: translate(var(--px, 0px), var(--py, 0px));
  transition: transform var(--duration-fast) ease-out, filter var(--duration) ease;
  cursor: pointer;
  filter: drop-shadow(0 12px 22px rgba(1, 37, 41, .16));
}
.lshape-art {
  display: block;
  transform: rotate(var(--rot, 0deg));
  transform-origin: center;
}
.lshape:hover { z-index: 4; filter: drop-shadow(0 18px 30px rgba(1, 37, 41, .22)); }

.s-sunburst .lshape-art { width: clamp(105px, 18vmin, 190px); opacity: .88; }
.s-ribbon .lshape-art { width: clamp(48px, 7vmin, 76px); opacity: .92; }
.s-squiggle-pink .lshape-art { width: clamp(110px, 18vmin, 190px); }
.s-quotes .lshape-art { width: clamp(75px, 12vmin, 118px); opacity: .35; }
.s-gear .lshape-art { width: clamp(105px, 20vmin, 205px); opacity: .82; }
.s-arc .lshape-art { width: clamp(100px, 17vmin, 168px); }
.s-pill .lshape-art { width: clamp(105px, 18vmin, 176px); }
.s-squiggle-purple .lshape-art { width: clamp(100px, 17vmin, 166px); }
.s-spark .lshape-art { width: clamp(42px, 7vmin, 70px); }
.s-ring .lshape-art { width: clamp(46px, 7vmin, 75px); }

.float-a { animation: lshape-float-a 7s ease-in-out infinite; }
.float-b { animation: lshape-float-b 8.5s ease-in-out infinite; }
.float-c { animation: lshape-float-c 10s ease-in-out infinite; }
.spin-slow { animation: lshape-spin 32s linear infinite; }
.spin-rev { animation: lshape-spin 36s linear infinite reverse; }

@keyframes lshape-float-a {
  0%, 100% { transform: rotate(var(--rot, 0deg)) translateY(0); }
  50% { transform: rotate(var(--rot, 0deg)) translateY(-12px); }
}
@keyframes lshape-float-b {
  0%, 100% { transform: rotate(var(--rot, 0deg)) translateX(0); }
  50% { transform: rotate(var(--rot, 0deg)) translateX(11px); }
}
@keyframes lshape-float-c {
  0%, 100% { transform: rotate(var(--rot, 0deg)) translate(0, 0); }
  50% { transform: rotate(var(--rot, 0deg)) translate(-8px, -9px); }
}
@keyframes lshape-spin { to { transform: rotate(360deg); } }

.lshape:hover .lshape-art { animation: lshape-wiggle .55s ease; }
.lshape.is-pop .lshape-art { animation: lshape-pop .5s var(--ease-bounce); }
@keyframes lshape-wiggle {
  0%, 100% { transform: rotate(var(--rot, 0deg)) scale(1); }
  35% { transform: rotate(calc(var(--rot, 0deg) + 8deg)) scale(1.10); }
  70% { transform: rotate(calc(var(--rot, 0deg) - 6deg)) scale(1.06); }
}
@keyframes lshape-pop {
  0% { transform: rotate(var(--rot, 0deg)) scale(1); }
  42% { transform: rotate(calc(var(--rot, 0deg) + 16deg)) scale(1.26); }
  100% { transform: rotate(var(--rot, 0deg)) scale(1); }
}

.login-core {
  position: relative;
  z-index: 3;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: auth-rise .65s var(--ease) both;
}

/* Velo suave: el fluido se mueve detrás sin restar legibilidad al texto. */
.login-core::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 168%;
  height: 138%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(4, 40, 45, .58), rgba(4, 40, 45, .22) 60%, transparent 100%);
}

.moa-wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  pointer-events: none;
}
.moa-word {
  color: #fff;
  font-size: clamp(62px, 12vmin, 96px);
  font-weight: 900;
  letter-spacing: -.065em;
  text-shadow: 0 16px 40px rgba(2, 33, 37, .30);
}
.moa-sub {
  margin-top: 8px;
  padding-left: .42em;
  color: rgba(255, 255, 255, .92);
  font-size: clamp(12px, 2.2vmin, 17px);
  font-weight: 800;
  letter-spacing: .42em;
}

.login-panel {
  position: relative;
  width: 100%;
  padding: 32px 32px 27px;
  overflow: hidden;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .23);
  border-radius: var(--radius-2xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, .09)),
    rgba(7, 63, 69, .18);
  box-shadow:
    0 32px 76px rgba(1, 34, 38, .34),
    inset 0 1px 0 rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  backdrop-filter: blur(22px) saturate(1.15);
}
.login-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  width: 76%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
}
.login-panel::after {
  content: "";
  position: absolute;
  right: -52px;
  bottom: -58px;
  width: 150px;
  height: 150px;
  border: 18px solid rgba(245, 207, 98, .11);
  border-radius: 50%;
  pointer-events: none;
}
.login-kicker {
  position: relative;
  margin: 0 0 7px;
  color: var(--yellow);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .22em;
}
.login-title {
  position: relative;
  margin: 0 0 10px;
  color: #fff;
  font-size: clamp(23px, 4vw, 29px);
  font-weight: 850;
  letter-spacing: -.035em;
}
.login-desc {
  position: relative;
  max-width: 315px;
  margin: 0 auto 23px;
  color: rgba(255, 255, 255, .83);
  font-size: 13px;
  line-height: 1.6;
}
.google-signin-slot {
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 44px;
  filter: drop-shadow(0 10px 18px rgba(1, 32, 36, .16));
}
.auth-error {
  position: relative;
  max-width: 310px;
  margin: 16px auto 0;
  padding: 11px 13px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 13px;
  background: rgba(237, 27, 89, .90);
  box-shadow: 0 12px 28px rgba(88, 20, 79, .24);
  font-size: 12px;
  font-weight: 680;
  line-height: 1.45;
}
.auth-footnote {
  position: relative;
  display: block;
  margin-top: 21px;
  color: rgba(255, 255, 255, .66);
  font-size: 10.5px;
}
@keyframes auth-rise {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: none; }
}

/* 5. Layout general
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  grid-column: 2;
  min-width: 0;
  padding: 0 clamp(20px, 3vw, 46px) 58px;
}

.main > * {
  width: min(100%, var(--content-max));
  margin-inline: auto;
}

.view { display: none; }
.view.active {
  display: block;
  animation: section-enter .38s var(--ease) both;
}

@keyframes section-enter {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.panel {
  position: relative;
  border: 1px solid rgba(197, 219, 215, .78);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(250, 253, 252, .96));
  box-shadow: var(--shadow-sm);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 26px;
  right: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .95), transparent);
  pointer-events: none;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.panel-heading h2,
.section-actions h2 {
  margin: 5px 0 0;
  color: var(--ink-strong);
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -.02em;
}
.panel-heading small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

/* 6. Sidebar
   ========================================================================== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  padding: 26px 19px 20px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 12% 0%, rgba(22, 148, 156, .55), transparent 32%),
    linear-gradient(165deg, #075d65 0%, var(--teal-950) 72%, #052f34 100%);
  box-shadow: 22px 0 60px rgba(7, 63, 69, .16);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background:
    linear-gradient(180deg, rgba(7, 63, 69, .22), rgba(7, 63, 69, .78)),
    url('/assets/moa-brand-pattern.png') center / cover no-repeat;
  mix-blend-mode: screen;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 40%;
  right: -128px;
  width: 205px;
  height: 205px;
  border: 25px solid rgba(245, 207, 98, .10);
  border-radius: 50%;
  pointer-events: none;
}

.sidebar > * { position: relative; z-index: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 7px 30px;
}
.brand-mark-wrap {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .30);
  border-radius: 17px;
  background: rgba(255, 255, 255, .13);
  box-shadow:
    0 15px 30px rgba(0, 0, 0, .17),
    inset 0 1px 0 rgba(255, 255, 255, .15);
}
.brand img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.brand strong {
  display: block;
  color: #fff;
  font-size: 17px;
  font-weight: 830;
  letter-spacing: -.02em;
}
.brand span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, .58);
  font-size: 8.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .15em;
}

.nav { display: grid; gap: 7px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 47px;
  padding: 11px 13px;
  overflow: hidden;
  color: rgba(255, 255, 255, .70);
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  font-weight: 680;
  transition:
    transform var(--duration) var(--ease),
    color var(--duration) ease,
    border-color var(--duration) ease,
    background var(--duration) ease,
    box-shadow var(--duration) ease;
}
.nav-item::after {
  content: "";
  position: absolute;
  inset: 7px auto 7px 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: transparent;
  transition: background var(--duration) ease, box-shadow var(--duration) ease;
}
.nav-item span {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  color: rgba(255, 255, 255, .78);
  border-radius: 8px;
  font-size: 17px;
  transition: background var(--duration) ease, color var(--duration) ease, transform var(--duration) var(--ease);
}
.nav-item:hover {
  transform: translateX(2px);
  color: #fff;
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .075);
}
.nav-item:hover span { transform: scale(1.05); color: var(--yellow); }
.nav-item.active {
  color: #fff;
  border-color: rgba(255, 255, 255, .16);
  background:
    linear-gradient(135deg, rgba(22, 148, 156, .42), rgba(11, 123, 131, .20)),
    rgba(255, 255, 255, .08);
  box-shadow:
    0 13px 28px rgba(1, 36, 40, .18),
    inset 0 1px 0 rgba(255, 255, 255, .12);
}
.nav-item.active::after {
  background: linear-gradient(180deg, var(--yellow), var(--pink));
  box-shadow: 0 0 16px rgba(245, 207, 98, .40);
}
.nav-item.active span {
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--plum-light));
  box-shadow: 0 7px 16px rgba(237, 27, 89, .24);
}

.sidebar-card {
  position: relative;
  margin-top: auto;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 19px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .035)),
    rgba(3, 42, 47, .52);
  box-shadow:
    0 17px 36px rgba(1, 31, 35, .18),
    inset 0 1px 0 rgba(255, 255, 255, .10);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.sidebar-card::after {
  content: "";
  position: absolute;
  right: -34px;
  bottom: -40px;
  width: 95px;
  height: 95px;
  border: 13px solid rgba(245, 207, 98, .10);
  border-radius: 50%;
}
.sidebar-card .eyebrow { color: var(--yellow); }
.sidebar-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin: 10px 0 4px;
  color: #fff;
  font-family: var(--font-numeric);
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -.03em;
}
.sidebar-card small { position: relative; z-index: 1; color: rgba(255, 255, 255, .58); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 15px;
  background: rgba(3, 42, 47, .46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}
.sidebar-user .user-avatar {
  width: 36px;
  height: 36px;
  flex: none;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, .38);
  border-radius: 50%;
}
.sidebar-user .user-meta {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.sidebar-user .user-meta strong {
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-role-pill {
  align-self: flex-start;
  padding: 2px 8px;
  color: rgba(255, 255, 255, .72);
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .09em;
}
.user-role-pill.admin { color: #a4f1da; background: rgba(20, 155, 119, .22); }
.user-role-pill.viewer { color: #ffe28c; background: rgba(231, 167, 47, .20); }
.sidebar-user #sign-out-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
  flex: none;
  color: #fff;
  border-color: rgba(255, 255, 255, .18);
  border-radius: 10px;
  background: rgba(255, 255, 255, .07);
}
.sidebar-user #sign-out-btn:hover {
  border-color: rgba(237, 27, 89, .48);
  background: rgba(237, 27, 89, .28);
  box-shadow: 0 8px 18px rgba(35, 3, 27, .18);
}
.sidebar-footer {
  padding: 13px 7px 0;
  color: rgba(255, 255, 255, .40);
  font-size: 9.5px;
  letter-spacing: .015em;
}

/* 7. Topbar
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: var(--topbar-height);
  margin-bottom: 1px;
  padding: 16px 0 14px;
  background: linear-gradient(180deg, rgba(248, 252, 251, .97) 0%, rgba(248, 252, 251, .91) 76%, rgba(248, 252, 251, 0) 100%);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  backdrop-filter: blur(18px) saturate(1.1);
}
.topbar::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 7px;
  left: 0;
  height: 1px;
  opacity: .65;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}
.topbar h1 {
  margin: 6px 0 0;
  color: var(--ink-strong);
  font-size: clamp(25px, 3vw, 35px);
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -.045em;
}
.topbar-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--muted-strong);
  border: 1px solid rgba(197, 219, 215, .85);
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow-xs);
  font-size: 11.5px;
  font-weight: 700;
}
.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(231, 167, 47, .15);
  animation: status-pulse 2.2s ease-in-out infinite;
}
.status-pill.online span { background: var(--green); box-shadow: 0 0 0 4px rgba(20, 155, 119, .14); }
.status-pill.error span { background: var(--red); box-shadow: 0 0 0 4px rgba(220, 60, 89, .14); }
@keyframes status-pulse { 50% { transform: scale(.82); opacity: .75; } }

/* 8. Botones
   ========================================================================== */
.btn,
.icon-btn,
.action-btn,
.quick-range {
  position: relative;
  isolation: isolate;
  font-weight: 760;
  transition:
    transform var(--duration-fast) var(--ease),
    box-shadow var(--duration) ease,
    border-color var(--duration) ease,
    background var(--duration) ease,
    color var(--duration) ease,
    opacity var(--duration) ease;
}

.btn {
  min-height: 42px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  overflow: hidden;
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, .28), transparent 80%);
  transform: translateX(-110%);
  transition: transform .45s var(--ease), opacity var(--duration) ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:hover::after { opacity: 1; transform: translateX(110%); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:disabled {
  cursor: not-allowed;
  opacity: .52;
  transform: none;
  box-shadow: none;
}
.btn:disabled::after { display: none; }

.btn-primary {
  color: #fff;
  border-color: rgba(7, 86, 94, .24);
  background: linear-gradient(135deg, var(--teal-500), var(--teal) 48%, var(--teal-900));
  box-shadow: var(--shadow-teal);
}
.btn-primary:hover {
  border-color: rgba(7, 86, 94, .40);
  box-shadow: 0 19px 40px rgba(11, 123, 131, .28);
}
.btn-secondary {
  color: var(--teal-900);
  border-color: var(--line);
  background: rgba(255, 255, 255, .93);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  border-color: rgba(11, 123, 131, .30);
  background: var(--surface-teal);
  box-shadow: var(--shadow-sm);
}
.btn-ghost {
  color: var(--pink-dark);
  border-color: transparent;
  background: transparent;
}
.btn-ghost:hover {
  color: var(--pink);
  background: var(--surface-pink);
  box-shadow: none;
}
.btn-large { min-height: 51px; padding-inline: 24px; border-radius: 14px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--teal-900);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-xs);
}
.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(11, 123, 131, .28);
  background: var(--surface-teal);
  box-shadow: var(--shadow-sm);
}
.icon-btn:active { transform: translateY(0) scale(.97); }

.action-btn {
  min-height: 31px;
  padding: 5px 10px;
  color: var(--pink-dark);
  border: 1px solid rgba(237, 27, 89, .20);
  border-radius: 9px;
  background: var(--surface-pink);
  font-size: 10.5px;
  font-weight: 820;
}
.action-btn:hover {
  transform: translateY(-1px);
  color: #fff;
  border-color: var(--pink);
  background: var(--pink);
  box-shadow: 0 9px 18px rgba(237, 27, 89, .18);
}

/* 9. Filtros
   ========================================================================== */
.filter-panel {
  position: relative;
  margin-bottom: 24px;
  padding: 19px;
  overflow: hidden;
  border: 1px solid rgba(11, 123, 131, .14);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .96), rgba(247, 252, 251, .88));
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.filter-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--teal-500), var(--pink), var(--yellow));
}
.filter-panel::after {
  content: "";
  position: absolute;
  top: -84px;
  right: -68px;
  width: 145px;
  height: 145px;
  border: 21px solid rgba(245, 207, 98, .18);
  border-radius: 50%;
  pointer-events: none;
}
.filter-panel-heading {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.filter-panel-heading h2 {
  margin: 5px 0 0;
  color: var(--ink-strong);
  font-size: 17px;
  letter-spacing: -.02em;
}
.filter-panel-meta { display: flex; align-items: center; gap: 8px; }
.filter-result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 33px;
  padding: 7px 11px;
  color: var(--teal-900);
  border: 1px solid rgba(11, 123, 131, .10);
  border-radius: 999px;
  background: var(--surface-teal);
  font-size: 10.5px;
  font-weight: 820;
}
.filter-result-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--teal-500);
}
.quick-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 15px;
}
.quick-range {
  min-height: 33px;
  padding: 6px 12px;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  font-size: 10.5px;
}
.quick-range:hover,
.quick-range:focus-visible {
  transform: translateY(-1px);
  color: var(--teal-900);
  border-color: rgba(11, 123, 131, .30);
  background: var(--surface-teal);
  box-shadow: var(--shadow-xs);
}
.quick-range:active {
  transform: none;
  color: #fff;
  background: var(--teal);
}
.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}
.filter-bar label,
.form-grid label {
  display: grid;
  gap: 7px;
  min-width: 0;
}
.filter-bar label > span,
.form-grid label > span,
.field-label {
  color: var(--muted-strong);
  font-size: 9.5px;
  font-weight: 850;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: .075em;
}

/* 10. Inputs y formularios base
   ========================================================================== */
input,
select,
textarea {
  width: 100%;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  background-color: rgba(255, 255, 255, .96);
  box-shadow: inset 0 1px 0 rgba(7, 63, 69, .015);
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    background var(--duration-fast) ease,
    transform var(--duration-fast) ease;
}
input,
select { height: 44px; padding: 0 12px; }
textarea { min-height: 92px; padding: 12px; resize: vertical; }
select {
  padding-right: 34px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--teal-800) 50%),
    linear-gradient(135deg, var(--teal-800) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 19px,
    calc(100% - 11px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input::placeholder,
textarea::placeholder { color: #98aaa9; }
input:hover,
select:hover,
textarea:hover { border-color: #b8d4cf; }
input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal-500);
  background-color: #fff;
  box-shadow: var(--focus-ring);
}
input:disabled,
select:disabled,
textarea:disabled,
input[readonly] {
  cursor: not-allowed;
  color: #789094;
  border-color: #dce8e6;
  background: #f2f7f6;
  box-shadow: none;
}
input[type="radio"],
input[type="checkbox"] {
  width: auto;
  height: auto;
  padding: 0;
  accent-color: var(--pink);
}
input[type="search"] { appearance: none; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

/* 11. Tarjetas financieras
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 18px;
}
.kpi-card {
  --card-accent: var(--teal);
  --card-soft: rgba(11, 123, 131, .08);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 145px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(197, 219, 215, .82);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 104% -8%, var(--card-soft), transparent 48%),
    linear-gradient(155deg, #fff 0%, #fbfefd 100%);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--duration) var(--ease),
    box-shadow var(--duration) ease,
    border-color var(--duration) ease;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--card-accent), color-mix(in srgb, var(--card-accent), white 38%));
}
.kpi-card::after {
  content: "";
  position: absolute;
  top: 17px;
  right: 17px;
  width: 38px;
  height: 38px;
  border: 9px solid var(--card-soft);
  border-radius: 50%;
  transition: transform var(--duration-slow) var(--ease);
}
.kpi-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--card-accent), white 62%);
  box-shadow: var(--shadow);
}
.kpi-card:hover::after { transform: rotate(18deg) scale(1.08); }
.kpi-card.positive { --card-accent: var(--green); --card-soft: rgba(20, 155, 119, .11); }
.kpi-card.warning { --card-accent: var(--amber); --card-soft: rgba(245, 207, 98, .18); }
.kpi-card.info { --card-accent: var(--blue); --card-soft: rgba(33, 138, 164, .11); }
.kpi-card.danger { --card-accent: var(--pink); --card-soft: rgba(237, 27, 89, .10); }
.kpi-card.accent { --card-accent: var(--plum); --card-soft: rgba(88, 20, 79, .10); }
.kpi-card.neutral { --card-accent: var(--teal); --card-soft: rgba(11, 123, 131, .09); }
.kpi-card > span {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 45px);
  color: var(--muted-strong);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .09em;
}
.kpi-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin: auto 0 7px;
  color: var(--ink-strong);
  font-family: var(--font-numeric);
  font-size: clamp(24px, 2.25vw, 34px);
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.kpi-card small {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
}

.cash-reconciliation-panel {
  margin-bottom: 16px;
  padding: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 0%, rgba(11, 123, 131, .08), transparent 34%),
    linear-gradient(155deg, #ffffff 0%, #fbfefd 100%);
}
.cash-reconciliation-heading { align-items: flex-start; }
.cash-reconciliation-heading small {
  display: block;
  max-width: 760px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.reconciliation-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 11px;
  border: 1px solid rgba(11, 123, 131, .14);
  border-radius: 999px;
  color: var(--teal-900);
  background: var(--surface-teal);
  font-size: 9.5px;
  font-weight: 850;
  letter-spacing: .02em;
  white-space: nowrap;
}
.reconciliation-status.success { color: var(--green); background: var(--positive-bg); border-color: rgba(20, 155, 119, .18); }
.reconciliation-status.warning { color: var(--yellow-dark); background: var(--warning-bg); border-color: rgba(211, 160, 26, .20); }
.reconciliation-status.danger { color: var(--pink); background: var(--negative-bg); border-color: rgba(196, 8, 71, .18); }
.reconciliation-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 17px 0 13px;
}
.reconciliation-overview > div {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid rgba(197, 219, 215, .74);
  border-radius: 15px;
  background: rgba(247, 251, 250, .74);
}
.reconciliation-overview span {
  color: var(--muted-strong);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.reconciliation-overview strong {
  color: var(--ink-strong);
  font-family: var(--font-numeric);
  font-size: clamp(18px, 2vw, 25px);
  font-variant-numeric: tabular-nums;
}
.reconciliation-overview small { color: var(--muted); font-size: 9.5px; }
.reconciliation-lines {
  border: 1px solid rgba(197, 219, 215, .76);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}
.reconciliation-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 12px 15px;
  border-bottom: 1px solid #edf3f2;
}
.reconciliation-line:last-child { border-bottom: 0; }
.reconciliation-line > span { display: grid; gap: 2px; }
.reconciliation-line > span > strong {
  color: var(--muted-strong);
  font-size: 10.5px;
  font-weight: 800;
}
.reconciliation-line small {
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.4;
}
.reconciliation-line > strong {
  color: var(--ink-strong);
  font-family: var(--font-numeric);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.reconciliation-line.total {
  background: linear-gradient(90deg, rgba(11, 123, 131, .08), rgba(11, 123, 131, .03));
  border-top: 1px solid rgba(11, 123, 131, .13);
}
.reconciliation-line.total > span > strong,
.reconciliation-line.total > strong { color: var(--teal-900); font-weight: 900; }
.reconciliation-line.bank { background: rgba(88, 20, 79, .035); }
.reconciliation-line.bank > span > strong { color: var(--plum); }
.reconciliation-alert {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  font-size: 10px;
  line-height: 1.5;
  font-weight: 650;
}
.reconciliation-alert.warning { color: #7a5a00; background: var(--warning-bg); border: 1px solid rgba(211, 160, 26, .18); }
.reconciliation-alert.danger { color: var(--pink); background: var(--negative-bg); border: 1px solid rgba(196, 8, 71, .16); }

.insights-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr);
  gap: 16px;
  margin-bottom: 16px;
}
.insights-panel,
.health-panel { padding: 21px; }
.insights-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.insight {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 11px;
  align-items: start;
  min-height: 91px;
  padding: 13px;
  border: 1px solid rgba(197, 219, 215, .72);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .96), rgba(247, 251, 250, .92));
  transition: transform var(--duration) var(--ease), border-color var(--duration) ease, box-shadow var(--duration) ease;
}
.insight:hover {
  transform: translateY(-2px);
  border-color: #bcd7d2;
  box-shadow: var(--shadow-xs);
}
.insight-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--teal);
  border-radius: 12px;
  background: var(--surface-teal);
  font-weight: 900;
}
.insight.warning .insight-icon { color: var(--yellow-dark); background: var(--warning-bg); }
.insight.danger .insight-icon { color: var(--pink); background: var(--negative-bg); }
.insight.positive .insight-icon { color: var(--green); background: var(--positive-bg); }
.insight strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  line-height: 1.35;
}
.insight p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.48;
}

.health-metrics { display: grid; gap: 16px; margin-top: 20px; }
.metric-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  align-items: center;
}
.metric-row span { color: var(--muted-strong); font-size: 11px; font-weight: 720; }
.metric-row strong {
  color: var(--ink-strong);
  font-family: var(--font-numeric);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.metric-bar {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8f0ee;
}
.metric-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-500), var(--teal), var(--pink));
  box-shadow: 0 0 15px rgba(22, 148, 156, .22);
  transition: width .65s var(--ease);
}

/* 12. Gráficas y mini tablas
   ========================================================================== */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.chart-card {
  min-width: 0;
  padding: 21px;
  overflow: hidden;
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) ease, border-color var(--duration) ease;
}
.chart-card:hover {
  transform: translateY(-2px);
  border-color: rgba(11, 123, 131, .20);
  box-shadow: var(--shadow);
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-wrap {
  position: relative;
  height: 285px;
  margin-top: 16px;
  padding: 4px 0 0;
}
.chart-card.wide .chart-wrap { height: 330px; }
.help {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  color: var(--teal-900);
  border: 1px solid rgba(11, 123, 131, .16);
  border-radius: 50%;
  background: var(--surface-teal);
  font-size: 11px;
  font-weight: 850;
  cursor: help;
}
.mini-table { margin-top: 15px; border-top: 1px solid var(--line); }
.mini-table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 1px;
  border-bottom: 1px solid #edf3f2;
}
.mini-table-row:last-child { border-bottom: 0; }
.mini-table-row span { color: var(--muted-strong); font-size: 11px; }
.mini-table-row strong {
  color: var(--ink-strong);
  font-family: var(--font-numeric);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.bank-balance-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}
.bank-balance-table .mini-table-row span { display: grid; gap: 2px; }
.bank-balance-table .mini-table-row small { color: var(--muted); font-size: 9.5px; }
.bank-balance-table .mini-table-row .bank-bcv-reference { color: var(--teal-800); font-weight: 750; }

/* 13. Secciones, estado de resultados y tablas
   ========================================================================== */
.section-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 4px 0 17px;
}
.section-actions p:not(.eyebrow) {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.pnl-card { padding: clamp(20px, 3vw, 32px); }
.pnl-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.pnl-title > div { display: flex; align-items: center; gap: 12px; }
.pnl-title img {
  width: 47px;
  height: 47px;
  object-fit: cover;
  border-radius: 15px;
  box-shadow: var(--shadow-xs);
}
.pnl-title h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.pnl-title p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.pnl-title > span {
  padding: 7px 12px;
  color: var(--teal-900);
  border: 1px solid rgba(11, 123, 131, .11);
  border-radius: 999px;
  background: var(--surface-teal);
  font-size: 10.5px;
  font-weight: 820;
}
.pnl-summary {
  display: grid;
  gap: 7px;
  max-width: 680px;
  margin: 26px auto;
}
.pnl-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 46px;
  padding: 10px 15px;
  border-radius: 12px;
}
.pnl-line span { color: var(--muted-strong); font-size: 12px; }
.pnl-line strong {
  font-family: var(--font-numeric);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.pnl-line.subtotal {
  border: 1px solid rgba(11, 123, 131, .12);
  background: var(--surface-teal);
}
.pnl-line.total {
  color: #fff;
  border: 1px solid rgba(7, 63, 69, .18);
  background: linear-gradient(135deg, var(--teal), var(--teal-900));
  box-shadow: var(--shadow-teal);
}
.pnl-line.total span,
.pnl-line.total strong { color: #fff; }
.pnl-line.negative strong { color: var(--pink); }
.pnl-notes {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid rgba(245, 207, 98, .35);
  border-radius: 15px;
  background: var(--surface-yellow);
}
.pnl-notes h3 { margin: 0 0 5px; font-size: 12px; }
.pnl-notes p { margin: 0; color: #74652e; font-size: 10.5px; line-height: 1.55; }
.pnl-notes .pnl-accounting-note {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(116, 101, 46, .16);
  font-weight: 700;
}

.table-panel { padding: 15px; overflow: hidden; }
.table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1.55fr) repeat(5, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 13px;
}
.table-tools > * { min-width: 0; }
.table-scroll {
  width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid rgba(216, 232, 229, .92);
  border-radius: 15px;
  background: #fff;
  scrollbar-color: #a8c8c3 #edf5f3;
  scrollbar-width: thin;
}
.table-scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.table-scroll::-webkit-scrollbar-track { background: #edf5f3; }
.table-scroll::-webkit-scrollbar-thumb { border: 2px solid #edf5f3; border-radius: 999px; background: #a8c8c3; }
.data-table {
  width: 100%;
  min-width: 850px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
}
.movement-table { min-width: 1480px; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 13px;
  color: #536c71;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fcfb, #f2f8f7);
  font-size: 9px;
  font-weight: 850;
  line-height: 1.3;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .075em;
  white-space: nowrap;
}
.data-table th:first-child { border-radius: 14px 0 0 0; }
.data-table th:last-child { border-radius: 0 14px 0 0; }
.data-table td {
  padding: 13px;
  color: #38585d;
  border-bottom: 1px solid #edf3f2;
  background: #fff;
  font-size: 10.5px;
  line-height: 1.45;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #f7fbfa; }
.data-table td strong { color: var(--ink-strong); font-size: 10.8px; }
.data-table td small { color: var(--muted); font-size: 9.5px; }
.data-table td:nth-last-child(n+3):nth-last-child(-n+7),
.pnl-table td:not(:first-child),
.pnl-table th:not(:first-child) {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.data-table tfoot th {
  color: var(--ink-strong);
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
  background: var(--surface-teal);
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 8px;
  color: var(--teal-900);
  border: 1px solid rgba(11, 123, 131, .11);
  border-radius: 999px;
  background: var(--surface-teal);
  font-size: 8.5px;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .045em;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  margin-right: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge.entry { color: #08775b; background: var(--positive-bg); border-color: rgba(20, 155, 119, .16); }
.badge.cost { color: #a8750f; background: var(--warning-bg); border-color: rgba(231, 167, 47, .18); }
.badge.expense { color: #c7294c; background: var(--negative-bg); border-color: rgba(237, 27, 89, .16); }
.badge.transfer { color: var(--plum); background: var(--surface-plum); border-color: rgba(88, 20, 79, .13); }
.badge.void { color: #6f7f82; background: #eef2f2; border-color: #dce5e3; }
.empty-state {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 210px;
  padding: 25px;
  color: var(--muted);
  text-align: center;
}
.empty-state::before {
  content: "↕";
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 3px;
  color: var(--teal);
  border: 1px solid rgba(11, 123, 131, .13);
  border-radius: 15px;
  background: var(--surface-teal);
  font-size: 20px;
}
.empty-state strong { color: var(--ink-strong); }
.empty-state span { font-size: 11px; }

/* 14. Formularios de registro
   ========================================================================== */
.form-layout {
  display: grid;
  gap: 16px;
  max-width: 1120px;
}
.form-card {
  position: relative;
  padding: clamp(20px, 2.5vw, 27px);
  overflow: hidden;
}
.form-card::after {
  content: "";
  position: absolute;
  top: -82px;
  right: -78px;
  width: 130px;
  height: 130px;
  border: 18px solid rgba(11, 123, 131, .045);
  border-radius: 50%;
  pointer-events: none;
}
.form-section-title {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
}
.form-section-title > span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: #fff;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-900));
  box-shadow: 0 10px 22px rgba(11, 123, 131, .20);
  font-weight: 900;
}
.form-section-title h3 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.form-section-title p { margin: 4px 0 0; color: var(--muted); font-size: 11.5px; }

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(135px, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #edf5f3;
}
.segmented.large { display: grid; max-width: 460px; margin-top: 15px; }
.segmented.direction-options {
  max-width: 790px;
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(165px, 1fr));
}
.segmented label { cursor: pointer; }
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented label span {
  display: grid;
  place-items: center;
  min-height: 41px;
  padding: 8px 12px;
  color: #667d81;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 820;
  text-align: center;
  transition: color var(--duration) ease, background var(--duration) ease, border-color var(--duration) ease, box-shadow var(--duration) ease, transform var(--duration-fast) var(--ease);
}
.segmented label:hover span { color: var(--teal-900); background: rgba(255, 255, 255, .50); }
.segmented input:checked + span {
  color: var(--pink-dark);
  border-color: rgba(237, 27, 89, .10);
  background: #fff;
  box-shadow: 0 8px 20px rgba(7, 63, 69, .10);
}
.segmented input:focus-visible + span { box-shadow: var(--focus-ring-pink), 0 8px 20px rgba(7, 63, 69, .10); }
.segmented input:active + span { transform: scale(.985); }

.conditional {
  margin-top: 18px;
  padding-top: 2px;
  animation: conditional-enter .25s var(--ease) both;
}
@keyframes conditional-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.field-help { margin: 9px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid small { color: var(--muted); font-size: 9.5px; line-height: 1.45; }
.transfer-accounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 17px;
  border: 1px solid rgba(11, 123, 131, .16);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .65), transparent),
    var(--surface-teal);
}
.rate-card {
  border-color: rgba(11, 123, 131, .18);
  background:
    radial-gradient(circle at 100% 0%, rgba(245, 207, 98, .10), transparent 34%),
    linear-gradient(145deg, #fff, #f3fbfa);
}
.rate-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 13px;
}
.rate-summary > div {
  position: relative;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}
.rate-summary > div::after {
  content: "";
  position: absolute;
  right: -22px;
  bottom: -25px;
  width: 70px;
  height: 70px;
  border: 10px solid rgba(11, 123, 131, .055);
  border-radius: 50%;
}
.rate-summary span,
.rate-summary small { position: relative; z-index: 1; display: block; color: var(--muted); }
.rate-summary span { font-size: 10px; font-weight: 760; }
.rate-summary small { font-size: 9.5px; }
.rate-summary strong {
  position: relative;
  z-index: 1;
  display: block;
  margin: 8px 0 5px;
  font-family: var(--font-numeric);
  font-size: 28px;
  font-weight: 850;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.rate-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 16px;
}

.exchange-panel {
  position: relative;
  margin-top: 16px;
  padding: 19px;
  overflow: hidden;
  border: 1px solid rgba(11, 123, 131, .20);
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(245, 207, 98, .14), transparent 28%),
    linear-gradient(145deg, #fff, #eaf7f5);
  box-shadow: inset 0 1px 0 #fff;
}
.exchange-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--yellow), var(--pink), var(--plum));
}
.exchange-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 17px;
}
.exchange-panel-heading h4 { margin: 5px 0 4px; font-size: 18px; letter-spacing: -.02em; }
.exchange-panel-heading small { color: var(--muted); line-height: 1.45; }
.exchange-operation-badge {
  display: inline-flex;
  align-items: center;
  min-height: 35px;
  flex: 0 0 auto;
  padding: 7px 12px;
  color: #fff;
  border: 1px solid rgba(7, 63, 69, .15);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--teal), var(--plum));
  box-shadow: 0 10px 22px rgba(7, 86, 94, .19);
  font-size: 10.5px;
  font-weight: 850;
}
.exchange-input-grid { align-items: stretch; }
.exchange-result {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 93px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-xs);
}
.exchange-result span,
.exchange-result small,
.exchange-metrics span,
.exchange-metrics small { color: var(--muted); font-size: 10.5px; }
.exchange-result strong {
  font-family: var(--font-numeric);
  font-size: 23px;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.exchange-formula {
  margin-top: 12px;
  padding: 11px 13px;
  color: #695a25;
  border-left: 3px solid var(--yellow);
  border-radius: 0 11px 11px 0;
  background: rgba(245, 207, 98, .16);
  font-size: 10.5px;
  font-weight: 730;
}
.exchange-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 13px;
}
.exchange-metrics > div {
  padding: 14px;
  border: 1px solid rgba(11, 123, 131, .09);
  border-radius: 13px;
  background: rgba(255, 255, 255, .88);
}
.exchange-metrics strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-numeric);
  font-size: 17px;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.exchange-differential-metric {
  grid-column: span 2;
  background: linear-gradient(135deg, #fff, var(--surface-yellow)) !important;
}
.exchange-metrics .amount-positive,
.exchange-metrics .amount-negative { font-size: 17px; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted-strong);
  font-size: 11px;
  cursor: pointer;
}
.switch-row input { width: 17px; height: 17px; accent-color: var(--pink); }
#manual-rate-fields {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.form-submit-bar {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 17px;
  border: 1px solid rgba(11, 123, 131, .18);
  border-radius: 17px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
}
.form-submit-bar strong,
.form-submit-bar span { display: block; }
.form-submit-bar span { margin-top: 3px; color: var(--muted); font-size: 10.5px; }

/* 15. Toasts, carga y estados
   ========================================================================== */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 28px));
}
.toast {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-strong);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: toast-in .28s var(--ease) both;
}
.toast::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--green);
}
.toast.error::before { background: var(--pink); }
.toast-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--green);
  border-radius: 10px;
  background: var(--positive-bg);
  font-weight: 900;
}
.toast.error .toast-icon { color: var(--pink); background: var(--negative-bg); }
.toast strong { display: block; margin-bottom: 3px; font-size: 12px; }
.toast p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.toast button {
  width: 28px;
  height: 28px;
  padding: 0;
  color: #809396;
  border: 0;
  border-radius: 8px;
  background: transparent;
}
.toast button:hover { color: var(--pink); background: var(--surface-pink); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--teal-950);
  background: rgba(238, 246, 244, .82);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  font-weight: 820;
}
.loading-overlay.visible { display: grid; }
.loader {
  width: 45px;
  height: 45px;
  border: 4px solid #cfe4e0;
  border-top-color: var(--pink);
  border-right-color: var(--yellow);
  border-radius: 50%;
  box-shadow: 0 8px 22px rgba(7, 63, 69, .12);
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 16. Focus y accesibilidad
   ========================================================================== */
:where(button, input, select, textarea):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn-primary:focus-visible,
.nav-item:focus-visible,
.action-btn:focus-visible { box-shadow: var(--focus-ring-pink), var(--shadow-teal); }
.nav-item:focus-visible { border-color: rgba(255, 255, 255, .40); }

/* 17. Responsive
   ========================================================================== */
@media (max-width: 1380px) {
  :root { --sidebar-width: 268px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .table-tools { grid-template-columns: minmax(230px, 1.4fr) repeat(2, minmax(150px, .8fr)); }
}

@media (max-width: 1100px) {
  .insights-layout { grid-template-columns: 1fr; }
  .chart-wrap { height: 270px; }
}

@media (max-width: 1020px) {
  :root { --topbar-height: 88px; }
  .mobile-only { display: inline-grid; place-items: center; }
  .app-shell { display: block; }
  .sidebar {
    width: min(292px, calc(100vw - 48px));
    transform: translateX(-106%);
    transition: transform .28s var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding-inline: 18px; }
  .topbar { gap: 14px; }
  .topbar > div:first-of-type { margin-right: auto; }
  .status-pill,
  .topbar-actions .btn-secondary { display: none; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body::before { background-size: 32px 32px; }
  .main { padding-inline: 12px; padding-bottom: 40px; }
  .topbar {
    flex-wrap: wrap;
    min-height: auto;
    padding-block: 12px 15px;
  }
  .topbar h1 { font-size: 25px; }
  .topbar-actions .btn-primary { min-height: 39px; padding-inline: 12px; font-size: 11px; }
  .filter-panel { padding: 16px 14px 15px; }
  .filter-panel-heading { align-items: flex-start; flex-direction: column; }
  .filter-panel-meta { width: 100%; justify-content: space-between; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi-card { min-height: 132px; padding: 17px; }
  .kpi-card strong { font-size: 25px; }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
  .chart-card { padding: 17px; }
  .chart-wrap,
  .chart-card.wide .chart-wrap { height: 285px; }
  .insights-list { grid-template-columns: 1fr; }
  .section-actions { align-items: stretch; flex-direction: column; }
  .button-row { flex-wrap: wrap; }
  .table-tools { grid-template-columns: 1fr; }
  .form-grid,
  .rate-summary,
  .transfer-accounts,
  .bank-balance-table { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .exchange-metrics { grid-template-columns: 1fr 1fr; }
  .exchange-differential-metric { grid-column: 1 / -1; }
  .exchange-panel-heading { flex-direction: column; }
  .rate-actions,
  .form-submit-bar { align-items: stretch; flex-direction: column; }
  .form-submit-bar { position: static; }
  .segmented { width: 100%; grid-auto-columns: 1fr; }
  .segmented.direction-options { grid-template-columns: 1fr; }
  .pnl-title { align-items: flex-start; }
}

@media (max-width: 560px) {
  .auth-screen { padding: 19px; }
  .login-core { max-width: 355px; gap: 19px; }
  .login-panel { padding: 27px 22px 24px; border-radius: 24px; }
  .s-quotes,
  .s-ring { display: none; }
  .s-sunburst { opacity: .65; }
  .login-fluid.is-ready { opacity: .78; }
  .moa-word { font-size: 67px; }

  .topbar-actions { width: 100%; }
  .topbar-actions .btn-primary { width: 100%; }
  .filter-bar,
  .kpi-grid { grid-template-columns: 1fr; }
  .quick-ranges { display: grid; grid-template-columns: 1fr 1fr; }
  .quick-range { width: 100%; }
  .kpi-card { min-height: 122px; }
  .exchange-metrics { grid-template-columns: 1fr; }
  .exchange-differential-metric { grid-column: auto; }
  .pnl-title { flex-direction: column; }
  .pnl-line { padding-inline: 12px; }
  .pnl-line span { font-size: 10.5px; }
  .pnl-line strong { font-size: 12px; text-align: right; }
  .toast-stack { right: 14px; bottom: 14px; }
}

@media (max-width: 380px) {
  .main { padding-inline: 10px; }
  .topbar h1 { font-size: 22px; }
  .quick-ranges { grid-template-columns: 1fr; }
  .filter-panel-meta { align-items: stretch; flex-direction: column; }
  .filter-panel-meta .btn { width: 100%; }
  .section-actions .button-row { display: grid; grid-template-columns: 1fr; }
  .button-row .btn { width: 100%; }
  .form-card { padding: 18px 15px; }
  .rate-summary strong { font-size: 23px; }
}

/* 18. Impresión
   ========================================================================== */
@media print {
  :root { color-scheme: light; }
  * { animation: none !important; transition: none !important; }
  body { overflow: visible; background: #fff; }
  body::before { display: none; }
  .sidebar,
  .topbar,
  .filter-panel,
  .section-actions,
  #view-dashboard,
  #view-movements,
  #view-register { display: none !important; }
  .main { padding: 0; }
  #view-pnl { display: block !important; }
  .pnl-card { padding: 0; border: 0; box-shadow: none; }
  .table-scroll { overflow: visible; border: 0; }
  .data-table { min-width: 0; }
  .data-table th { position: static; }
}

/* 19. Movimiento reducido
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .lshape { transform: none !important; }
  .login-fluid { display: none; }
}


/* Costos por línea de servicio: detalle interactivo */
.cost-service-detail { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border, #d8e8e5); }
.cost-service-detail-heading { margin-bottom: 10px; }
.cost-service-detail-heading h3 { margin: 0 0 4px; font-size: 1rem; }
.cost-service-detail-heading small { color: var(--muted, #64748b); }
.cost-service-detail-chart { min-height: 360px; }

/* ==========================================================================
   20. Paginador de la tabla de movimientos (carga por bloques)
   ========================================================================== */

.movement-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed rgba(216, 232, 229, .95);
  border-radius: 14px;
  background: rgba(244, 248, 248, .55);
}

.movement-pager.hidden { display: none; }

#movement-pager-note {
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted, #6B7F82);
}

#movement-sentinel { height: 1px; }

@media (max-width: 700px) {
  .reconciliation-overview { grid-template-columns: 1fr; }
  .reconciliation-line { grid-template-columns: 1fr; gap: 7px; }
  .reconciliation-line > strong { text-align: left; }
  .cash-reconciliation-heading { align-items: flex-start; }
}
