/* ============================================================
   ADA Finance Pro — Stylesheet
   Guard-IA-N V8 · Dark Theme · Production SPA
   ============================================================ */

/* ── 0. CSS Variables ──────────────────────────────────────── */

:root {
  --bg-main: #0a0e14;
  --bg-header: #0d1117;
  --bg-panel: #131920;
  --bg-widget: #1a2130;
  --bg-card: #1e2738;
  --bg-input: #242d3d;
  --bg-hover: #2a3548;
  --border: #2d3748;
  --border-focus: #10b981;
  --text-primary: #e4e8ee;
  --text-secondary: #8b97a8;
  --text-muted: #5a6577;
  --text-bright: #fff;
  --accent-primary: #10b981;
  --accent-secondary: #3b82f6;
  --accent-tertiary: #06b6d4;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --profit: #22c55e;
  --loss: #ef4444;
  --purple-dna: #8b5cf6;
  --orange-insight: #f59e0b;
  --pink-alert: #ec4899;
  --cyan-order: #06b6d4;
  --font-ui: 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
}

/* ── 1. Reset & Base ───────────────────────────────────────── */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-panel);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ── 2. Layout ─────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 15px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  z-index: 100;
}

/* ── nav wrapper: tabs row + filters row ─────────────────── */
#fin-nav {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

#fin-tabs {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 1px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#fin-tabs::-webkit-scrollbar { display: none; }

#fin-main {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.fin-view {
  display: none;
}

.fin-view.active {
  display: block;
}

body.mobile-app {
  background: linear-gradient(180deg, #09111f 0%, #0a0e14 22%, #0a0e14 100%);
}

body.mobile-app #header {
  display: none;
}

body.mobile-app #fin-nav {
  display: none;
}

body.mobile-app #fin-main {
  padding: 10px;
  padding-bottom: 92px;
}

body.mobile-app #header,
body.mobile-app #fin-nav,
body.mobile-app #fin-tabs {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

body.mobile-app #fin-main .widget {
  overflow: hidden;
}

body.mobile-app #fin-main .widget-header {
  padding: 10px 12px;
}

body.mobile-app #fin-main .widget-body {
  padding: 12px;
}

body.mobile-app #mobile-shell {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: rgba(13, 17, 24, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.5);
}

body.mobile-app #mobile-shell[hidden] {
  display: none !important;
}

body.mobile-app .mobile-nav-primary .mobile-nav-fab {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  margin-top: -10px;
}

body.mobile-app .mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  padding: 6px 4px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
}

body.mobile-app .mobile-nav-btn.active {
  color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.12);
}

body.mobile-app .mobile-nav-icon {
  font-size: 16px;
  line-height: 1;
}

body.mobile-app .mobile-nav-primary {
  color: #fff;
}

body.mobile-app .hdr-right {
  display: none;
}

body.mobile-app .hdr-logo .title {
  font-size: 15px;
}

body.mobile-app .hdr-logo .icon {
  font-size: 18px;
}

body.mobile-app .hdr-fx {
  font-size: 11px;
}

body.mobile-app .hdr-sep:nth-of-type(n+3) {
  display: none;
}

body.mobile-app .widget,
body.mobile-app .mini-card,
body.mobile-app .chart-box {
  border-radius: 18px;
}

body.mobile-app .widget {
  margin-bottom: 10px;
}

body.mobile-app .grid-2,
body.mobile-app .grid-3,
body.mobile-app .grid-4 {
  grid-template-columns: 1fr;
}

body.mobile-app .fin-table,
body.mobile-app .acc-table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body.mobile-app .fin-table th,
body.mobile-app .fin-table td {
  white-space: nowrap;
}

body.mobile-app .toast-container {
  left: 12px;
  right: 12px;
  top: auto;
  bottom: 112px;
}

body.mobile-app .modal-content {
  border-radius: 22px;
}

body.mobile-app .modal {
  padding: 14px;
}

body.mobile-app .form-row,
body.mobile-app .grid-2,
body.mobile-app .grid-3,
body.mobile-app .grid-4 {
  display: grid;
  grid-template-columns: 1fr !important;
  gap: 10px;
}

body.mobile-app .form-group {
  margin-bottom: 0;
}

body.mobile-app input,
body.mobile-app select,
body.mobile-app textarea {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 16px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

body.mobile-app label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

body.mobile-app .btn {
  min-height: 46px;
  border-radius: 14px;
  font-size: 14px;
  padding: 10px 14px;
}

body.mobile-app .btn.btn-sm {
  min-height: 40px;
  font-size: 13px;
}

body.mobile-app #cmd-form > div:last-child {
  flex-direction: column;
}

body.mobile-app #cmd-form > div:last-child .btn,
body.mobile-app #cmd-form > div:last-child button {
  width: 100%;
}

body.mobile-app .tipo-sel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

body.mobile-app .tipo-sel::-webkit-scrollbar {
  display: none;
}

body.mobile-app .tipo-btn {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

body.mobile-app .dest-indicator {
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12px;
}

body.mobile-app .quick-tpl {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

body.mobile-app .quick-tpl::-webkit-scrollbar {
  display: none;
}

body.mobile-app .tpl {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 999px;
}

body.mobile-app .fin-table-wrap,
body.mobile-app .acc-table-wrap {
  border-radius: 14px;
  overflow: hidden;
}

body.mobile-app .fin-table,
body.mobile-app .acc-table {
  font-size: 11px;
}

body.mobile-app .fin-table th,
body.mobile-app .acc-table th,
body.mobile-app .fin-table td,
body.mobile-app .acc-table td {
  padding: 8px 10px;
}

body.mobile-app .modal-content {
  max-height: calc(100vh - 40px);
  overflow: auto;
}

body.mobile-app .fin-view.active {
  animation: mobileViewIn 180ms ease-out;
}

@keyframes mobileViewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.mobile-app .tag,
body.mobile-app .badge,
body.mobile-app .pill,
body.mobile-app .status,
body.mobile-app .chip {
  border-radius: 999px;
}

body.mobile-app .table-actions,
body.mobile-app .widget-header,
body.mobile-app .dest-indicator,
body.mobile-app .bank-card,
body.mobile-app .summary-card {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

body.mobile-app .fin-table tr,
body.mobile-app .acc-table tr {
  height: 44px;
}

body.mobile-app .fin-table td:first-child,
body.mobile-app .acc-table td:first-child {
  padding-left: 12px;
}

body.mobile-app .fin-table td:last-child,
body.mobile-app .acc-table td:last-child {
  padding-right: 12px;
}

body.mobile-app .rec-table,
body.mobile-app .acc-table,
body.mobile-app .rec-month-row,
body.mobile-app .rec-item {
  display: block;
  width: 100%;
}

body.mobile-app .rec-subtabs,
body.mobile-app .acc-subnav {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}

body.mobile-app .rec-pane,
body.mobile-app .acc-content,
body.mobile-app .rec-card,
body.mobile-app .acc-card {
  border-radius: 18px;
}

body.mobile-app .rec-period-bar,
body.mobile-app .acc-toolbar {
  flex-direction: column;
  align-items: stretch;
}

body.mobile-app .rec-btn,
body.mobile-app .acc-btn,
body.mobile-app .rec-table .btn,
body.mobile-app .acc-table .btn {
  min-height: 44px;
}

/* ── 3. Header ─────────────────────────────────────────────── */

.hdr-logo {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hdr-logo .icon {
  font-size: 20px;
}

.hdr-logo .title {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent-primary);
}

.hdr-logo .ver {
  font-size: 11px;
  color: var(--text-muted);
}

.hdr-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 4px;
}

.hdr-fx {
  font-family: var(--font-mono);
  font-size: 13px;
}

.hdr-fx .label {
  color: var(--text-muted);
  font-size: 10px;
}

.hdr-fx .val {
  color: var(--accent-tertiary);
  font-weight: bold;
}

.hdr-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── 4. Tabs & Filters ────────────────────────────────────── */

.fin-tab {
  padding: 7px 11px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all .15s;
}

.fin-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.fin-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: rgba(16, 185, 129, .08);
}

.fin-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
}

.fin-filters select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: var(--font-ui);
}

/* ── 5. Views & Widgets ────────────────────────────────────── */

.widget {
  background: var(--bg-widget);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 12px;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.widget-header .title {
  font-size: 12px;
  font-weight: bold;
  color: var(--text-bright);
}

.widget-header .badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--accent-primary);
}

.widget-body {
  padding: 10px 12px;
}

/* ── 6. Stats & Mini-Cards ─────────────────────────────────── */

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.stat-row .label {
  color: var(--text-secondary);
  font-size: 12px;
}

.stat-row .value {
  font-family: var(--font-mono);
  font-size: 13px;
}

.profit {
  color: var(--profit) !important;
}

.loss {
  color: var(--loss) !important;
}

.warn {
  color: var(--warning) !important;
}

.mini-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
}

.mc-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.mc-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: bold;
  margin-top: 2px;
}

.mc-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── 7. Grid System ────────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.grid-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 12px;
}

.grid-2 > *,
.grid-3 > *,
.grid-4 > *,
.widget {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1000px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── 8. Tables ─────────────────────────────────────────────── */

.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.fin-table th {
  text-align: left;
  padding: 6px 10px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.fin-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.fin-table tr:hover td {
  background: var(--bg-hover);
}

.num {
  font-family: var(--font-mono);
  text-align: right;
}

.income {
  color: var(--profit);
}

.expense {
  color: var(--loss);
}

.transfer {
  color: var(--cyan-order);
}

/* ── 9. Charts ─────────────────────────────────────────────── */

.chart-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  min-height: 180px;
}

.chart-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  padding-top: 10px;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 2px;
}

.bar-col .bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-width: 14px;
}

.bar-col .bar-label {
  font-size: 9px;
  color: var(--text-muted);
}

.bar-col .bar-val {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.donut-container {
  display: flex;
  align-items: center;
  gap: 20px;
}

.donut {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  position: relative;
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: var(--bg-card);
  border-radius: 50%;
  width: 75px;
  height: 75px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.donut-center .val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
}

.donut-center .lbl {
  font-size: 9px;
  color: var(--text-muted);
}

.donut-legend {
  font-size: 11px;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── 10. Progress Bars ─────────────────────────────────────── */

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}

/* ── 11. Buttons ───────────────────────────────────────────── */

.btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-ui);
}

.btn:hover {
  background: var(--bg-hover);
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-main);
  border-color: var(--accent-primary);
  font-weight: bold;
}

.btn-primary:hover {
  opacity: .9;
}

.btn-sm {
  padding: 3px 10px;
  font-size: 11px;
}

/* ── 12. Forms ─────────────────────────────────────────────── */

.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-ui);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

/* ── 13. Tags ──────────────────────────────────────────────── */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
}

.tag-income {
  background: rgba(34, 197, 94, .15);
  color: var(--profit);
}

.tag-expense {
  background: rgba(239, 68, 68, .15);
  color: var(--loss);
}

.tag-transfer {
  background: rgba(6, 182, 212, .15);
  color: var(--cyan-order);
}

.tag-refund {
  background: rgba(168, 85, 247, .15);
  color: #a855f7;
}

.tag-ok {
  background: rgba(16, 185, 129, .15);
  color: var(--accent-primary);
}

.tag-warn {
  background: rgba(245, 158, 11, .15);
  color: var(--warning);
}

.tag-over {
  background: rgba(239, 68, 68, .15);
  color: var(--danger);
}

/* ── 14. Status Dots ───────────────────────────────────────── */

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot-green {
  background: var(--success);
}

.dot-yellow {
  background: var(--warning);
}

.dot-red {
  background: var(--danger);
}

/* ── 15. AI Chat Bubbles ───────────────────────────────────── */

.ai-bubble {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.5;
  max-width: 85%;
}

.ai-bubble.assistant {
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-right: auto;
}

.ai-bubble.user {
  background: rgba(16, 185, 129, .12);
  border: 1px solid rgba(16, 185, 129, .3);
  margin-left: auto;
}

/* ── 16. Gauge ─────────────────────────────────────────────── */

.gauge {
  width: 120px;
  height: 60px;
  position: relative;
  overflow: hidden;
}

.gauge-bg {
  width: 120px;
  height: 60px;
  border-radius: 60px 60px 0 0;
  background: conic-gradient(from 0.75turn, var(--danger) 0%, var(--warning) 25%, var(--success) 50%);
  clip-path: polygon(0 100%, 0 0, 100% 0, 100% 100%, 50% 100%);
}

.gauge-val {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: bold;
}

/* ── 17. Type Selector ─────────────────────────────────────── */

.tipo-sel {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tipo-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  transition: all .15s;
}

.tipo-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.tipo-btn.active {
  background: rgba(16, 185, 129, .15);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: bold;
}

/* ── 18. Calendar ──────────────────────────────────────────── */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-hdr {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  padding: 4px;
  text-transform: uppercase;
}

.cal-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  min-height: 60px;
  font-size: 11px;
}

.cal-day .day-num {
  font-weight: bold;
  font-size: 12px;
  margin-bottom: 4px;
}

.cal-day.today {
  border-color: var(--accent-primary);
}

.cal-evt {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-evt.paid {
  background: rgba(34, 197, 94, .15);
  color: var(--profit);
}

.cal-evt.pending {
  background: rgba(245, 158, 11, .15);
  color: var(--warning);
}

.cal-evt.overdue {
  background: rgba(239, 68, 68, .15);
  color: var(--danger);
}

/* ── 19. Quick Templates ───────────────────────────────────── */

.quick-tpl {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-tpl .tpl {
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
}

.quick-tpl .tpl:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ── 20. Budget Rule Bar ───────────────────────────────────── */

.dest-indicator {
  background: rgba(16, 185, 129, .08);
  border: 1px solid rgba(16, 185, 129, .25);
  border-radius: 6px;
  padding: 8px 14px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--accent-primary);
}

.rule-bar {
  display: flex;
  gap: 2px;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
}

.rule-bar div {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: bold;
  color: var(--bg-main);
}

.legend-inline {
  display: flex;
  gap: 14px;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
}

.legend-inline span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

/* ── 22. Modal / Dialog ────────────────────────────────────── */

body.modal-open #mobile-shell {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100001;
  backdrop-filter: blur(4px);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  backdrop-filter: blur(4px);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  width: 92%;
  max-width: 520px;
  max-height: 88vh;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(0);
  transition: transform 0.2s;
  position: relative;
  z-index: 100002;
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-bright);
}

.modal-header .close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.modal-header .close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

/* ── 23. Toast Notifications ───────────────────────────────── */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  min-width: 260px;
  max-width: 380px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  animation: toast-slide-in 0.3s ease forwards;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--accent-secondary);
}

.toast.removing {
  animation: toast-slide-out 0.25s ease forwards;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-slide-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ── 24. Loading Spinner ───────────────────────────────────── */

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 24px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── 25. Empty State ───────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state .title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state .desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
}

/* ── 26. Responsive — see comprehensive section at end of file ── */

/* ── 27. App-specific Components ───────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-header h1 {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-bright);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--bg-widget);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
}
.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: bold;
  color: var(--text-bright);
}

.card {
  background: var(--bg-widget);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
}
.card h3 {
  font-size: 13px;
  font-weight: bold;
  color: var(--text-bright);
  margin-bottom: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.data-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover td {
  background: var(--bg-hover);
}

.btn-secondary {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-ui);
}
.btn-secondary:hover {
  background: var(--bg-hover);
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--font-ui);
}
.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid .full-width {
  grid-column: 1 / -1;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 10px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: 0.2s;
}
.toggle input:checked + .toggle-slider {
  background: var(--accent-primary);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.filters-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tx-list {
  max-height: 350px;
  overflow-y: auto;
}
.tx-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.tx-date {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 80px;
  font-family: var(--font-mono);
}
.tx-desc {
  flex: 1;
  font-size: 12px;
}
.tx-amount {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: bold;
  min-width: 100px;
  text-align: right;
}

.comando-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.trm-display {
  font-size: 13px;
  color: var(--text-secondary);
}
.trm-display strong {
  color: var(--accent-tertiary);
  font-family: var(--font-mono);
}

.budget-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rule-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rule-bar-label {
  min-width: 100px;
  font-size: 12px;
  color: var(--text-secondary);
}
.rule-bar-container {
  flex: 1;
  height: 20px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.rule-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.rule-bar-value {
  min-width: 100px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-align: right;
}

.year-nav {
  display: flex;
  gap: 8px;
}

.success { color: var(--success) !important; }
.error { color: var(--danger) !important; }
.profit { color: var(--profit) !important; }
.loss { color: var(--loss) !important; }
.warn { color: var(--warning) !important; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN — Full Device Support
   iPhone SE (375px) · iPhone Pro (393px) · Android (360-412px)
   iPad Mini (768px) · iPad (820px) · iPad Pro (1024px)
   Laptop (1280px+) · Desktop (1440px+)
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet landscape & small laptops (≤1200px) ───────────── */
@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .comando-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ── Tablet portrait / iPad (≤1024px) ─────────────────────── */
@media (max-width: 1024px) {
  #header {
    flex-wrap: wrap;
    min-height: auto;
    padding: 8px 12px;
  }

  .hdr-logo .ver { display: none; }

  .hdr-sep { display: none; }

  .hdr-right {
    width: 100%;
    justify-content: flex-end;
    order: -1;
    padding-bottom: 4px;
  }

  #fin-tabs {
    gap: 0;
    padding: 0 4px;
  }

  .fin-tab {
    padding: 6px 8px;
    font-size: 10px;
  }

  .grid-3, .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Small tablet / large phone landscape (≤768px) ────────── */
@media (max-width: 768px) {
  html, body {
    font-size: 14px;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  #app {
    height: auto;
    min-height: 100vh;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }

  #fin-main, .fin-view {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }

  /* Ocultar barra superior y pestañas de escritorio en pantallas móviles para eliminar desbordamiento horizontal */
  #header,
  #fin-nav,
  #fin-tabs {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  #mobile-shell,
  #mobile-dock {
    display: grid !important;
  }

  #fin-main {
    padding: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .kpi-card { padding: 10px 12px; }
  .kpi-value { font-size: 16px; }

  .widget { margin-bottom: 8px; }
  .widget-body { padding: 8px 10px; }
  .widget-header { padding: 6px 10px; }

  .tipo-sel {
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  .tipo-btn {
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 11px;
  }

  .form-row { flex-direction: column; gap: 6px; }

  /* Tables: horizontal scroll wrapper */
  .fin-table, .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .chart-box { padding: 10px; min-height: 140px; }
  .donut-container { flex-direction: column; align-items: center; }
  .donut { width: 100px; height: 100px; }
  .donut-center { width: 60px; height: 60px; }
  .donut-center .val { font-size: 12px; }
  .bar-chart { height: 110px; }

  .cal-day { min-height: 44px; padding: 3px 4px; font-size: 10px; }
  .cal-evt { font-size: 8px; padding: 1px 3px; }

  .modal-content {
    width: 96%;
    max-width: none;
    max-height: 92vh;
    border-radius: 10px;
  }

  .toast { min-width: 200px; max-width: 90vw; font-size: 12px; }
  .toast-container { top: 8px; right: 8px; left: 8px; }

  .quick-tpl { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .quick-tpl .tpl { flex-shrink: 0; }

  .legend-inline { flex-wrap: wrap; gap: 8px; }

  .ai-bubble { max-width: 95%; }

  .filters-row { flex-direction: column; gap: 6px; }
}

/* ── Phone portrait (≤480px) — iPhone, Android ────────────── */
@media (max-width: 480px) {
  html, body { font-size: 14px; }

  #header {
    padding: 6px 8px;
    gap: 4px;
  }

  .hdr-logo { gap: 4px; }
  .hdr-logo .icon { font-size: 16px; }
  .hdr-logo .title { font-size: 13px; }
  .hdr-logo .ver { display: none; }

  .hdr-fx { font-size: 10px; }
  .hdr-fx .label { font-size: 8px; }

  .hdr-right {
    font-size: 9px;
    gap: 4px;
  }

  #fin-tabs {
    gap: 0;
    padding: 0 2px;
  }

  .fin-tab {
    padding: 8px 7px;
    font-size: 10px;
    min-height: 36px;
  }

  .fin-filters {
    padding: 5px 8px;
  }

  .fin-filters select {
    font-size: 12px;
    height: 30px;
  }

  #fin-main { padding: 6px; }

  .kpi-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
  }

  .kpi-card { padding: 8px 10px; }
  .kpi-label { font-size: 9px; }
  .kpi-value { font-size: 14px; }

  .widget {
    border-radius: 4px;
    margin-bottom: 6px;
  }

  .widget-header {
    padding: 6px 8px;
  }
  .widget-header .title { font-size: 11px; }
  .widget-header .badge { font-size: 9px; padding: 1px 6px; }

  .widget-body { padding: 6px 8px; }

  .tipo-sel {
    gap: 3px;
  }
  .tipo-btn {
    padding: 5px 8px;
    font-size: 10px;
    border-radius: 12px;
  }

  .form-group label { font-size: 9px; }
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 8px 10px;
  }

  .btn {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 44px; /* Apple touch target minimum */
  }

  .btn-primary {
    width: 100%;
    text-align: center;
  }

  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
    min-height: 36px;
  }

  .stat-row { padding: 4px 0; }
  .stat-row .label { font-size: 11px; }
  .stat-row .value { font-size: 12px; }

  .mini-card { padding: 8px 10px; }
  .mc-value { font-size: 15px; }

  /* Calendar: 3-column on very small screens */
  .cal-grid { gap: 1px; }
  .cal-day { min-height: 36px; padding: 2px 3px; font-size: 9px; }
  .cal-day .day-num { font-size: 10px; }
  .cal-evt { font-size: 7px; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .page-header h1 { font-size: 15px; }

  .modal-content {
    width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
    margin-bottom: 0;
  }
  .modal-header { padding: 12px 14px; font-size: 14px; }
  .modal-body { padding: 12px 14px; -webkit-overflow-scrolling: touch; }
  .modal-footer {
    padding: 12px 14px max(16px, env(safe-area-inset-bottom, 16px));
    position: sticky;
    bottom: 0;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    z-index: 10;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
  }

  .empty-state { padding: 32px 16px; }
  .empty-state .icon { font-size: 32px; }
  .empty-state .title { font-size: 14px; }
  .empty-state .desc { font-size: 12px; }

  .tx-item { padding: 6px 0; gap: 6px; }
  .tx-date { min-width: 55px; font-size: 10px; }
  .tx-desc { font-size: 11px; }
  .tx-amount { min-width: 70px; font-size: 11px; }

  .dest-indicator { padding: 6px 10px; font-size: 11px; }

  .rule-bar { height: 20px; }
  .rule-bar div { font-size: 8px; }
  .rule-bar-label { min-width: 70px; font-size: 11px; }
  .rule-bar-value { min-width: 60px; font-size: 10px; }
}

/* ── Very small phones / iPhone SE (≤375px) ───────────────── */
@media (max-width: 375px) {
  .hdr-logo .title { font-size: 12px; }
  .hdr-fx { display: none; }

  .fin-tab { padding: 7px 5px; font-size: 9px; }

  .kpi-row { grid-template-columns: 1fr; gap: 4px; }
  .kpi-card { padding: 6px 8px; }
  .kpi-value { font-size: 13px; }

  .tipo-btn { padding: 4px 6px; font-size: 9px; }
}

/* ── Voice panel responsive ───────────────────────────────── */
@media (max-width: 768px) {
  #voice-panel {
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 60vh !important;
  }

body.mobile-app #voice-fab {
  display: none !important;
}
}

/* ── Touch-friendly enhancements for all mobile ────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  .fin-tab { min-height: 44px; display: flex; align-items: center; }
  .tipo-btn { min-height: 36px; display: flex; align-items: center; }
  .btn { min-height: 44px; }
  .quick-tpl .tpl { min-height: 32px; display: flex; align-items: center; padding: 6px 12px; }
  .tag { padding: 4px 10px; }

  /* Remove hover effects on touch devices */
  .fin-tab:hover { background: transparent; }
  .fin-table tr:hover td { background: transparent; }
  .data-table tr:hover td { background: transparent; }

  /* Better tap feedback */
  .fin-tab:active,
  .tipo-btn:active,
  .btn:active,
  .quick-tpl .tpl:active {
    opacity: 0.7;
    transform: scale(0.97);
  }

  /* Scroll momentum */
  #fin-tabs, #fin-main, .tx-list, .fin-table, .data-table {
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Mobile app shell override ─────────────────────────────── */
body.mobile-app #header,
body.mobile-app #fin-nav,
body.mobile-app #fin-tabs {
  display: none !important;
}

body.mobile-app #app {
  height: auto;
  min-height: 100vh;
  overflow: visible;
}

body.mobile-app #fin-main {
  padding-top: 12px !important;
}

/* ── iOS Safari safe area (notch) support ─────────────────── */
@supports (padding: env(safe-area-inset-top)) {
  #header {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  #fin-main {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .modal-content {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .toast-container {
    top: max(8px, env(safe-area-inset-top));
  }
}

/* ── Landscape phone orientation ──────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  #header { min-height: 36px; padding: 4px 10px; }
  .hdr-logo .icon { font-size: 14px; }
  .hdr-logo .title { font-size: 12px; }
  .fin-tab { padding: 4px 8px; font-size: 10px; min-height: 32px; }
  #fin-main { padding: 6px; }
  .widget { margin-bottom: 6px; }
  .kpi-row { grid-template-columns: repeat(4, 1fr); gap: 6px; }
}

/* ── Tooltips Fix ─────────────────────────────────────────── */
/* Permitir que tooltips sean visibles sin cortarse */
.grid-2, .grid-3, .grid-4 {
  overflow: visible !important;
}

.mini-card {
  overflow: visible !important;
  position: relative;
}

/* Tooltips personalizados con data-tooltip */
.mini-card[data-tooltip] {
  cursor: help;
}

.mini-card[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: -45px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.95);
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 300px;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: tooltipFadeIn 0.2s ease-out;
}

.mini-card[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  pointer-events: none;
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-5px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Widgets que necesitan overflow visible */
.widget.allow-overflow,
.widget.allow-overflow .widget-body {
  overflow: visible !important;
}

/* ── Print-friendly ───────────────────────────────────────── */
@media print {
  #header, #fin-tabs, .btn, .tipo-sel, #voice-panel, .toast-container { display: none !important; }
  #fin-main { padding: 0; overflow: visible; }
  .widget { break-inside: avoid; border: 1px solid #ccc; }
  body { background: white; color: black; }
  .fin-view { display: block !important; }
  
  /* Hide tooltips on print */
  .mini-card[data-tooltip]:hover::after,
  .mini-card[data-tooltip]:hover::before { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   MODERN HORIZONTAL TAB BAR
   ═══════════════════════════════════════════════════════════ */

/* Tab bar container — always visible, horizontal scroll */
/* nav wrapper: tabs + filters in one bar */
#fin-nav {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

#fin-tabs {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  height: 44px;
  min-height: 44px;
  position: relative;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#fin-tabs::-webkit-scrollbar { display: none; }

/* Gradient fade on right edge to hint more tabs */
#fin-tabs::after {
  content: '';
  position: sticky;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  min-width: 40px;
  background: linear-gradient(to right, transparent, var(--bg-panel));
  pointer-events: none;
  flex-shrink: 0;
}

/* Individual tab — pill style */
.fin-tab {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  user-select: none;
  flex-shrink: 0;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
  height: 30px;
}
.fin-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}
.fin-tab.active {
  background: var(--accent-primary);
  color: #000;
  font-weight: 700;
  border-color: transparent;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

/* Period filter selects — compact, always visible right of tabs (desktop) / below tabs (mobile) */
.fin-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
}
.fin-filters select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  height: 28px;
  font-family: var(--font-ui);
}
.fin-filters select:hover {
  border-color: var(--accent-primary);
}

/* Overlay (kept for potential future use, hidden by default) */
#sidebar-overlay { display: none; }

/* ── Tab scroll arrow buttons ─────────────────────────────── */
.tabs-scroll-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 10px;
  flex-shrink: 0;
  height: 44px;
  min-height: 44px;
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  z-index: 2;
}
.tabs-scroll-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tabs-scroll-btn.visible {
  display: flex;
}
#tabs-scroll-left {
  border-right: 1px solid var(--border);
}
#tabs-scroll-right {
  border-left: 1px solid var(--border);
}


/* ── Friendly KPI Cards & Hero Panel ──────────────────────── */
.hero-financial-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.hero-card {
  background: linear-gradient(135deg, #131d2a 0%, #1a2738 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hero-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.hero-card.hero-card-assets {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(13, 148, 136, 0.10) 100%);
  border-color: rgba(16, 185, 129, 0.35);
}
.hero-card.hero-card-income {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.14) 0%, rgba(37, 99, 235, 0.10) 100%);
  border-color: rgba(59, 130, 246, 0.35);
}
.hero-card.hero-card-expenses {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14) 0%, rgba(220, 38, 38, 0.10) 100%);
  border-color: rgba(239, 68, 68, 0.35);
}
.hero-card.hero-card-net {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14) 0%, rgba(124, 58, 237, 0.10) 100%);
  border-color: rgba(139, 92, 246, 0.35);
}
.hero-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.hero-card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.hero-card-icon {
  font-size: 18px;
}
.hero-card-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-bright);
  line-height: 1.2;
}
.hero-card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Quick Action Chips */
.quick-action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.quick-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--text-bright);
  transform: translateY(-1px);
}
.quick-chip.primary {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}
.quick-chip.primary:hover {
  background: #10b981;
  color: #fff;
}

/* ── Mobile Layout Polish for Hero Panel & Quick Chips ──────── */
@media (max-width: 600px) {
  .hero-financial-panel {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
  }
  .hero-card {
    padding: 10px 12px !important;
    border-radius: 14px !important;
  }
  .hero-card-title {
    font-size: 9px !important;
    letter-spacing: 0.4px !important;
  }
  .hero-card-icon {
    font-size: 15px !important;
  }
  .hero-card-value {
    font-size: 16px !important;
    font-weight: 800 !important;
  }
  .hero-card-subtitle {
    font-size: 9px !important;
    margin-top: 2px !important;
  }
  .quick-action-bar {
    gap: 6px !important;
    margin-bottom: 12px !important;
  }
  .quick-chip {
    padding: 6px 10px !important;
    font-size: 11px !important;
    border-radius: 18px !important;
  }
}

/* ── Ensure zero horizontal overflow on mobile ── */
body.mobile-app .widget,
body.mobile-app .widget-body,
body.mobile-app pre,
body.mobile-app code,
body.mobile-app textarea {
  max-width: 100% !important;
  word-break: break-all !important;
  overflow-wrap: anywhere !important;
  box-sizing: border-box !important;
}


/* ── MODO PRIVACIDAD ( / Privacy Mode) ── */
body.privacy-mode-active .hero-card-value,
body.privacy-mode-active .mc-value,
body.privacy-mode-active .font-mono,
body.privacy-mode-active .num,
body.privacy-mode-active .stat-row .value,
body.privacy-mode-active .privacy-blur {
  filter: blur(8px) !important;
  user-select: none !important;
  transition: filter 0.15s ease !important;
}
body.privacy-mode-active .hero-card-value:hover,
body.privacy-mode-active .mc-value:hover,
body.privacy-mode-active .font-mono:hover,
body.privacy-mode-active .num:hover,
body.privacy-mode-active .stat-row .value:hover {
  filter: blur(0px) !important;
}


/* ── MOBILE MENU DRAWER / BOTTOM SHEET ────────────────────── */
.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.mobile-drawer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.mobile-drawer-content {
  position: relative;
  background: var(--bg-card, #131920);
  border-top: 1px solid var(--border, #2d3748);
  border-radius: 24px 24px 0 0;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.6);
  animation: slideUpDrawer 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom, 20px);
}
@keyframes slideUpDrawer {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border, #2d3748);
}
.mobile-drawer-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px 24px;
}
.mobile-drawer-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #8b97a8);
  margin: 14px 0 8px;
}
.mobile-drawer-section-title:first-child {
  margin-top: 2px;
}
.mobile-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, #2d3748);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-primary, #e4e8ee);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mobile-menu-item:active {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(0.98);
}
.mmi-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.mmi-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ── KAIZEN ONBOARDING & PASTEL CATEGORIES (ESTILO LUKAS) ── */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 15, 23, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  animation: fadeInOnb 0.2s ease-out;
}
@keyframes fadeInOnb {
  from { opacity: 0; }
  to { opacity: 1; }
}
.onboarding-dialog {
  background: var(--bg-card, #131920);
  border: 1px solid var(--border, #2d3748);
  border-radius: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.onboarding-close-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
}
.onboarding-close-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.onboarding-step {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 22px 20px 20px;
  -webkit-overflow-scrolling: touch;
}
/* Selector de Idiomas 4 Pills */
.onboarding-lang-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}
.lang-pill {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted, #94a3b8);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.15s ease;
}
.lang-pill.active {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
}
.onboarding-header-text {
  text-align: center;
  margin-bottom: 16px;
}
.onboarding-header-text h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary, #e2e8f0);
  margin: 0 0 4px;
}
.onboarding-header-text p {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  margin: 0;
  line-height: 1.4;
}
/* Grilla de Categorías Pastel */
.onboarding-category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-bottom: 16px;
}
@media (max-width: 360px) {
  .onboarding-category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.pastel-cat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 6px 12px;
  border-radius: 18px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.pastel-cat-card:active {
  transform: scale(0.96);
}
.pastel-cat-card.selected {
  border-color: #10b981;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.2);
}
.pastel-cat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 8px;
}
.pastel-cat-name {
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pastel-cat-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.15);
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  transition: all 0.15s ease;
}
.pastel-cat-card.selected .pastel-cat-badge {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
  font-weight: 800;
}

/* Paleta de colores pastel idéntica a Lukas */
.p-mint   { background: #e6f9f0; color: #047857; }
.p-mint .pastel-cat-icon { background: #d1fae5; }

.p-orange { background: #fff5ed; color: #c2410c; }
.p-orange .pastel-cat-icon { background: #ffedd5; }

.p-purple { background: #f3f0ff; color: #6d28d9; }
.p-purple .pastel-cat-icon { background: #ede9fe; }

.p-blue   { background: #eef6ff; color: #1d4ed8; }
.p-blue .pastel-cat-icon { background: #dbeafe; }

.p-lavender { background: #f5f3ff; color: #7c3aed; }
.p-lavender .pastel-cat-icon { background: #ede9fe; }

.p-rose   { background: #fff1f2; color: #be123c; }
.p-rose .pastel-cat-icon { background: #ffe4e6; }

.p-violet { background: #faf5ff; color: #7e22ce; }
.p-violet .pastel-cat-icon { background: #f3e8ff; }

.p-magenta { background: #fdf2f8; color: #be185d; }
.p-magenta .pastel-cat-icon { background: #fce7f3; }

.p-cyan   { background: #ecfeff; color: #0e7490; }
.p-cyan .pastel-cat-icon { background: #cffafe; }

.p-amber  { background: #fffbeb; color: #b45309; }
.p-amber .pastel-cat-icon { background: #fef3c7; }

.p-yellow { background: #fefce8; color: #a16207; }
.p-yellow .pastel-cat-icon { background: #fef9c3; }

.p-brown  { background: #f7f4f0; color: #78350f; }
.p-brown .pastel-cat-icon { background: #f2ede7; }

/* Botones de acción Onboarding */
.onboarding-footer-bar {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border, #2d3748);
}
.onboarding-primary-btn {
  width: 100%;
  padding: 14px 20px;
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}
.onboarding-primary-btn:active {
  transform: scale(0.98);
  background: #059669;
}

/* Paso 2: Saldo Inicial */
.onboarding-initial-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 10px;
}
.onb-bank-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  font-size: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.onb-balance-input-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, #2d3748);
  border-radius: 18px;
  padding: 16px 20px;
  margin: 18px 0 10px;
  text-align: left;
}
.onb-balance-input-card label {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  display: block;
  margin-bottom: 6px;
}
.onb-currency-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.onb-currency-symbol {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary, #e2e8f0);
}
#onb-initial-balance-input {
  background: transparent;
  border: none;
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary, #e2e8f0);
  outline: none;
  width: 100%;
}
.onb-helper-text {
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
  line-height: 1.4;
  margin-bottom: 22px;
}
.onb-secondary-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
  cursor: pointer;
  padding: 8px;
}
.onb-secondary-btn:hover {
  color: #fff;
}

/* ── KAIZEN GUIDED TOUR (POPOVER TOOLTIPS) ── */
.tour-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100001;
  pointer-events: auto;
}
.tour-tooltip {
  position: fixed;
  background: #ffffff;
  color: #0f172a;
  border-radius: 20px;
  padding: 20px 22px;
  width: calc(100% - 40px);
  max-width: 380px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.4);
  z-index: 100002;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.tour-dots-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.tour-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: #cbd5e1;
  transition: all 0.2s ease;
}
.tour-dot.active {
  width: 22px;
  background: #10b981;
}
.tour-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px;
}
.tour-desc {
  font-size: 13px;
  color: #475569;
  line-height: 1.45;
  margin: 0 0 16px;
}
.tour-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tour-btn-skip {
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  padding: 6px 10px;
}
.tour-btn-next {
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3);
}
