*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── DARK THEME (default) ── */
:root,
[data-theme="dark"] {
  --bg: #0e0f11;
  --surface: #16181c;
  --surface2: #1e2128;
  --border: rgba(255, 255, 255, 0.07);
  --border2: rgba(255, 255, 255, 0.13);
  --text: #f0f0ee;
  --muted: #7a7d85;
  --faint: #3a3d45;
  --teal: #3ecf8e;
  --purple: #8b7cf6;
  --coral: #f06a50;
  --amber: #f5a623;
  --red: #e05252;
  --green: #3ecf8e;
  --inversionista: #8b7cf6;
  --trader: #3ecf8e;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --radius: 10px;
  --radius-lg: 14px;

  /* Clerk Theme Setup & Specificity Fix */
  --clerk-color-primary: var(--purple) !important;
  --clerk-color-background: var(--surface) !important;
  --clerk-color-surface: var(--surface2) !important;
  --clerk-color-input: var(--surface2) !important;
  --clerk-color-foreground: var(--text) !important;
  --clerk-color-text: var(--text) !important;
  --clerk-color-neutral: var(--muted) !important;
  --clerk-color-primary-foreground: #ffffff !important;
  --clerk-color-muted-foreground: var(--muted) !important;
  --clerk-color-text-secondary: var(--muted) !important;
  --clerk-color-danger: var(--coral) !important;
  --clerk-color-success: var(--teal) !important;
  --clerk-color-input-foreground: var(--text) !important;
  --clerk-font-family: 'DM Sans', sans-serif !important;
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #eef0f3;
  --border: rgba(0, 0, 0, 0.08);
  --border2: rgba(0, 0, 0, 0.15);
  --text: #1a1b1e;
  --muted: #6b7280;
  --faint: #d1d5db;
  --teal: #059669;
  --purple: #7c3aed;
  --coral: #dc2626;
  --amber: #d97706;
  --red: #dc2626;
  --green: #059669;
  --inversionista: #7c3aed;
  --trader: #059669;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

  /* Clerk Theme Setup & Specificity Fix */
  --clerk-color-primary: var(--purple) !important;
  --clerk-color-background: var(--surface) !important;
  --clerk-color-surface: var(--surface2) !important;
  --clerk-color-input: var(--surface2) !important;
  --clerk-color-foreground: var(--text) !important;
  --clerk-color-text: var(--text) !important;
  --clerk-color-neutral: var(--muted) !important;
  --clerk-color-primary-foreground: #ffffff !important;
  --clerk-color-muted-foreground: var(--muted) !important;
  --clerk-color-text-secondary: var(--muted) !important;
  --clerk-color-danger: var(--coral) !important;
  --clerk-color-success: var(--teal) !important;
  --clerk-color-input-foreground: var(--text) !important;
}

[data-theme="light"] #btn-theme {
  opacity: 0.8;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ── LOGIN SCREEN ── */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
}

.login-screen::before,
.login-screen::after {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.35;
  animation: float 10s ease-in-out infinite alternate;
}

.login-screen::before {
  background: radial-gradient(circle, var(--inversionista) 0%, transparent 70%);
  top: -200px;
  left: -200px;
}

.login-screen::after {
  background: radial-gradient(circle, var(--purple) 0%, transparent 70%);
  bottom: -200px;
  right: -200px;
  animation-delay: -5s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(60px, 60px) scale(1.1);
  }
}

.login-card {
  background: rgba(30, 33, 40, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 48px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  max-width: 360px;
  width: calc(100% - 40px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-logo-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--inversionista), var(--purple));
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  box-shadow: 0 8px 24px rgba(76, 175, 80, 0.25);
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.login-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 6px;
}

.login-btn {
  background: #f4f5f7;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 12px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #1a1b1e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  transition: transform 0.1s, background 0.1s;
}

.login-btn:hover {
  background: #ffffff;
  transform: translateY(-1px);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn svg {
  width: 18px;
  height: 18px;
}

[data-theme="dark"] .login-btn {
  background: #1e2128;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f0f0ee;
}

[data-theme="dark"] .login-btn:hover {
  background: #2a2d35;
}


/* ── HEADER ── */
header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}

.logo-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: center;
}

.sim-selector {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sim-name-btn {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color .15s;
}

.sim-name-btn:hover {
  border-color: var(--purple);
}

.sim-name-btn .arrow {
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
}

.sim-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  min-width: 220px;
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
  display: none;
}

.sim-dropdown.open {
  display: block;
}

.sim-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  gap: 8px;
  transition: background .1s;
}

.sim-dropdown-item:hover {
  background: var(--surface2);
}

.sim-dropdown-item.active {
  color: var(--purple);
  font-weight: 500;
}

.sim-dropdown-item .sim-item-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-dropdown-item .sim-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sim-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .1s, background .1s;
  line-height: 1;
}

.sim-item-btn:hover {
  color: var(--text);
  background: var(--border2);
}

.sim-item-btn.del:hover {
  color: var(--coral);
}

.sim-dropdown-footer {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
}

.sim-new-btn {
  width: 100%;
  background: none;
  border: 1px dashed var(--border2);
  border-radius: 6px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  padding: 7px;
  cursor: pointer;
  transition: all .15s;
}

.sim-new-btn:hover {
  border-color: var(--purple);
  color: var(--purple);
  background: rgba(139, 124, 246, 0.06);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.save-status {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  min-width: 60px;
  text-align: right;
}

.save-status.saving {
  color: var(--amber);
}

.save-status.saved {
  color: var(--green);
}

.icon-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: color .15s, border-color .15s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border2);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border: 1px solid var(--border2);
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── LAYOUT ── */
.app-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--surface);
  height: 100%;
}

/* ── ACCORDION ── */
.accordion-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.accordion {
  display: flex;
  flex-direction: column;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  transition: color 0.15s, background 0.15s;
  gap: 8px;
}

.accordion-header:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
}

[data-theme="light"] .accordion-header:hover {
  background: rgba(0, 0, 0, 0.03);
}

.accordion.open .accordion-header {
  color: var(--text);
}

.accordion-icon {
  flex-shrink: 0;
  transition: transform 0.22s cubic-bezier(.4, 0, .2, 1);
  color: var(--faint);
}

.accordion.open .accordion-icon {
  transform: rotate(180deg);
  color: var(--purple);
}

.accordion-body {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.28s cubic-bezier(.4, 0, .2, 1),
    opacity 0.20s ease;
  padding: 0 20px;
}

.accordion.open .accordion-body {
  max-height: 1200px;
  opacity: 1;
  padding: 0 20px 16px;
}

.section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── CONFIG GRID ── */
.cfg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cfg-label {
  font-size: 10px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.cfg-input {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  padding: 6px 8px;
  width: 100%;
  transition: border-color .15s;
}

.cfg-input:focus {
  outline: none;
  border-color: var(--purple);
}

.cfg-select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  padding: 6px 8px;
  width: 100%;
  cursor: pointer;
  transition: border-color .15s;
}

.cfg-select:focus {
  outline: none;
  border-color: var(--purple);
}

/* ── TRAMOS ── */
.tramo-row {
  display: grid;
  grid-template-columns: 1fr 1fr 28px;
  gap: 6px;
  align-items: center;
  margin-bottom: 7px;
}

.inp-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inp-label {
  font-size: 10px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.inp-field {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  padding: 6px 8px;
  width: 100%;
  transition: border-color .15s;
}

.inp-field:focus {
  outline: none;
  border-color: var(--purple);
}

.inp-suffix {
  font-size: 10px;
  color: var(--muted);
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.inp-wrap {
  position: relative;
}

.del-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--muted);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, color .15s;
  align-self: end;
}

.del-btn:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.add-btn {
  width: 100%;
  background: none;
  border: 1px dashed var(--border2);
  border-radius: 6px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  padding: 7px;
  cursor: pointer;
  transition: all .15s;
}

.add-btn:hover {
  border-color: var(--purple);
  color: var(--purple);
  background: rgba(139, 124, 246, 0.06);
}

.days-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
}

.days-pill {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.pill-ok {
  background: rgba(62, 207, 142, 0.15);
  color: var(--teal);
}

.pill-warn {
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
}

.pill-err {
  background: rgba(224, 82, 82, 0.15);
  color: var(--red);
}

.monthly-ret {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  font-family: 'DM Mono', monospace;
}

.monthly-ret span {
  color: var(--amber);
  font-weight: 500;
}

/* ── RETIROS ── */
.retiro-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.retiro-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.retiro-label {
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.ret-inp-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ret-prefix {
  font-size: 12px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.ret-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  padding: 7px 9px;
  transition: border-color .15s;
}

.ret-input:focus {
  outline: none;
  border-color: var(--purple);
}

.ret-warn {
  font-size: 10px;
  color: var(--coral);
  min-height: 13px;
  font-family: 'DM Mono', monospace;
}

.mode-toggle {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
}

.mode-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--border2);
  border-radius: 5px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  padding: 4px 0;
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
}

.mode-btn.active {
  background: var(--surface2);
  color: var(--text);
  font-weight: 500;
}

.mode-btn:hover:not(.active) {
  color: var(--text);
}

.expand-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color .15s, color .15s;
  margin-top: 4px;
}

.expand-btn:hover {
  border-color: var(--border2);
  color: var(--text);
}

.expand-btn .arrow {
  font-size: 9px;
  transition: transform .2s;
}

.expand-btn.open .arrow {
  transform: rotate(180deg);
}

.per-mes-wrap {
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}

.per-mes-wrap.open {
  max-height: 600px;
}

.pm-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.pm-table th {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 4px 4px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.pm-table td {
  padding: 3px 2px;
  vertical-align: middle;
}

.pm-mes {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  padding-right: 4px;
}

.pm-mode-toggle {
  display: flex;
  gap: 2px;
}

.pm-mode-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  padding: 2px 5px;
  cursor: pointer;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  transition: all .12s;
  white-space: nowrap;
}

.pm-mode-btn.active {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
}

.pm-inp {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 3px 5px;
  transition: border-color .12s;
}

.pm-inp:focus {
  outline: none;
  border-color: var(--purple);
}

.pm-inp:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pm-reset {
  background: none;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 13px;
  padding: 0 3px;
  line-height: 1;
  transition: color .12s;
}

.pm-reset:hover {
  color: var(--coral);
}

/* ── LEGEND ── */
.legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.leg-line {
  width: 22px;
  height: 2px;
  border-radius: 2px;
  flex-shrink: 0;
}

.leg-label {
  color: var(--muted);
}

.leg-pct {
  margin-left: auto;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--faint);
}

/* ── CONTENT ── */
.content {
  padding: 24px 28px;
  display: flex;
  flex-direction: row;
  gap: 20px;
  background: var(--bg);
  height: 100%;
}

.content-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  padding-right: 14px;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--purple);
  font-weight: 500;
}

/* ── METRICS GRID ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.m-label {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.m-value {
  font-size: 19px;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
  letter-spacing: -0.5px;
}

.m-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  font-family: 'DM Mono', monospace;
}

/* ── CHART ── */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 20px 12px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

/* ── TABLE ── */
.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px;
}

.month-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  font-size: 12px;
}

.mc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.mc-mes {
  font-weight: 600;
  font-size: 14px;
}

.mc-capital {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

.mc-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.mc-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mc-lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mc-val {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
}

.mc-section {
  border-left: 2px solid;
  padding-left: 9px;
  margin-bottom: 8px;
}

.mc-section:last-child {
  margin-bottom: 0;
}

.mc-sec-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  opacity: 0.85;
}

.mc-grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.mc-neg {
  color: var(--red) !important;
}

/* ── SCENARIO SELECTOR ── */
.tsel-row {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tsel-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
}

.tsel-btn.active {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border2);
  font-weight: 500;
}

.tsel-btn:hover {
  color: var(--text);
}

/* ── RESUMEN PANEL ── */
.resumen-panel {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 12px;
  height: 100%;
}

.rsm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  gap: 6px;
}

.rsm-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.rsm-scenario {
  font-size: 10px;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
}

.rsm-block {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rsm-block:last-child {
  border-bottom: none;
}

.rsm-block-title {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.rsm-hint {
  font-size: 9px;
  color: var(--faint);
  font-family: 'DM Mono', monospace;
  margin-top: -3px;
}

.rsm-fondo {
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-top: 2px;
}

.rsm-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.rsm-line-label {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rsm-line-val {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}

/* Split % inputs */
.rsm-split-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.rsm-split-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rsm-split-label {
  font-size: 9px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rsm-split-inp {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 5px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  padding: 5px 7px;
  width: 100%;
  transition: border-color .15s;
}

.rsm-split-inp:focus {
  outline: none;
  border-color: var(--purple);
}

.rsm-split-readonly {
  opacity: 0.5;
  cursor: not-allowed;
  border-style: dashed;
}

.rsm-split-divider {
  font-size: 14px;
  color: var(--faint);
  padding-top: 14px;
  flex-shrink: 0;
}

/* Party blocks */
.rsm-party-block {
  border-left: 3px solid var(--party-color);
  margin-left: 0;
  padding-left: 11px;
}

.rsm-party-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.rsm-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.rsm-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 5px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  font-family: 'DM Mono', monospace;
}

/* Grand total */
.rsm-grand-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 11px 14px;
  background: linear-gradient(135deg, rgba(139, 124, 246, 0.07), rgba(62, 207, 142, 0.07));
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.rsm-grand-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.rsm-grand-val {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

/* ── INLINE RENAME INPUT ── */
.rename-input {
  background: var(--surface2);
  border: 1px solid var(--purple);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 8px;
  max-width: 180px;
  outline: none;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--faint);
  border-radius: 3px;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .app-body {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: auto;
    max-height: 60vh;
  }

  .content {
    height: auto;
    overflow: visible;
    padding: 16px;
    flex-direction: column;
  }

  .content-main {
    padding-right: 0;
    overflow-y: visible;
    height: auto;
  }

  .resumen-panel {
    width: 100%;
    height: auto;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  header {
    padding: 12px 16px;
  }

  .logo-title {
    display: none;
  }

  .header-center {
    justify-content: flex-start;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .month-grid {
    grid-template-columns: 1fr;
  }
}