/* ============================================================
   FinanzasDIOS — Design System v6.0 · "Acacia"
   Estética: Editorial desaturado · navegación lateral
     · Paleta sage-mint + iris-dusty (menos neón)
     · Más Newsreader · animaciones físicas con overshoot
     · Navegacion principal integrada en cabecera de vista
   Tipografía: Newsreader (display serif) + Geist (UI) + Geist Mono
   Drop-in replacement — todas las clases originales preservadas
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,300;1,6..72,400;1,6..72,500&family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ── TOKENS · oscuro por defecto ── */
:root {
  /* Fondos · grafito frío con leve calidez */
  --bg:        #0b101a;
  --bg-2:      #0f1524;
  --panel:     #151c2d;
  --panel-2:   #1d2640;
  --panel-3:   #283354;
  --glass:     rgba(21, 28, 45, 0.78);

  /* Bordes */
  --line:      rgba(180, 195, 230, 0.10);
  --line-2:    rgba(180, 195, 230, 0.20);
  --line-ink:  rgba(180, 195, 230, 0.45);

  /* Texto */
  --text:      #f4f6fc;
  --text-2:    #c8d0e5;
  --muted:     #8290b5;
  --muted-2:   #535e7e;

  /* Acentos · sage-mint + iris desaturado (paleta sobria) */
  --green:     #4cb497;          /* sage-mint · desaturado */
  --green-2:   #3a957c;
  --green-dim: rgba(76, 180, 151, 0.13);
  --green-glow:rgba(76, 180, 151, 0.24);

  --blue:      #8a7fc7;          /* iris dusty */
  --blue-dim:  rgba(138, 127, 199, 0.13);
  --blue-glow: rgba(138, 127, 199, 0.22);

  --red:       #d77584;          /* coral suave */
  --red-dim:   rgba(215, 117, 132, 0.12);

  --yellow:    #d8b35a;          /* oro apagado */
  --yellow-dim:rgba(216, 179, 90, 0.13);

  --purple:    #a99ace;
  --sage:      #6fa48b;
  --sage-dim:  rgba(111, 164, 139, 0.12);

  /* Gradiente firma — sage→mint→iris, todos desaturados */
  --grad-brand: linear-gradient(135deg, #4cb497 0%, #5fb0a6 45%, #8a7fc7 100%);
  --grad-brand-soft: linear-gradient(135deg, rgba(76,180,151,0.12), rgba(138,127,199,0.12));

  /* Tipografía · trío nuevo */
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-ui:      'Geist', system-ui, -apple-system, sans-serif;
  --font-mono:    'Geist Mono', 'JetBrains Mono', 'Fira Mono', monospace;

  /* Forma · radios intermedios — fluido pero contenido */
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* Sombras · capas suaves */
  --shadow-sm: 0 2px 8px rgba(5, 8, 18, 0.30);
  --shadow-md: 0 12px 32px rgba(5, 8, 18, 0.42), 0 2px 6px rgba(5, 8, 18, 0.28);
  --shadow-lg: 0 28px 70px rgba(5, 8, 18, 0.55), 0 6px 18px rgba(5, 8, 18, 0.34);
  --shadow-green: 0 0 0 4px rgba(76, 180, 151, 0.14);
  --shadow-iris:  0 0 0 4px rgba(138, 127, 199, 0.14);

  /* Transiciones · más físicas, con overshoot real */
  --ease:        cubic-bezier(0.32, 0.94, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);   /* overshoot pronunciado */
  --ease-out-back: cubic-bezier(0.18, 1.6, 0.4, 1);   /* rubber-band fuerte */
  --dur:         240ms;
  --dur-fast:    160ms;
  --dur-slow:    480ms;
}

/* ── Modo claro · marfil tibio · paleta desaturada ── */
:root[data-theme="light"] {
  --bg:        #f4f0e6;
  --bg-2:      #ece6d8;
  --panel:     #fdfaf2;
  --panel-2:   #f6f1e4;
  --panel-3:   #ece5d0;
  --glass:     rgba(253, 250, 242, 0.84);

  --line:      rgba(40, 38, 54, 0.10);
  --line-2:    rgba(40, 38, 54, 0.20);
  --line-ink:  rgba(40, 38, 54, 0.55);

  --text:      #1a1828;
  --text-2:    #3a3850;
  --muted:     #756f86;
  --muted-2:   #a39bb0;

  --green:     #3a8c74;
  --green-2:   #2e7460;
  --green-dim: rgba(58, 140, 116, 0.10);
  --green-glow:rgba(58, 140, 116, 0.20);

  --blue:      #6c5fa0;
  --blue-dim:  rgba(108, 95, 160, 0.10);
  --blue-glow: rgba(108, 95, 160, 0.20);

  --red:       #b8546a;
  --red-dim:   rgba(184, 84, 106, 0.10);

  --yellow:    #a07e2b;
  --yellow-dim:rgba(160, 126, 43, 0.12);

  --purple:    #6c5fa0;
  --sage:      #4f8a72;
  --sage-dim:  rgba(79, 138, 114, 0.10);

  --grad-brand: linear-gradient(135deg, #3a8c74 0%, #4f9a8a 50%, #6c5fa0 100%);
  --grad-brand-soft: linear-gradient(135deg, rgba(58,140,116,0.08), rgba(108,95,160,0.08));

  --shadow-sm: 0 1px 3px rgba(20, 28, 50, 0.06);
  --shadow-md: 0 10px 32px rgba(20, 28, 50, 0.10), 0 2px 6px rgba(20, 28, 50, 0.06);
  --shadow-lg: 0 24px 64px rgba(20, 28, 50, 0.14), 0 6px 16px rgba(20, 28, 50, 0.08);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01';
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 70% 38% at 14% -8%,  rgba(76, 180, 151, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 36% at 92% 8%,   rgba(138, 127, 199, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 30% at 50% 110%, rgba(138, 127, 199, 0.06) 0%, transparent 60%);
  background-attachment: fixed;
}

:root[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 70% 38% at 14% -6%, rgba(58, 140, 116, 0.07) 0%, transparent 62%),
    radial-gradient(ellipse 64% 36% at 96% 18%, rgba(108, 95, 160, 0.06) 0%, transparent 60%);
}

button, input, select, textarea { font: inherit; }
a {
  color: var(--green);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--blue); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--panel-3);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: padding-box; }

::selection { background: var(--green-dim); color: var(--text); }

/* ── SHELL ── */
.app-shell { min-height: 100vh; }

/* ══════════════════════════════════════
   LOGIN
══════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 56% 50% at 50% 0%,   rgba(76, 180, 151, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(138, 127, 199, 0.08) 0%, transparent 60%),
    var(--bg);
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  inset: -20% -10% auto auto;
  width: 56vw;
  height: 56vw;
  background: radial-gradient(circle at center, rgba(138, 127, 199, 0.07), transparent 60%);
  pointer-events: none;
  filter: blur(20px);
}

.login-panel {
  position: relative;
  width: min(100%, 430px);
  padding: 44px 36px 34px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.55s var(--ease-spring) both;
  isolation: isolate;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── BRAND ── */
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 6px;
}

.brand-lockup h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  padding: 0;
  background: var(--grad-brand);
  color: #0a1e18;
  border: none;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: 1.5rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), var(--shadow-sm);
}

.brand-mark.small { width: 40px; height: 40px; border-radius: 11px; font-size: 1.15rem; }

.brand-kicker {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 6px;
}

.muted-copy {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
  margin-top: 8px;
  line-height: 1.6;
  max-width: 38ch;
}

/* ── PIN / AMOUNT DISPLAY · serif grande ── */
.pin-display,
.amount-display {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 400;
  text-align: center;
  padding: 20px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.01em;
  color: var(--text);
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), color var(--dur);
}

.pin-display:not(:empty) {
  color: var(--green);
  border-color: rgba(76, 180, 151, 0.35);
  box-shadow: var(--shadow-green);
}

/* ── PIN FIELD ── */
.pin-field {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-form { display: grid; gap: 0; }

/* ── KEYPAD ── */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.compact-keypad { margin-top: 20px; }

/* ── KEYS & BUTTONS ── */
.key {
  min-height: 56px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  cursor: pointer;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    transform 120ms var(--ease-spring),
    box-shadow var(--dur) var(--ease);
}

.key:hover  { background: var(--panel-3); border-color: var(--line-2); transform: translateY(-1px); }
.key:active { transform: scale(0.95); }

.key.accent,
.primary-button {
  background: var(--grad-brand);
  color: #0a1e18;
  border-color: transparent;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 20px rgba(76, 180, 151, 0.26), inset 0 1px 0 rgba(255,255,255,0.16);
}
.key.accent:hover,
.primary-button:hover {
  filter: brightness(1.07);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(76, 180, 151, 0.36), inset 0 1px 0 rgba(255,255,255,0.20);
}

.key.utility,
.secondary-button {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 0.92rem;
}
.key.utility:hover,
.secondary-button:hover {
  background: var(--panel-2);
  border-color: var(--line-ink);
  color: var(--text);
}

.icon-button {
  min-height: 40px;
  width: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.icon-button:hover {
  color: var(--text);
  border-color: var(--line-2);
  background: var(--panel-3);
  transform: translateY(-1px);
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  transition: all var(--dur) var(--ease);
}
.primary-button:active,
.secondary-button:active { transform: scale(0.98); }

.error-copy {
  color: var(--red);
  font-size: 0.86rem;
  margin-top: 14px;
  text-align: center;
  background: var(--red-dim);
  border: 1px solid rgba(251, 113, 133, 0.26);
  border-radius: var(--radius);
  padding: 10px 14px;
}

/* ══════════════════════════════════════
   WORKSPACE
══════════════════════════════════════ */
/* ── WORKSPACE deja espacio al rail vertical ── */
.workspace {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0 40px 0;
  padding-left: 90px;   /* ancho del rail collapsed + aire */
}

@media (min-width: 1500px) {
  .workspace { padding-left: 0; }
}

/* ── TOPBAR · glass del v3 ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 14px 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  position: sticky;
  top: 12px;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.brand-lockup.compact { gap: 14px; }

.brand-lockup.compact strong {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-lockup.compact span {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
  font-family: var(--font-ui);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  min-height: 36px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(76, 180, 151, 0.26);
  background: var(--green-dim);
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  transition: all var(--dur) var(--ease);
}
.profile-pill:hover { background: rgba(76, 180, 151, 0.18); }

/* ── MODE SWITCH ── editorial: con border-bottom, no card ── */
.mode-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 4px 4px 20px 4px;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  margin-bottom: 22px;
}

.mode-switch strong {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 2rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  min-height: 30px;
  border-radius: 0;
  border: none;
  background: transparent;
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--green);
  box-shadow: 0 0 8px var(--green), 0 0 0 3px var(--green-dim);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity:1; transform: scale(1); } 50% { opacity:0.6; transform: scale(0.94); } }

.sync-pill.offline .status-dot { background: var(--red); box-shadow: 0 0 8px var(--red), 0 0 0 3px var(--red-dim); animation: none; }
.sync-pill.syncing .status-dot { background: var(--yellow); box-shadow: 0 0 8px var(--yellow), 0 0 0 3px var(--yellow-dim); }

/* ── CONTENT ── */
.content-area,
.view-stack { display: grid; gap: 22px; }

/* ── NOTICE BANNER ── */
.notice-banner {
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(76, 180, 151, 0.28);
  border-left: 3px solid var(--green);
  background: var(--green-dim);
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideDown 0.34s var(--ease-spring) both;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ══════════════════════════════════════
   METRICS GRID — cards con cifras serif
══════════════════════════════════════ */
.metrics-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.analytics-metrics { margin-top: -4px; }
.compact-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.metric-card {
  padding: 22px 22px 24px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  display: grid;
  gap: 8px;
  min-height: 124px;
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease-spring);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-brand);
  opacity: 0;
  transition: opacity var(--dur);
}
.metric-card::after {
  content: '';
  position: absolute;
  inset: auto -30% -60% auto;
  width: 200px; height: 200px;
  background: radial-gradient(circle at center, var(--green-dim), transparent 70%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  pointer-events: none;
}
.metric-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.metric-card:hover::before { opacity: 1; }
.metric-card:hover::after  { opacity: 1; }

.metric-card span {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.metric-card strong {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.025em;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}

/* ══════════════════════════════════════
   SURFACES / CARDS
══════════════════════════════════════ */
.surface {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.surface:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }

.surface-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.surface-head h2 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.65rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.015em;
}

.toolbar-head { justify-content: space-between; }

/* ── DASHBOARD GRID ── */
.dashboard-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1.4fr 0.8fr;
}

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

.chart-surface.wide { min-height: 320px; }
canvas { width: 100% !important; height: 260px !important; }

/* ── LISTS · hairlines del v4 + hover sutil ── */
.stack-list,
.account-list,
.rank-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0;
}

.stack-list li,
.account-list li,
.rank-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  transition: padding var(--dur) var(--ease), color var(--dur);
}
.stack-list li:last-child,
.account-list li:last-child,
.rank-list li:last-child { border-bottom: none; }

.stack-list li:hover,
.account-list li:hover,
.rank-list li:hover {
  padding-left: 8px;
  color: var(--text);
}

.rank-list li strong {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--green);
  font-feature-settings: 'tnum' 1;
}

.alert-row span { display: grid; gap: 4px; }
.alert-row small { color: var(--muted); font-size: 0.8rem; line-height: 1.5; }
.alert-row b {
  text-transform: uppercase;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--yellow);
  background: var(--yellow-dim);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(252, 211, 77, 0.24);
  white-space: nowrap;
  font-weight: 700;
}

.account-list li strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text);
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}

/* ══════════════════════════════════════
   QUICK ENTRY / FORMS
══════════════════════════════════════ */
.quick-entry-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 0.9fr 1.1fr;
}

.amount-display {
  font-size: 3rem;
  min-height: 110px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

/* ── SEGMENTED CONTROL · v3 con tipografía limpia ── */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 18px;
  padding: 5px;
  background: var(--panel-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.segmented button {
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.segmented button.active {
  background: var(--grad-brand);
  color: #0a1e18;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(76, 180, 151, 0.26);
}
.segmented button:not(.active):hover { color: var(--text); background: var(--panel-3); }

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

.field-caption {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ── INPUTS · híbrido: borde fino + focus ring mint ── */
select,
input:not([type="checkbox"]):not([type="file"]):not([type="radio"]),
textarea {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 14px;
  font-size: 0.92rem;
  font-family: var(--font-ui);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur);
  outline: none;
}

select:hover,
input:hover:not([type="checkbox"]):not([type="file"]):not([type="radio"]),
textarea:hover { border-color: var(--line-ink); }

select:focus,
input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(76, 180, 151, 0.14);
  background: var(--panel);
}

select { cursor: pointer; }
textarea { resize: vertical; min-height: 88px; line-height: 1.55; }

input::placeholder,
textarea::placeholder { color: var(--muted-2); }

/* ── CHIP ROW ── */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.chip-button:hover {
  background: var(--green-dim);
  border-color: rgba(76, 180, 151, 0.36);
  color: var(--green);
  transform: translateY(-1px);
}

/* ── ADVANCED BLOCK ── */
.advanced-block {
  grid-column: 1 / -1;
  padding: 16px 0 4px;
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.advanced-block summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  user-select: none;
  transition: color var(--dur-fast);
}
.advanced-block summary:hover { color: var(--text); }
.advanced-grid { margin-top: 16px; }

/* ── ACTION ROW ── */
.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ── CONFIG NAV ── */
.config-nav-groups {
  display: grid;
  gap: 22px;
  margin-top: 26px;
}

.config-nav-group {
  display: grid;
  gap: 12px;
}

.config-nav-group h3 {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

.config-tile {
  min-height: 118px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), transparent),
    var(--panel-2);
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition:
    transform 260ms var(--ease-spring),
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.config-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(76, 180, 151, 0.34);
  background:
    linear-gradient(180deg, rgba(76, 180, 151, 0.10), transparent),
    var(--panel);
  box-shadow: 0 10px 28px rgba(0,0,0,0.20), 0 0 0 1px rgba(76, 180, 151, 0.06);
  color: var(--text);
}

.config-tile:active { transform: scale(0.985); }

.config-tile .tile-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid rgba(76, 180, 151, 0.24);
  background: rgba(76, 180, 151, 0.10);
  color: var(--green);
  font-size: 1.05rem;
}

.config-tile strong {
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
}

.config-tile small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.automation-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.action-tile {
  min-height: 92px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "icon title"
    "icon detail";
  align-content: center;
  column-gap: 12px;
  row-gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(34, 45, 74, 0.52);
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition:
    transform 260ms var(--ease-spring),
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.action-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(151, 160, 217, 0.38);
  background: rgba(43, 56, 91, 0.74);
  box-shadow: 0 10px 26px rgba(0,0,0,0.18);
  color: var(--text);
}

.action-tile span {
  grid-area: icon;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(151, 160, 217, 0.13);
  color: var(--accent);
  font-weight: 800;
}

.action-tile strong {
  grid-area: title;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.25;
}

.action-tile small {
  grid-area: detail;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.action-tile.primary-action {
  border-color: rgba(76, 180, 151, 0.30);
  background: rgba(76, 180, 151, 0.10);
}

.action-tile.primary-action span {
  background: rgba(76, 180, 151, 0.16);
  color: var(--green);
}

.action-tile.danger-action {
  border-color: rgba(230, 88, 88, 0.24);
}

.action-tile.danger-action span {
  background: rgba(230, 88, 88, 0.12);
  color: var(--red);
}

/* ── FILTER ROW ── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-row input { flex: 1 1 200px; }

/* ══════════════════════════════════════
   TABLES · editorial v4 + hover mint v3
══════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

table { width: 100%; border-collapse: collapse; min-width: 640px; }

thead tr { background: transparent; border-bottom: 1px solid var(--line-ink); }

th {
  padding: 14px 18px;
  text-align: left;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-bottom: none;
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  color: var(--text-2);
}

td:last-child {
  font-family: var(--font-mono);
  text-align: right;
  font-weight: 500;
  color: var(--text);
  font-feature-settings: 'tnum' 1;
}

th.numeric-cell,
td.numeric-cell {
  text-align: right;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1;
}

th.status-cell,
td.status-cell {
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}

th.actions-cell,
td.actions-cell {
  width: 132px;
  text-align: right;
  font-family: var(--font-ui);
}

.danger-link {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(251, 113, 133, 0.28);
  background: rgba(251, 113, 133, 0.09);
  color: var(--red);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.danger-link:hover {
  background: rgba(251, 113, 133, 0.16);
  border-color: rgba(251, 113, 133, 0.42);
}

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

tbody tr {
  transition: background var(--dur) var(--ease);
}
tbody tr:hover { background: rgba(76, 180, 151, 0.05); }
tbody tr:hover td { color: var(--text); }

/* ══════════════════════════════════════
   CARDS GRID
══════════════════════════════════════ */
.card-grid,
.settings-grid,
.report-grid,
.category-columns {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.mini-card,
.report-card,
.category-row {
  min-height: 110px;
  padding: 20px;
  display: grid;
  gap: 10px;
  align-content: start;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  transition: all var(--dur) var(--ease);
}

.mini-card:hover,
.report-card:hover,
.category-row:hover {
  border-color: var(--line-2);
  background: var(--panel-3);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.mini-card span,
.category-row span {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mini-card strong {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.015em;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}

.mini-card small { font-size: 0.82rem; color: var(--muted); }

.report-card {
  text-align: left;
  cursor: pointer;
  min-height: 90px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.12rem;
  font-weight: 400;
  color: var(--text);
  border-left: 2px solid transparent;
  position: relative;
  overflow: hidden;
}
.report-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grad-brand-soft);
  opacity: 0;
  transition: opacity var(--dur);
  pointer-events: none;
}
.report-card:hover {
  border-left-color: var(--green);
  color: var(--text);
  padding-left: 22px;
  transform: translateX(2px);
}
.report-card:hover::before { opacity: 1; }
.report-card > * { position: relative; z-index: 1; }

.category-row {
  min-height: 58px;
  font-size: 0.9rem;
  font-family: var(--font-ui);
  font-style: normal;
}

/* ══════════════════════════════════════
   DRAFT CARDS
══════════════════════════════════════ */
.draft-list { display: grid; gap: 16px; }

.draft-card {
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--yellow);
  background: var(--panel);
  transition: all var(--dur) var(--ease);
}
.draft-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.draft-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}
.draft-head strong {
  color: var(--yellow);
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

/* ══════════════════════════════════════
   TEMPLATES
══════════════════════════════════════ */
.template-card { min-height: 170px; align-content: start; }
.template-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; }

/* ══════════════════════════════════════
   IMPORT
══════════════════════════════════════ */
.import-drop { display: grid; gap: 16px; }

input[type="file"] {
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--line-2);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  transition: all var(--dur) var(--ease);
}
input[type="file"]:hover {
  border-color: var(--green);
  color: var(--text);
  background: var(--green-dim);
}

/* ══════════════════════════════════════
   PLACEHOLDER
══════════════════════════════════════ */
.placeholder-block {
  min-height: 170px;
  display: grid;
  align-items: center;
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--line-2);
  background: var(--panel-2);
  color: var(--text-2);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.7;
  text-align: center;
}

.placeholder-block.subtle { color: var(--muted); }
.placeholder-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 22px; }

/* ══════════════════════════════════════
   NAV · accesos principales en cabecera de vista
══════════════════════════════════════ */
.bottom-nav {
  position: static;
  z-index: auto;
  width: min(100%, 760px);
  padding: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  background: rgba(15, 21, 36, 0.62);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow-sm);
}

:root[data-theme="light"] .bottom-nav { background: rgba(253, 250, 242, 0.88); }

.bottom-nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 132px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    transform 280ms var(--ease-spring),
    box-shadow var(--dur) var(--ease);
}

.bottom-nav button .nav-icon {
  flex-shrink: 0;
  width: 20px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  transition: transform 280ms var(--ease-spring);
}

.bottom-nav button .nav-label {
  font-family: var(--font-ui);
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 1;
  transform: none;
  transition: color var(--dur) var(--ease);
}

.bottom-nav button:hover {
  color: var(--text);
  background: var(--panel-2);
  transform: translateY(-1px);
}
.bottom-nav button:hover .nav-icon { transform: scale(1.08) rotate(-2deg); }
.bottom-nav button:active { transform: scale(0.96); }

.bottom-nav button.active {
  position: relative;
  background: var(--green-dim);
  border-color: rgba(76, 180, 151, 0.28);
  color: var(--green);
  box-shadow: 0 4px 14px rgba(76, 180, 151, 0.18), inset 0 1px 0 rgba(255,255,255,0.04);
  animation: navActivePop 520ms var(--ease-out-back);
}

.bottom-nav button.active::before {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
}

@keyframes navActivePop {
  0%   { transform: scale(0.94); }
  55%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ══════════════════════════════════════
   FAB · gradiente firma del v3
══════════════════════════════════════ */
.register-fab {
  position: fixed;
  z-index: 42;
  right: 24px;
  bottom: 92px;
  display: grid;
  justify-items: end;
  gap: 8px;
}

.fab-main {
  min-width: 162px;
  min-height: 50px;
  padding: 0 22px;
  border-radius: var(--radius-pill);
  background: var(--grad-brand);
  color: #0a1e18;
  border: none;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(76, 180, 151, 0.32), 0 0 0 1px rgba(255,255,255,0.05), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: all var(--dur) var(--ease-spring);
}
.fab-main:hover {
  filter: brightness(1.06);
  box-shadow: 0 16px 40px rgba(76, 180, 151, 0.42), 0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 rgba(255,255,255,0.20);
  transform: translateY(-3px);
}
.fab-main:active { transform: translateY(-1px) scale(0.97); }

.fab-menu {
  display: none;
  width: 224px;
  padding: 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-2);
  background: rgba(21, 28, 45, 0.96);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-lg);
  gap: 4px;
}

:root[data-theme="light"] .fab-menu { background: rgba(255, 255, 255, 0.96); }

.fab-menu button {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  text-align: left;
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.fab-menu button:hover {
  background: var(--panel-3);
  border-color: var(--line);
  color: var(--text);
  transform: translateX(2px);
}

.register-fab:hover .fab-menu,
.register-fab:focus-within .fab-menu { display: grid; }

/* ══════════════════════════════════════
   AUDITORIA — código diff
══════════════════════════════════════ */
code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--purple);
  background: rgba(180, 161, 255, 0.10);
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid rgba(180, 161, 255, 0.18);
  word-break: break-all;
}

/* ══════════════════════════════════════
   MISC
══════════════════════════════════════ */
.select-wrap { display: grid; gap: 4px; color: var(--muted); font-size: 0.78rem; }

/* ══════════════════════════════════════
   FOCUS RING
══════════════════════════════════════ */
:focus-visible {
  outline: 2px solid rgba(76, 180, 151, 0.55);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid,
  .quick-entry-layout,
  .split-grid,
  .placeholder-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid, .settings-grid, .report-grid, .category-columns { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .config-tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .automation-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .workspace { width: 100%; padding: 14px 12px 110px; padding-left: 12px; }
  .topbar {
    position: relative; top: auto;
    flex-direction: column; align-items: stretch;
  }
  .top-actions { width: 100%; justify-content: flex-start; }
  .mode-switch { flex-direction: column; align-items: flex-start; }
  .sync-pill { margin-left: 0; }
  .metrics-grid,
  .form-grid,
  .card-grid,
  .settings-grid,
  .report-grid,
  .category-columns,
  .compact-metrics,
  .status-grid { grid-template-columns: 1fr; }
  .config-tile-grid { grid-template-columns: 1fr; }
  .config-tile { min-height: 96px; }
  .automation-action-grid { grid-template-columns: 1fr; }
  .metric-card strong { font-size: 1.6rem; }
  .pin-display, .amount-display { font-size: 2.2rem; }
  .register-fab { left: 12px; right: 12px; bottom: 88px; justify-items: stretch; }
  .fab-main, .fab-menu { width: 100%; border-radius: var(--radius-lg); }
  .login-panel { padding: 30px 22px 26px; }
  .surface { padding: 20px; }
  .surface-head h2 { font-size: 1.25rem; }

  /* En movil la navegacion queda en dos filas compactas bajo el estado sync */
  .bottom-nav {
    width: 100%;
    border-radius: var(--radius-lg);
    padding: 6px;
    gap: 4px;
  }
  .bottom-nav button {
    flex: 1 1 44%;
    justify-content: center;
    min-height: 44px;
    padding: 0 8px;
  }
  .bottom-nav button .nav-label {
    display: inline;
    font-size: 0.68rem;
  }
}

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

/* ── ANIMACIONES DE ENTRADA ── */
.view-stack > * {
  animation: fadeInUp 0.40s var(--ease-spring) both;
}

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

.metrics-grid .metric-card { animation: fadeInUp 0.44s var(--ease-spring) both; }
.metrics-grid .metric-card:nth-child(1) { animation-delay: 0ms; }
.metrics-grid .metric-card:nth-child(2) { animation-delay: 70ms; }
.metrics-grid .metric-card:nth-child(3) { animation-delay: 140ms; }
.metrics-grid .metric-card:nth-child(4) { animation-delay: 210ms; }
