/* ===== RESET & VARIÁVEIS ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f7fb;
  --bg-elevated: #eef3fb;
  --bg-card: #ffffff;
  --bg-soft: #f8fafd;
  --text-primary: #0b1220;
  --text-secondary: #4b5568;
  --text-tertiary: #6f7c90;
  --border: #dbe3ef;
  --border-strong: #c8d4e5;

  --green: #16a34a;
  --green-bg: #dcfce7;
  --green-text: #166534;

  --red: #dc2626;
  --red-bg: #fee2e2;
  --red-text: #991b1b;

  --orange: #ea580c;
  --orange-bg: #ffedd5;
  --orange-text: #9a3412;

  --blue: #7B4FE8;
  --blue-bg: #EEE8FD;
  --blue-text: #4C1D95;

  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --purple-text: #5b21b6;

  --amber: #d97706;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;

  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.09), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 34px rgba(15, 23, 42, 0.14), 0 6px 14px rgba(15, 23, 42, 0.1);

  --header-height: 62px;
  --nav-height: 70px;
  --content-padding: 18px;
  --max-width: 800px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overscroll-behavior: none;
  scrollbar-gutter: stable;
}

body {
  font-family: 'Segoe UI', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background:
    radial-gradient(circle at 8% -10%, #ede8ff 0, rgba(237, 232, 255, 0) 42%),
    radial-gradient(circle at 92% -14%, #e6f6f3 0, rgba(230, 246, 243, 0) 36%),
    linear-gradient(180deg, #faf8ff 0%, var(--bg) 32%, #f4f2fc 100%);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  overscroll-behavior: none;
}

body.app-modal-open {
  overflow: hidden;
}

body.app-modal-open #content {
  overflow-y: hidden;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ===== APP LAYOUT — shell fixo, só #content rola ===== */
#app {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER — flex item no topo do app shell ===== */
#header {
  flex-shrink: 0;
  height: var(--header-height);
  background: rgba(245, 248, 253, 0.97);
  display: flex;
  align-items: center;
  padding: 0 var(--content-padding);
  z-index: 40;
  border-bottom: 1px solid rgba(200, 212, 229, 0.7);
}

#header h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

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

.header-brand::before {
  content: '';
  width: 4px;
  height: 22px;
  background: linear-gradient(180deg, #a78bfa 0%, var(--blue) 100%);
  border-radius: 3px;
  flex-shrink: 0;
}

/* ===== CONTENT — único elemento que faz scroll ===== */
#content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: var(--content-padding);
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  scrollbar-gutter: stable;
}

.tab-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ===== MONTH SELECTOR ===== */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.month-label-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.month-selector .month-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.month-year {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.month-nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--blue);
  transition: background 0.15s;
}

.month-nav-btn:active {
  background: var(--blue-bg);
}

/* ===== SUMMARY CARD ===== */
.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.summary-card .summary-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.summary-card .summary-value {
  font-size: 1.82rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--green);
}

.summary-card .summary-value.is-negative {
  color: var(--red);
}

/* ===== SUMMARY CARD HERO ===== */
.summary-card--hero {
  background: linear-gradient(135deg, #5B21B6 0%, #7B4FE8 55%, #8B5CF6 100%);
  border: none;
  box-shadow: 0 8px 28px rgba(123, 79, 232, 0.32), 0 2px 6px rgba(123, 79, 232, 0.16);
  padding: 22px 20px;
}

.summary-card--hero .summary-label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8125rem;
  font-weight: 500;
}

.summary-card--hero .summary-value {
  color: #ffffff;
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.summary-card--hero .summary-value.is-negative {
  color: #fca5a5;
}

/* ===== CATEGORY ROW HEADER ===== */
.cat-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cat-row-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.cat-config-btn {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-bg);
  padding: 3px 10px;
  border-radius: 100px;
  transition: background 0.15s, color 0.15s;
}

.cat-config-btn:active {
  background: var(--blue);
  color: #fff;
}

.cat-empty-hint {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  padding: 8px 0;
  grid-column: 1 / -1;
}

/* ===== CATEGORY CARDS CONFIG MODAL ===== */
.cat-config-hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.4;
}

.cat-config-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.cat-config-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cat-config-item:has(input:checked) {
  background: var(--blue-bg);
  border-color: var(--blue);
}

.cat-config-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  cursor: pointer;
  flex-shrink: 0;
}

.cat-config-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

/* ===== CATEGORY ROW ===== */
.category-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.category-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 14px 14px 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
}

.category-card .cat-label {
  font-size: 0.775rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.category-card .cat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green);
}

.category-card .cat-value.is-negative {
  color: var(--red);
}

.category-card.full-width {
  grid-column: 1 / -1;
}

/* ===== CHIPS / FILTERS ===== */
.chips-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chips-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  transition: all 0.15s;
  white-space: nowrap;
}

.chip:active {
  transform: scale(0.96);
}

.chip.active {
  background: linear-gradient(180deg, #6D28D9 0%, var(--blue) 100%);
  color: white;
  border-color: var(--blue);
  box-shadow: 0 4px 10px rgba(123, 79, 232, 0.28);
}

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 14px 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title::before {
  content: '';
  width: 3px;
  height: 11px;
  background: var(--blue);
  border-radius: 2px;
  flex-shrink: 0;
}

.section-title--amber { color: var(--amber-text); }
.section-title--amber::before { background: var(--amber); }
.section-title--green { color: var(--green-text); }
.section-title--green::before { background: var(--green); }
.section-title--blue { color: var(--blue-text); }
.section-title--blue::before { background: var(--blue); }

/* ===== TRANSACTION LIST ===== */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transaction-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow: hidden;
  gap: 0;
  padding: 0;
}

.transaction-item.tx-inactive {
  opacity: 0.68;
}

/* Colored left bar by transaction type */
.tx-type-indicator {
  width: 4px;
  flex-shrink: 0;
}

.tx-type-indicator.tx-type-entrada { background: var(--green); }
.tx-type-indicator.tx-type-saida   { background: var(--red); }
.tx-type-indicator.tx-type-neutral { background: var(--border-strong); }

/* Inner body (padding lives here) */
.tx-body {
  flex: 1;
  padding: 13px 12px 11px;
  min-width: 0;
}

.tx-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* Right column: amount + action button */
.tx-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.transaction-info {
  flex: 1;
  min-width: 0;
}

.transaction-info .tx-desc {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.transaction-info .tx-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.transaction-info .tx-meta span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.tx-date-badge {
  background: var(--blue-bg);
  color: var(--blue-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 100px;
  letter-spacing: 0.01em;
}

/* Date column — dia + mês à esquerda do card */
.tx-date-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  flex-shrink: 0;
  padding-right: 2px;
  border-right: 1px solid var(--border);
  margin-right: 2px;
  gap: 1px;
}

.tx-date-day {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.tx-date-mon {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
}

.transaction-amount {
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.transaction-amount.is-entrada {
  color: var(--green);
}

.transaction-amount.is-saida {
  color: var(--red);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-tertiary);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state .empty-text {
  font-size: 0.9375rem;
}

/* ===== BOTTOM NAVIGATION — flex item na base do app shell ===== */
#bottom-nav {
  flex-shrink: 0;
  width: 100%;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid var(--border);
  z-index: 70;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-top: 0;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.07);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--nav-height) - 2px);
  gap: 2px;
  padding: 8px 4px;
  color: #728199;
  transition: color 0.15s;
  position: relative;
  font-size: 0.7rem;
  font-weight: 500;
}

.nav-item .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
  padding: 3px 10px;
  border-radius: 100px;
  transition: background 0.15s;
}

.nav-item .nav-label {
  font-size: 0.71rem;
  line-height: 1.2;
}

.nav-item.active {
  color: var(--blue);
  font-weight: 700;
}

.nav-item.active .nav-icon {
  background: rgba(123, 79, 232, 0.1);
  color: var(--blue);
}

.nav-item.active::after {
  display: none;
}

/* ===== FAB BUTTON — position:absolute dentro do #app shell ===== */
.fab {
  position: absolute;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
  right: 16px;
  left: auto;
  margin: 0;
  width: fit-content;
  z-index: 45;
  background: linear-gradient(180deg, #6D28D9 0%, var(--blue) 100%);
  color: white;
  padding: 13px 22px;
  border-radius: 100px;
  font-size: 0.9375rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(calc(100vw - 32px), 340px);
}

.fab:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-md);
}

.fab-icon {
  font-size: 1.35rem;
  font-weight: 300;
  line-height: 1;
}

.fab-label {
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ===== ACCOUNT CARDS ===== */
.account-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.account-card .account-header {
  padding: 18px 18px 14px;
  background: linear-gradient(180deg, #fbfdff 0%, #f6f9ff 100%);
}

.account-card .account-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.account-card .account-balance {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0;
}

.account-card .account-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 18px 8px;
}

.account-card .boxes-list {
  padding: 0 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-card .box-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.account-card .box-name {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

.account-card .box-balance {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--blue);
}

.account-card .cards-section {
  border-top: 1px solid var(--border);
  padding: 14px 18px 18px;
  background: #fcfdff;
}

.account-card .card-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.account-card .card-item + .card-item {
  border-top: 1px solid var(--border);
}

.account-card .card-info {
  flex: 1;
  min-width: 0;
}

.account-card .card-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.account-card .card-statement {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.account-card .card-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}

.account-card .card-status.aberta {
  background: var(--amber-bg);
  color: var(--amber-text);
}

.account-card .card-status.paga {
  background: var(--green-bg);
  color: var(--green-text);
}

/* ===== BILLS LIST ===== */
.bill-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bill-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.bill-item .bill-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.bill-item .bill-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.bill-item .bill-amount {
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
}

.bill-item .bill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 10px;
}

.bill-item .bill-meta span {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.bill-item .bill-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.bill-item .bill-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  display: inline-block;
  margin-bottom: 8px;
}

.bill-status-badge.pendente {
  background: var(--amber-bg);
  color: var(--amber-text);
}

.bill-status-badge.paga {
  background: var(--green-bg);
  color: var(--green-text);
}

.bill-item.paga {
  opacity: 0.7;
}

.bill-item.paga .bill-name {
  text-decoration: line-through;
}

/* ===== SETTINGS (MAIS TAB) ===== */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 13px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.settings-card:active {
  background: var(--bg-elevated);
}

.settings-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--blue-bg);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.settings-card .settings-label {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-card .settings-arrow {
  color: var(--text-tertiary);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overscroll-behavior: contain;
}

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

/* Fix: inline style pointer-events:none persists after closeModal() — override it */
.modal-overlay:not(.hidden) {
  pointer-events: auto !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 20, 35, 0.42);
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: var(--max-width);
  max-height: 92vh;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease;
  overflow: hidden;
  border: 1px solid rgba(198, 211, 231, 0.65);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

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

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.modal-close:active {
  background: var(--border);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 18px;
  -webkit-overflow-scrolling: touch;
}

/* ===== MODAL TYPE SELECTOR ===== */
.type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.type-btn {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  transition: all 0.15s;
  text-align: center;
}

.type-btn:active {
  transform: scale(0.97);
}

.type-btn.active {
  border-color: #b59cf5;
  background: linear-gradient(180deg, #f3effe 0%, #ebe3fc 100%);
  color: var(--blue-text);
}

/* ===== FORM ELEMENTS ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fbfdff;
  font-size: 0.9375rem;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(123, 79, 232, 0.14);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ===== CARD ITEMS IN MODAL ===== */
.card-item-form {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}

.card-item-form .remove-item-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--red);
  background: var(--red-bg);
}

.add-item-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border-strong);
  color: var(--blue);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s;
  margin-bottom: 16px;
}

.add-item-btn:active {
  background: var(--blue-bg);
  border-color: var(--blue);
}

/* ===== MODAL BUTTONS ===== */
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all 0.15s;
  text-align: center;
  border: 1px solid transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #6D28D9 0%, var(--blue) 100%);
  color: white;
  box-shadow: 0 6px 14px rgba(123, 79, 232, 0.25);
}

.btn-secondary {
  background: var(--bg-soft);
  color: #42556a;
  border: 1px solid var(--border-strong);
}

/* ===== DESCRIPTION SUGGESTION ===== */
.desc-suggestion {
  display: none;
  font-size: 0.8125rem;
  color: var(--blue);
  padding: 4px 0 0;
}

.desc-suggestion.visible {
  display: block;
}

.desc-suggestion strong {
  font-weight: 600;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 600px) {
  :root {
    --content-padding: 22px;
  }

  .category-row {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .modal-sheet {
    border-radius: var(--radius-lg);
    margin: 28px 16px;
    max-height: 85vh;
  }

  .modal-overlay {
    align-items: center;
  }

  .bill-item .bill-actions {
    justify-content: flex-end;
  }
}

@media (min-width: 900px) {
  :root {
    --nav-height: 74px;
  }

  #bottom-nav {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  #content {
    padding-left: 32px;
    padding-right: 32px;
  }

  .account-card .account-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .account-card .account-balance {
    text-align: right;
  }
}

/* ===== MANAGEMENT VIEWS (MAIS) ===== */

.mgmt-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.mgmt-back {
  width: auto;
  padding: 6px 10px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--blue);
  flex-shrink: 0;
  transition: background 0.15s;
}

.mgmt-back::before {
  content: '‹';
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
}

.mgmt-back:active {
  background: var(--blue-bg);
}

.mgmt-title {
  font-size: 1.125rem;
  font-weight: 700;
  flex: 1;
}

.mgmt-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 16px 0 8px;
}

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

.mgmt-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mgmt-item-info {
  flex: 1;
  min-width: 0;
}

.mgmt-item-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.mgmt-item-name .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mgmt-item-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

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

.mgmt-btn {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.15s;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text-secondary);
  white-space: nowrap;
}

.mgmt-btn:active {
  transform: scale(0.96);
}

.mgmt-btn-edit {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--blue-bg);
}

.mgmt-btn-archive {
  color: var(--amber);
  border-color: var(--amber);
  background: var(--amber-bg);
}

.mgmt-btn-unarchive {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-bg);
}

.mgmt-btn-delete {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-bg);
}

.mgmt-item.archived {
  opacity: 0.65;
}

.mgmt-status-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  display: inline-block;
}

.mgmt-status-badge.ativa,
.mgmt-status-badge.ativo {
  background: var(--green-bg);
  color: var(--green-text);
}

.mgmt-status-badge.arquivada,
.mgmt-status-badge.arquivado {
  background: var(--amber-bg);
  color: var(--amber-text);
}

.mgmt-type-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--blue-bg);
  color: var(--blue-text);
}

.mgmt-type-badge.receita {
  background: var(--green-bg);
  color: var(--green-text);
}

.mgmt-type-badge.despesa {
  background: var(--red-bg);
  color: var(--red-text);
}

.mgmt-type-badge.ambos {
  background: var(--purple-bg);
  color: var(--purple-text);
}

.mgmt-add-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 2px dashed var(--border-strong);
  color: var(--blue);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: all 0.15s;
  margin-top: 8px;
  text-align: center;
}

.mgmt-add-btn:active {
  background: var(--blue-bg);
  border-color: var(--blue);
}

.mgmt-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.mgmt-inline-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.mgmt-inline-form .form-group {
  margin-bottom: 12px;
}

.mgmt-inline-form .form-group:last-child {
  margin-bottom: 0;
}

/* Suggestion indicator */
.suggestion-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-bg);
  padding: 3px 10px;
  border-radius: 100px;
  margin-top: 6px;
}

/* Make type selector wider on management forms */
.type-selector.mgmt-type-selector {
  grid-template-columns: 1fr;
}

/* Box list inside management */
.mgmt-box-list {
  margin-top: 8px;
  padding-left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mgmt-box-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.mgmt-box-item .box-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.mgmt-box-item .box-name {
  font-weight: 500;
}

.mgmt-box-item .box-balance {
  font-weight: 600;
  color: var(--text-secondary);
}

.mgmt-box-item .box-type-tag {
  font-size: 0.6875rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-secondary);
}

/* Competence year field in bill form */
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .form-row-3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== BILL AMOUNT CLASSES ===== */
.bill-amount--pendente {
  color: var(--amber);
}
.bill-amount--paga {
  color: var(--green);
}

/* ===== CHIP VARIANTS ===== */
.chip--pay {
  color: var(--green-text);
  border-color: var(--green);
  background: var(--green-bg);
}
.chip--unpay {
  color: var(--blue-text);
  border-color: var(--blue);
  background: var(--blue-bg);
}

/* Alert / block message */
.block-msg {
  background: var(--amber-bg);
  color: var(--amber-text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  margin-bottom: 12px;
  line-height: 1.4;
}

.tx-action-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.4;
  min-height: 26px;
  white-space: nowrap;
}

.app-action-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  isolation: isolate;
  overscroll-behavior: contain;
}

.app-action-modal.hidden {
  display: none;
  pointer-events: none;
}

.app-action-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 20, 35, 0.46);
  touch-action: none;
}

.app-action-sheet {
  position: relative;
  width: 100%;
  max-width: var(--max-width);
  max-height: 90vh;
  overflow: hidden;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  contain: layout style paint;
  border: 1px solid rgba(198, 211, 231, 0.65);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
}

.app-action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.app-action-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.app-action-close {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.app-action-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  white-space: pre-line;
  flex-shrink: 0;
}

.app-action-content {
  margin-bottom: 12px;
  overflow: auto;
  min-height: 0;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.app-action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

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

.action-item {
  text-align: left;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  font-size: 0.9375rem;
  font-weight: 600;
}

.search-select {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
}

.search-select-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.search-select-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  max-height: 40vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.app-modal-content--stretch {
  flex: 1;
  display: flex;
  min-height: 0;
}

.app-modal--fullscreen {
  height: 100vh;
  max-height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.app-modal--fullscreen .app-action-content {
  flex: 1;
  min-height: 0;
  display: flex;
}

.app-modal--fullscreen .search-select {
  flex: 1;
}

.app-modal--fullscreen .search-select-list {
  flex: 1;
  max-height: none;
}

.app-modal--fullscreen .app-action-buttons {
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
  padding-top: 8px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

@media (min-width: 600px) {
  .app-modal--fullscreen {
    height: min(86vh, 720px);
    max-height: min(86vh, 720px);
    border-radius: var(--radius-lg);
  }
}

.search-item {
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
}

.search-item-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.search-item-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.search-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}

@media (max-width: 768px) {
  .modal-sheet {
    animation: fadeIn 0.18s ease;
  }

  .fab:active,
  .btn:active,
  .type-btn:active,
  .chip:active,
  .tx-action-btn:active {
    transform: none;
  }
}

@media (max-width: 480px) {
  :root {
    --content-padding: 14px;
    --header-height: 58px;
  }

  .fab {
    right: 12px;
    padding: 13px 18px;
    font-size: 0.875rem;
    bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 10px);
  }

  .summary-card .summary-value {
    font-size: 1.58rem;
  }

  .transaction-item,
  .bill-item,
  .settings-card,
  .mgmt-item {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ===== AUTH LOADING STATE ===== */
.auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-tertiary);
  font-size: 0.875rem;
  gap: 8px;
}

.auth-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background:
    radial-gradient(circle at 8% -10%, #ede8ff 0, rgba(237, 232, 255, 0) 42%),
    radial-gradient(circle at 92% -14%, #e6f6f3 0, rgba(230, 246, 243, 0) 36%),
    linear-gradient(180deg, #faf8ff 0%, var(--bg) 32%, #f4f2fc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 28px 32px;
  width: 100%;
  max-width: 380px;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand-icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
  line-height: 1;
}

.login-brand-title {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-brand-sub {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.login-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.login-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--bg-soft);
  color: var(--text-primary);
  transition: border-color 0.15s;
  outline: none;
  -webkit-appearance: none;
}

.login-input:focus {
  border-color: var(--blue);
  background: #fff;
}

.login-error {
  font-size: 0.8125rem;
  color: var(--red);
  background: var(--red-bg);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: none;
}

.login-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(180deg, #6D28D9 0%, var(--blue) 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  transition: opacity 0.15s;
  margin-top: 4px;
  box-shadow: 0 2px 8px rgba(123, 79, 232, 0.35);
}

.login-btn:not(:disabled):hover {
  opacity: 0.92;
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ===== MAIS TAB — user info + logout ===== */
.mais-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--blue-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid rgba(123, 79, 232, 0.15);
}

.mais-user-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.mais-user-email {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--blue-text);
  word-break: break-all;
}

.settings-card-danger .settings-label {
  color: var(--red);
}

.settings-card-danger .settings-icon {
  filter: none;
}
