:root {
  --bg-start: #0B0B1A;
  --bg-mid: #111125;
  --bg-end: #1a1f4a;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.15);
  --text: #e2e2f0;
  --text-dim: #9898b0;
  --primary: #6C3CE1;
  --primary-light: #A78BFA;
  --accent: #FACC15;
  --ok: #43d39e;
  --warn: #ffb957;
  --bad: #ff6d89;
  --shadow: 0 20px 40px rgba(6, 10, 30, 0.35);
  --sidebar-w: 260px;
  --topbar-h: 64px;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Outfit", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #23256f 0%, transparent 36%),
    radial-gradient(circle at 85% 0%, #452f81 0%, transparent 24%),
    linear-gradient(160deg, var(--bg-start) 0%, var(--bg-mid) 45%, var(--bg-end) 100%);
}

body.auth-locked {
  overflow: hidden;
}

body.menu-open {
  overflow: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Outfit", sans-serif;
  letter-spacing: 0.01em;
}

h1 {
  font-family: "Space Mono", monospace;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  min-height: 0;
  padding: 16px 20px;
  overflow: hidden;
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.top-header {
  margin: 14px 20px 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 8px;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-subtitle {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-action {
  padding: 8px 10px;
  font-size: 0.76rem;
}

.profile-shortcut {
  padding: 8px 12px;
}

.sync-pill {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
}

.app-footer {
  margin: 0 20px 14px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.app-footer a {
  color: #c8cdff;
  text-decoration: none;
}

.menu-backdrop {
  display: none;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  font-size: 1rem;
}

.brand p {
  margin: 4px 0 0;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.brand-badge {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-weight: 700;
  font-family: "Space Mono", monospace;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.brand h1 {
  font-family: "Space Mono", monospace;
  font-size: 1.1rem;
}

.brand h1 span {
  color: var(--accent);
}

.user-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.9rem;
}

.user-chip-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-chip-name {
  color: var(--text);
  font-weight: 500;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip-role {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.ghost {
  padding: 8px 10px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.menu-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0;
}

#menuToggle {
  display: none;
}

.topbar-user {
  font-size: 0.82rem;
  color: var(--text-dim);
  min-width: 72px;
  text-align: right;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 96px 1fr;
}

body.sidebar-collapsed .brand h1,
body.sidebar-collapsed .brand p,
body.sidebar-collapsed .user-chip span,
body.sidebar-collapsed .install-help,
body.sidebar-collapsed .menu-item {
  font-size: 0;
}

body.sidebar-collapsed .menu-item {
  padding: 11px;
  text-align: center;
}

body.sidebar-collapsed .menu-item::first-letter {
  font-size: 1rem;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-item,
button,
input,
select {
  font-family: inherit;
}

.menu-item {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.25s ease;
}

/* --- Menu group separators --- */
.menu-group-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding: 12px 14px 4px;
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
}

.menu-group-label:first-child {
  padding-top: 4px;
}

.menu-item:hover {
  transform: translateX(3px);
  border-color: rgba(255, 255, 255, 0.2);
}

.menu-item.active {
  background: linear-gradient(130deg, rgba(110, 123, 255, 0.4), rgba(159, 124, 255, 0.35));
  border-color: rgba(255, 255, 255, 0.35);
}

.install-btn {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
}

.install-help {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.35;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 174px);
  overflow-y: auto;
  padding-right: 4px;
}

.view {
  display: none;
  animation: fadeUp 0.5s ease both;
}

.view.active {
  display: block;
}

.section-header {
  margin-bottom: 16px;
}

.section-header p {
  margin: 6px 0 0;
  color: var(--text-dim);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  padding: 16px 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  position: relative;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kpi-card h3 {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.kpi-card p {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.kpi-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  margin-top: 6px;
  color: var(--text-dim);
}

.up p {
  color: var(--ok);
}

.down p {
  color: var(--bad);
}

.warn p {
  color: var(--warn);
}

.save p {
  color: #8de8ff;
}

.patrimony p {
  color: #d2ff89;
}

.fic-kpis {
  margin-top: 10px;
  margin-bottom: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.fic-kpis .kpi-card {
  padding: 16px;
}

.fic-kpis .kpi-card h3 {
  font-size: 0.75rem;
  margin-bottom: 8px;
}

.fic-kpis .kpi-card p {
  font-size: 1.1rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.panel {
  padding: 16px;
}

.panel.wide {
  grid-column: span 2;
}

.gauge-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 10px 0;
}

.gauge {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Outfit", sans-serif;
  font-size: 2rem;
  font-weight: 700;
  background:
    radial-gradient(closest-side, #0f1434 78%, transparent 79% 100%),
    conic-gradient(var(--primary) 0deg, var(--primary-light) 0deg, rgba(255, 255, 255, 0.16) 0deg);
  transition: background 0.45s ease;
}

.gauge span {
  transform: translateY(2px);
}

.score-range {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 2px 0 0;
  letter-spacing: 0.5px;
}

.score-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  max-width: 240px;
}

.score-chip {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-dim);
  white-space: nowrap;
}

canvas {
  width: 100% !important;
  max-height: 330px;
  opacity: 0;
  transform: translateY(8px);
  animation: chartIn 0.65s ease forwards;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-row .form-field {
  min-width: 140px;
}

.filter-row select {
  min-height: 44px;
  padding: 10px 36px 10px 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 2px;
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: rgba(10, 14, 33, 0.75);
  color: var(--text-dim);
  font-size: 0.9rem;
  min-height: 48px;
}

.check-inline input {
  width: auto;
  min-height: auto;
}

input,
select {
  width: 100%;
  min-height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 16px 18px;
  color: var(--text);
  background: rgba(10, 14, 33, 0.8);
  font-size: 1rem;
  font-family: "Outfit", sans-serif;
  line-height: 1.4;
  transition: all 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 60, 225, 0.2);
  background: rgba(10, 14, 33, 0.95);
}

input::placeholder {
  color: #6a6a8a;
  opacity: 1;
  padding-left: 2px;
}

input::-webkit-input-placeholder {
  padding-left: 2px;
}

input:-moz-placeholder {
  padding-left: 2px;
}

input:-ms-input-placeholder {
  color: #6a6a8a;
}

input::-ms-input-placeholder {
  color: #6a6a8a;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239898b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
  cursor: pointer;
}

select option {
  background: var(--bg-mid);
  color: var(--text);
  padding: 12px;
}

button {
  border: 1px solid transparent;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 12px 18px;
  font-weight: 600;
  font-family: "Outfit", sans-serif;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.loading {
  opacity: 0.75;
  pointer-events: none;
  cursor: not-allowed;
}

button.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(108, 60, 225, 0.4);
}

button:active {
  transform: translateY(0);
}

button.ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

button.secondary {
  background: rgba(108, 60, 225, 0.2);
  border: 1px solid rgba(108, 60, 225, 0.4);
  color: var(--primary-light);
}

button.danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
  color: var(--text-dim);
  font-weight: 600;
}

.danger {
  background: rgba(255, 109, 137, 0.16);
  border: 1px solid rgba(255, 109, 137, 0.35);
}

.ia-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ia-controls {
  text-align: center;
  padding: 10px 0;
}

.ia-description {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.6;
}

.ia-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.ia-btn {
  font-size: 1.1rem;
  padding: 14px 28px;
  border-radius: 30px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  transition: transform 0.2s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.ia-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(110, 123, 255, 0.4);
}

.ia-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.ia-btn-icon {
  font-size: 1.2rem;
}

.secondary-ia-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.ia-loader {
  text-align: center;
  padding: 40px 0;
  color: var(--accent);
  font-weight: 500;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 0.4;
  }
}

.ia-result-wrapper {
  margin-top: 10px;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid rgba(159, 124, 255, 0.25);
  background: rgba(10, 14, 38, 0.85);
  box-shadow: inset 0 0 20px rgba(159, 124, 255, 0.05);
  transition: all 0.3s ease;
}

.ia-result-wrapper.hidden {
  display: none;
}

.ia-result {
  color: var(--text);
  line-height: 1.7;
  font-size: 0.95rem;
}

.ia-result h3 {
  color: var(--accent);
  margin-top: 1.5em;
  margin-bottom: 0.8em;
  font-size: 1.2rem;
  border-bottom: 1px solid rgba(159, 124, 255, 0.2);
  padding-bottom: 8px;
}

.ia-result p {
  margin-bottom: 1em;
}

.ia-result ul {
  margin-left: 20px;
  margin-bottom: 1em;
}

.ia-result li {
  margin-bottom: 0.5em;
}

.ia-result strong {
  color: #fff;
}

#financeCalendar {
  margin-top: 10px;
}

.fc .fc-toolbar-title {
  color: var(--text);
  font-family: "Outfit", sans-serif;
  font-size: 1rem;
}

.fc .fc-button {
  background: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: var(--text) !important;
}

.fc .fc-daygrid-day-number,
.fc .fc-col-header-cell-cushion,
.fc .fc-list-day-cushion {
  color: var(--text) !important;
}

.fc-theme-standard td,
.fc-theme-standard th,
.fc-theme-standard .fc-scrollgrid {
  border-color: rgba(255, 255, 255, 0.12) !important;
}

.flatpickr-calendar {
  background: #0f1538;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 30px rgba(5, 8, 26, 0.5);
  z-index: 99999;
}

.flatpickr-month,
.flatpickr-current-month,
.flatpickr-weekdays,
.flatpickr-weekday,
.flatpickr-day,
.flatpickr-time input {
  color: #e8ecff;
}

.flatpickr-day:hover,
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--primary);
  border-color: var(--primary);
}

.cdt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.cdt-cards {
  display: grid;
  gap: 10px;
}

.cdt-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cdt-card button.danger {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
}

.cdt-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.cdt-pill {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: var(--text-dim);
}

.cdt-pill.proximo {
  color: #ffd18d;
  border-color: rgba(255, 185, 87, 0.55);
}

.cdt-pill.vencido {
  color: #ff9ab0;
  border-color: rgba(255, 109, 137, 0.55);
}

.cdt-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.cdt-metrics p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-dim);
}

.cdt-metrics strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
}

.cdt-metrics p.retention {
  color: var(--warn);
}

.cdt-metrics p.retention strong {
  color: var(--warn);
}

.cdt-metrics p.net-value {
  color: var(--ok);
  font-weight: 600;
}

.cdt-metrics p.net-value strong {
  color: var(--ok);
  font-size: 1.1em;
}

.cdt-calendar,
.cdt-alerts {
  display: grid;
  gap: 8px;
}

.calendar-item,
.alert-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px;
  background: rgba(7, 12, 32, 0.7);
}

.alert-item {
  border-left: 4px solid var(--primary);
}

.alert-item.warning {
  border-left-color: var(--warn);
}

.alert-item.danger {
  border-left-color: var(--bad);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 10, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: min(100%, 420px);
  max-width: 420px;
  padding: 32px 28px;
  border-radius: 20px;
}

.auth-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  text-align: center;
}

.brand-title {
  font-family: "Space Mono", monospace;
  color: #fff;
}

.brand-title span {
  color: var(--accent);
}

.auth-card > p {
  text-align: center;
  margin-bottom: 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.auth-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-form .form-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
}

.auth-form input {
  min-height: 52px;
  padding: 14px 16px;
  font-size: 1rem;
  border-radius: 12px;
  background: rgba(10, 14, 33, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  transition: all 0.2s ease;
}

.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 60, 225, 0.25);
  outline: none;
}

.auth-form input::placeholder {
  color: #5a5a7a;
}

/* Autofill styles for login */
.auth-form input:-webkit-autofill,
.auth-form input:-webkit-autofill:hover,
.auth-form input:-webkit-autofill:focus,
.auth-form input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px rgba(10, 14, 33, 0.9) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text) !important;
  transition: background-color 5000s ease-in-out 0s;
}

.auth-form button[type="submit"] {
  margin-top: 8px;
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 12px;
}

.auth-form.slim {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.auth-message {
  margin: 16px 0 0;
  min-height: 24px;
  font-size: 0.9rem;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
}

/* Error state for auth-message */
.auth-message.error {
  background: rgba(255, 109, 137, 0.1);
  border-color: rgba(255, 109, 137, 0.2);
  color: #ff9ab0;
}

/* Admin header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.admin-header-title {
  flex: 1;
}

.admin-sync-btn {
  margin-top: 8px;
  white-space: nowrap;
}

/* Mobile admin header */
@media (max-width: 600px) {
  .admin-header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-sync-btn {
    margin-top: 12px;
    width: 100%;
  }
}

/* Admin actions cell */
.admin-actions-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-dim);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.auth-tab.active {
  background: rgba(108, 60, 225, 0.2);
  border-color: var(--primary);
  color: var(--text);
}

/* --- Toggles (Switches) --- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #e8ecff;
  transition: .4s;
}

input:checked+.slider {
  background-color: #43d39e;
  border-color: #43d39e;
}

input:focus+.slider {
  box-shadow: 0 0 1px #43d39e;
}

input:checked+.slider:before {
  transform: translateX(20px);
  background-color: #fff;
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}


@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes chartIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Utility Color Classes --- */
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }

/* --- Buttons --- */
.secondary {
  background: rgba(110, 123, 255, 0.16);
  border: 1px solid rgba(110, 123, 255, 0.35);
  color: var(--primary);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 8px;
}

td.actions-cell {
  white-space: nowrap;
}

td.actions-cell button {
  margin-right: 4px;
  margin-bottom: 2px;
  vertical-align: middle;
}

/* --- Modal Overlay --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 10, 26, 0.78);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  width: min(100%, 500px);
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  border-radius: 18px;
  animation: slideUp 0.25s ease;
}

.modal-wide {
  width: min(100%, 800px);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  font-size: 1.15rem;
  color: var(--accent);
}

.modal-close-btn {
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 10px;
  color: var(--text-dim);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* --- Edit Modal Grid --- */
.edit-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.edit-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.edit-field-wrap .edit-field-lbl {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
}

.edit-field-wrap input,
.edit-field-wrap select {
  width: 100%;
}

.edit-field-wrap .check-inline {
  margin-top: 4px;
}

.edit-field-label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.edit-field-label input,
.edit-field-label select {
  width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* --- Amortization Summary --- */
.amort-summary-row {
  background: rgba(110, 123, 255, 0.06);
}

.amort-summary-row td {
  padding: 8px 10px;
  border-bottom: 2px solid rgba(110, 123, 255, 0.15);
}

.amort-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.amort-chip {
  font-size: 0.84rem;
  color: var(--text-dim);
}

.amort-chip strong {
  color: var(--text);
}

.amort-chip-total strong {
  color: var(--warn);
}

.amort-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.amort-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.amort-card-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.amort-card-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.amort-card-value.bad {
  color: var(--bad);
}

.amort-card-value.warn {
  color: var(--warn);
}

/* --- IA Indicators --- */
.ia-indicators {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ia-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.ia-card-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.ia-card-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* --- IA Result Improvements --- */
.ia-result code {
  background: rgba(110, 123, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* --- Hormiga Summary --- */
.hormiga-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0;
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.hormiga-summary strong {
  color: var(--text);
}

.gastos-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0;
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.gastos-summary strong {
  color: var(--text);
}

.variables-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0;
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.variables-summary strong {
  color: var(--text);
}

.gastos-alerts {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.top-category {
  background: rgba(108, 60, 225, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
  border-left: 3px solid var(--primary);
}

.monthly-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.monthly-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.monthly-item-stack {
  display: block;
}

.monthly-label {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.monthly-value {
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
}

.monthly-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.monthly-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(110, 123, 255, 0.14);
  color: var(--text);
  font-size: 0.84rem;
}

@media (max-width: 1100px) {

  .top-header,
  .app-footer {
    margin-left: 14px;
    margin-right: 14px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding: 14px;
    overflow: visible;
  }

  .sidebar {
    position: static;
    height: auto;
    top: 0;
  }

  .content {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }

  .summary-grid,
  .dashboard-grid,
  .cdt-grid,
  .fic-kpis {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    z-index: 92;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    height: auto;
  }

  .top-header h2 {
    font-size: 1rem;
    max-width: 50vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }

  .top-subtitle,
  #sidebarCollapseBtn,
  .quick-action:not(.profile-shortcut),
  .sync-pill {
    display: none;
  }

  .profile-shortcut {
    display: inline-flex !important;
    font-size: 1.2rem;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    align-items: center;
  }

  #menuToggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .app-shell {
    padding: 96px 12px 24px;
  }

  /* Add margin to first section header so it's not covered by fixed header */
  .view.active .section-header {
    margin-top: 12px;
    padding-top: 12px;
    scroll-margin-top: 80px;
  }

  .section-header {
    margin-bottom: 16px;
  }

  .section-header h2 {
    font-size: 1.25rem;
    margin-bottom: 6px;
    line-height: 1.3;
  }

  .section-header p {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.4;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(84vw, 320px);
    border-radius: 0 18px 18px 0;
    z-index: 90;
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(6, 10, 26, 0.55);
    z-index: 80;
  }

  body.menu-open .menu-backdrop {
    display: block;
  }
  
  /* Mobile menu items - more compact */
  .menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  
  .menu-item {
    padding: 10px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .content {
    gap: 16px;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .panel,
  .kpi-card {
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .form-grid,
  .edit-fields-grid,
  .cdt-metrics {
    grid-template-columns: 1fr;
  }

  th,
  td {
    white-space: nowrap;
    font-size: 0.84rem;
    padding: 8px 10px;
  }

  /* Table as cards on mobile */
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr {
    display: block;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
  }

  .table-wrap td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: right;
  }

  .table-wrap td:last-child {
    border-bottom: none;
  }

  .table-wrap td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .table-wrap td.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .table-wrap td.actions-cell::before {
    display: none;
  }

  .table-wrap td.actions-cell button {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  /* Better form spacing on mobile */
  .form-grid {
    gap: 16px;
  }

  .form-field {
    gap: 8px;
  }

  .form-field label {
    font-size: 0.85rem;
  }

  input,
  select {
    min-height: 52px;
    padding: 14px 16px;
    font-size: 1rem;
  }

  button[type="submit"] {
    width: 100%;
    margin-top: 8px;
    padding: 16px;
    font-size: 1rem;
  }

  canvas {
    max-height: 250px;
  }

  .app-footer {
    margin: 0 12px 12px;
    font-size: 0.76rem;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }

  .modal-content {
    padding: 16px;
    max-height: 90vh;
  }

  .amort-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .amort-card {
    padding: 10px;
  }

  .amort-card-value {
    font-size: 0.95rem;
  }

  .amort-inline {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }

  .ia-indicators {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .ia-card {
    padding: 12px;
  }

  /* Tables: allow horizontal scroll but improve UX */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 100%;
  }
  
  th, td {
    white-space: nowrap;
    font-size: 0.78rem;
    padding: 8px 6px;
  }

  /* Make action buttons stack on mobile */
  td.actions-cell button {
    display: inline-block;
    margin-bottom: 2px;
    margin-right: 2px;
    width: auto;
    font-size: 0.7rem;
    padding: 4px 8px;
  }

  /* Form fields stack on mobile */
  .form-grid,
  .edit-fields-grid {
    grid-template-columns: 1fr;
  }
  
  .form-field {
    width: 100%;
  }
  
  .form-field label {
    font-size: 0.75rem;
  }
  
  /* Auth form improvements */
  .auth-form {
    gap: 8px;
  }
  
  .auth-form .form-field {
    margin-bottom: 4px;
  }
}

/* SweetAlert2 Custom Theme */
.swal2-popup {
  font-family: "Outfit", sans-serif !important;
  background: var(--bg-mid) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: 16px !important;
}

.swal2-title {
  font-family: "Outfit", sans-serif !important;
  color: var(--text) !important;
}

.swal2-content {
  color: var(--text-dim) !important;
}

.swal2-confirm {
  background: linear-gradient(135deg, var(--primary), var(--primary-light)) !important;
  border: none !important;
  border-radius: 10px !important;
  font-family: "Outfit", sans-serif !important;
  font-weight: 600 !important;
}

.swal2-cancel {
  background: rgba(255, 255, 255, 0.1) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  color: var(--text) !important;
  border-radius: 10px !important;
  font-family: "Outfit", sans-serif !important;
}

.swal2-input,
.swal2-select {
  background: rgba(10, 14, 33, 0.8) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  border-radius: 10px !important;
}

.swal2-input:focus,
.swal2-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(108, 60, 225, 0.3) !important;
}

.swal2-icon.swal2-success {
  border-color: var(--ok) !important;
  color: var(--ok) !important;
}

.swal2-icon.swal2-error {
  border-color: var(--bad) !important;
  color: var(--bad) !important;
}

.swal2-icon.swal2-warning {
  border-color: var(--warn) !important;
  color: var(--warn) !important;
}

/* Calendar event popup badge */
.swal-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(108, 60, 225, 0.2);
  color: var(--primary-light);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Mobile auth form improvements */
@media (max-width: 480px) {
  .auth-overlay {
    padding: 16px;
    align-items: flex-start;
    padding-top: 40px;
  }

  .auth-card {
    padding: 24px 20px;
    width: 100%;
  }

  .auth-card h2 {
    font-size: 1.3rem;
  }

  .auth-form {
    gap: 14px;
  }

  .auth-form input {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .auth-form button[type="submit"] {
    min-height: 48px;
  }

  .auth-toggle {
    gap: 6px;
  }

  .auth-tab {
    padding: 10px 8px;
    font-size: 0.9rem;
  }
}

/* ── Reportes Filters ──────────────────────────────────────── */
.reportes-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.reportes-filters .form-field {
  min-width: 140px;
}

.reportes-filters select[multiple] {
  min-height: 120px;
}

.reportes-filters button {
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .reportes-filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .reportes-filters .form-field {
    width: 100%;
  }
}

/* ── Sidebar collapsed: hide group labels ──────────────────── */
body.sidebar-collapsed .menu-group-label {
  display: none;
}

body.sidebar-collapsed .user-chip-role {
  display: none;
}

/* ── Form grid: submit button alignment ────────────────────── */
.form-grid > button[type="submit"] {
  align-self: end;
  min-height: 56px;
}

/* ── Touch-friendly action buttons on mobile ───────────────── */
@media (max-width: 768px) {
  td.actions-cell button {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: 8px;
  }
}

/* ── Empty states ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
}

.empty-state-icon {
  font-size: 2.5rem;
  opacity: 0.5;
  animation: pulse 3s infinite;
}

.empty-state p {
  font-size: 0.92rem;
  margin: 0;
  max-width: 240px;
  line-height: 1.5;
}

.empty-state .empty-cta {
  font-size: 0.82rem;
  color: var(--primary-light);
  border: 1px dashed rgba(167, 139, 250, 0.4);
  background: rgba(108, 60, 225, 0.08);
  padding: 8px 16px;
  border-radius: 10px;
  cursor: default;
}

/* ── KPI cards icon accent ─────────────────────────────────── */
.kpi-icon {
  font-size: 1.1rem;
  margin-bottom: 6px;
  display: block;
  opacity: 0.75;
}

/* ── Dates: legible format helper ─────────────────────────── */
.date-readable {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

/* ── Quick-add panel ───────────────────────────────────────── */
.quick-add-panel {
  border: 1px solid rgba(67, 211, 158, 0.2);
  background: rgba(67, 211, 158, 0.04);
}

.quick-add-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #43d39e;
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

/* ── Compact form grid (quick-add) ─────────────────────────── */
.form-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px 12px;
}

.form-grid-compact .form-field label {
  font-size: 0.72rem;
}

.form-grid-compact input,
.form-grid-compact select {
  padding: 8px 10px;
  font-size: 0.88rem;
}

.form-grid-compact button[type="submit"] {
  align-self: end;
  min-height: 44px;
  padding: 8px 18px;
  font-size: 0.9rem;
}

/* ── OK / green button ─────────────────────────────────────── */
button.ok-btn {
  background: linear-gradient(135deg, #2ecc71, #43d39e);
  color: #0f1434;
  font-weight: 700;
}

button.ok-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(67, 211, 158, 0.35);
}

