:root {
  --green-950: #102b23;
  --green-900: #163b2f;
  --green-800: #1e4a3b;
  --green-700: #2b6652;
  --gold: #e0c56f;
  --gold-dark: #b79a44;
  --cream: #f2eedc;
  --paper: #f8f5e8;
  --card: #ece6cf;
  --line: #cec5a5;
  --ink: #17342b;
  --muted: #6e705f;
  --income: #2c7364;
  --expense: #a13f31;
  --white: #fffdf5;
  --shadow: 0 18px 50px rgba(16, 43, 35, .10);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--ink);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  background: var(--green-950);
  color: var(--cream);
  border-right: 1px solid rgba(224, 197, 111, .18);
}
.brand-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.brand-mark {
  width: 42px; height: 42px; border: 1px solid rgba(224, 197, 111, .55); border-radius: 14px;
  display: grid; place-items: center; color: var(--gold); font-family: Georgia, serif; font-size: 24px; font-weight: 700;
}
.brand { display: block; font-family: Georgia, serif; font-size: 29px; color: var(--gold); letter-spacing: -.4px; }
.brand-sub { display: block; color: #bfcabb; font-size: 12px; margin-top: 2px; }
.nav-list { display: grid; gap: 8px; }
.nav-item, .mobile-nav-item {
  border: 0; background: transparent; color: #cbd5cc; text-align: left; padding: 13px 14px; border-radius: 12px;
}
.nav-item:hover, .nav-item.active { background: rgba(224, 197, 111, .10); color: var(--gold); }
.sidebar-foot { margin-top: auto; color: #92a69a; font-size: 12px; display: grid; gap: 6px; }

.main { min-width: 0; }
.hero {
  padding: 36px 42px 40px;
  color: var(--cream);
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 2px, transparent 2px 22px),
    linear-gradient(135deg, var(--green-900), #173529 70%, #10271f);
  border-bottom-right-radius: 34px;
  box-shadow: var(--shadow);
}
.hero-topline, .eyebrow, .summary-card span, .field > span, .type-toggle legend, .balance-label {
  text-transform: uppercase; letter-spacing: .18em; font-size: 11px; font-weight: 700;
}
.hero-topline, .balance-label, .eyebrow { color: var(--gold); }
.hero-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; }
.hero h1 { margin: 8px 0 3px; font-family: Georgia, serif; font-size: clamp(42px, 6vw, 72px); line-height: .95; color: var(--gold); }
.hero p { margin: 12px 0 26px; color: #ccd6cd; font-size: 17px; }
.period-control { display: grid; gap: 7px; color: #b7c6ba; font-size: 11px; min-width: 190px; }
.period-control select { border: 1px solid rgba(224,197,111,.35); background: rgba(9, 29, 23, .35); color: var(--gold); border-radius: 12px; padding: 11px 12px; outline: none; }
.balance-label { margin-top: 10px; }
.balance { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: clamp(38px, 6vw, 64px); font-weight: 800; color: var(--gold); margin-top: 12px; }

.view { display: none; padding: 30px 42px 80px; }
.view.active { display: block; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 4px; }
.summary-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; min-height: 104px; display: grid; align-content: center; gap: 9px; }
.summary-card span { color: var(--muted); }
.summary-card strong { font-size: 22px; }
.income-card strong { color: var(--income); }
.expense-card strong { color: var(--expense); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 18px; margin-top: 18px; }
.panel { background: var(--paper); border: 1px solid rgba(181,166,116,.45); border-radius: var(--radius); padding: 24px; box-shadow: 0 8px 24px rgba(22,59,47,.04); }
.panel h2 { font-family: Georgia, serif; font-size: 26px; margin: 5px 0 18px; }
.panel-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.transaction-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.full { grid-column: 1 / -1; }
.field { display: grid; gap: 7px; }
.field > span, .type-toggle legend { color: #6b6a56; }
.field input, .field select, .inline-form input {
  width: 100%; border: 1px solid #cfc6a9; background: white; color: var(--ink); border-radius: 12px; padding: 13px 14px; outline: none;
}
.field input:focus, .field select:focus, .inline-form input:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(43,102,82,.12); }
.field-help { color: var(--muted); font-size: 11px; line-height: 1.45; }
.type-toggle { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-toggle legend { margin-bottom: 7px; }
.type-btn { border: 1px solid #cfc6a9; border-radius: 12px; padding: 13px; background: white; color: #54594e; font-weight: 800; }
.type-btn.expense.active { background: var(--expense); border-color: var(--expense); color: white; }
.type-btn.income.active { background: var(--income); border-color: var(--income); color: white; }
.primary-btn, .outline-btn, .danger-btn, .file-btn {
  border-radius: 12px; padding: 13px 16px; font-weight: 800; border: 1px solid transparent; text-align: center;
}
.primary-btn { background: var(--green-900); color: var(--gold); }
.primary-btn:hover { background: var(--green-800); }
.outline-btn { background: transparent; color: var(--green-900); border-color: #bfb493; }
.danger-btn { background: #8c3128; color: white; }
.text-btn { border: 0; background: transparent; color: var(--expense); font-weight: 700; }
.hidden { display: none !important; }

.insights-panel { min-height: 100%; }
.breakdown { display: grid; gap: 14px; }
.breakdown-row { display: grid; gap: 7px; }
.breakdown-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.breakdown-head strong { font-size: 13px; }
.bar-track { height: 8px; border-radius: 999px; background: #e6dfc6; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--green-700); }
.empty-state { padding: 28px 10px; text-align: center; color: var(--muted); }
.empty-state.compact { padding: 40px 4px; }
.list-panel { margin-top: 18px; }

.transaction-list { display: grid; }
.transaction-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; gap: 14px; align-items: center; padding: 15px 4px; border-top: 1px solid #ddd4b8; }
.transaction-row:first-child { border-top: 0; }
.tx-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; }
.tx-icon.expense { background: rgba(161,63,49,.10); color: var(--expense); }
.tx-icon.income { background: rgba(44,115,100,.11); color: var(--income); }
.tx-main { min-width: 0; }
.tx-main strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main span { color: var(--muted); font-size: 12px; }
.tx-amount { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; white-space: nowrap; }
.tx-amount.expense { color: var(--expense); }
.tx-amount.income { color: var(--income); }
.tx-actions { display: flex; gap: 6px; }
.icon-btn { border: 1px solid #d4ccb1; background: transparent; color: #5e655a; border-radius: 9px; padding: 7px 9px; font-size: 12px; }
.icon-btn.delete:hover { color: var(--expense); border-color: #d6a59e; }

.page-heading { margin-bottom: 18px; }
.page-heading h2 { margin: 6px 0 6px; font-family: Georgia, serif; font-size: 34px; }
.page-heading p { color: var(--muted); margin: 0; }
.filters-grid { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; align-items: end; margin-bottom: 18px; }
.filter-clear { height: 48px; }
.category-grid, .backup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.category-grid .panel { min-height: 360px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 16px; }
.category-list { display: grid; gap: 8px; }
.category-chip { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #d8d0b6; border-radius: 12px; padding: 11px 12px; background: #fffdf5; }
.category-chip button { border: 0; background: transparent; color: var(--expense); font-weight: 800; }
.card-manager-panel { grid-column: 1 / -1; min-height: 0 !important; }
.panel-helper { color: var(--muted); margin: -7px 0 16px; line-height: 1.5; font-size: 13px; }
.fixed-chip { border-radius: 999px; padding: 4px 8px; background: rgba(43,102,82,.10); color: var(--green-700); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.backup-grid { grid-template-columns: repeat(3, 1fr); }
.backup-grid .panel p { color: var(--muted); min-height: 48px; }
.file-btn { display: inline-block; background: var(--green-900); color: var(--gold); }
.file-btn input { display: none; }
.danger-panel { border-color: rgba(161,63,49,.35); }
.notice { margin-top: 18px; border-left: 4px solid var(--gold-dark); background: #ebe4c9; border-radius: 10px; padding: 16px 18px; color: #5c5f50; line-height: 1.5; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; background: var(--green-950); color: var(--cream); border: 1px solid rgba(224,197,111,.35); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .backup-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .hero { padding: 26px 20px 30px; border-bottom-right-radius: 28px; }
  .hero-row { display: block; }
  .period-control { margin: 20px 0 8px; min-width: 0; }
  .view { padding: 22px 16px 92px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .summary-card { min-height: 92px; padding: 15px; }
  .summary-card strong { font-size: 18px; }
  .transaction-form, .category-grid, .filters-grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .type-toggle { grid-template-columns: 1fr 1fr; }
  .transaction-row { grid-template-columns: auto minmax(0,1fr) auto; }
  .tx-actions { grid-column: 2 / -1; justify-content: flex-end; }
  .mobile-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; display: grid; grid-template-columns: repeat(4,1fr); background: rgba(16,43,35,.97); border-top: 1px solid rgba(224,197,111,.24); backdrop-filter: blur(12px); }
  .mobile-nav-item { color: #bdcbbf; text-align: center; border-radius: 0; padding: 14px 4px; font-size: 12px; }
  .mobile-nav-item.active { color: var(--gold); background: rgba(224,197,111,.07); }
}

@media (max-width: 520px) {
  .summary-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .transaction-row { gap: 10px; }
  .tx-icon { width: 35px; height: 35px; }
  .tx-amount { font-size: 13px; }
}

/* Rycco v1.3 — parcelamentos, cartões e fluxo de lançamento */
.form-first { margin-bottom: 2px; }
.payment-toggle { align-self: end; }
.payment-btn {
  border: 1px solid #cfc6a9; border-radius: 12px; padding: 13px; background: white; color: #54594e; font-weight: 800;
}
.payment-btn.active { background: var(--green-900); border-color: var(--green-900); color: var(--gold); }
.installment-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  padding: 16px; border-radius: 16px; border: 1px dashed #b9ab7b; background: rgba(224,197,111,.08);
}
.installment-preview { color: var(--muted); font-size: 13px; line-height: 1.5; }
.installment-preview strong { color: var(--ink); }
.notice.mini { margin-top: 0; padding: 12px 14px; font-size: 13px; }
.installment-summary-grid { margin-bottom: 18px; }
.installment-group-list { display: grid; gap: 12px; }
.installment-card { border: 1px solid #d8d0b6; border-radius: 16px; background: #fffdf5; overflow: hidden; }
.installment-card-head { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 16px; }
.installment-card-main strong { display: block; font-size: 16px; }
.installment-card-main span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.installment-card-side { text-align: right; }
.installment-card-side strong { display: block; }
.installment-card-side span { color: var(--muted); font-size: 12px; }
.installment-progress { height: 6px; background: #e7dfc5; }
.installment-progress > div { height: 100%; background: var(--green-700); }
.installment-card details { border-top: 1px solid #e2dbc2; }
.installment-card summary { padding: 12px 16px; cursor: pointer; color: var(--green-900); font-weight: 700; font-size: 13px; }
.installment-parts { padding: 0 16px 14px; display: grid; gap: 7px; }
.installment-part { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; font-size: 12px; color: var(--muted); }
.installment-part strong { color: var(--ink); }
.status-pill { border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; background: #ebe4c9; color: #6c674f; }
.status-pill.future { background: rgba(224,197,111,.20); color: #806919; }
.installment-actions { padding: 0 16px 16px; display: flex; justify-content: flex-end; }
.tx-badge { display: inline-block; margin-left: 6px; border: 1px solid #d2c7a5; border-radius: 999px; padding: 2px 6px; font-size: 10px; color: #756b49; vertical-align: 1px; }
.scheduled-text { color: #927b2d; }

@media (max-width: 820px) {
  .mobile-nav { grid-template-columns: repeat(5, 1fr); }
  .installment-fields { grid-template-columns: 1fr; }
  .installment-card-head { grid-template-columns: auto minmax(0,1fr); }
  .installment-card-side { grid-column: 2; text-align: left; }
}
@media (max-width: 520px) {
  .installment-part { grid-template-columns: 1fr auto; }
  .installment-part .status-pill { grid-column: 1 / -1; justify-self: start; }
  .mobile-nav-item { font-size: 10px; }
}

/* Cadastro de cartões */
.card-form { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(110px, .7fr) minmax(110px, .7fr) auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.card-add-btn { min-height: 48px; }
.card-chip > span:first-child { display: grid; gap: 3px; }
.card-chip > span:first-child strong { font-size: 14px; }
.card-chip > span:first-child small { color: var(--muted); font-size: 11px; }
@media (max-width: 820px) { .card-form { grid-template-columns: 1fr 1fr; } .card-form .field:first-child, .card-add-btn { grid-column: 1 / -1; } }
@media (max-width: 520px) { .card-form { grid-template-columns: 1fr; } .card-form .field:first-child, .card-add-btn { grid-column: auto; } }


/* Rycco v3.1 — autenticação em nuvem e confirmação de e-mail */
.auth-locked { overflow: hidden; }
.auth-locked .app-shell,
.auth-locked .mobile-nav { display: none !important; }
.auth-screen {
  min-height: 100svh;
  background: #f4efdf;
  color: var(--ink);
  display: grid;
  place-items: stretch;
}
.auth-layout { min-height: 100svh; display: grid; grid-template-columns: minmax(360px, .95fr) minmax(520px, 1.05fr); }
.auth-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(34px, 5vw, 72px);
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 12%, rgba(224,197,111,.16), transparent 26%),
    radial-gradient(circle at 85% 85%, rgba(224,197,111,.10), transparent 30%),
    linear-gradient(145deg, #0f2d24, #173f32 60%, #0d2820);
  color: var(--cream);
}
.auth-brand-panel::after {
  content: "R";
  position: absolute;
  right: -5vw;
  bottom: -12vw;
  font: 700 min(46vw, 620px)/.8 Georgia, serif;
  color: rgba(224,197,111,.035);
  pointer-events: none;
}
.auth-brand-lockup { display: flex; align-items: center; gap: 13px; position: relative; z-index: 1; }
.auth-mark { width: 48px; height: 48px; font-size: 23px; }
.auth-brand-name { color: var(--cream); font-size: 24px; }
.auth-brand-copy { max-width: 560px; position: relative; z-index: 1; }
.auth-eyebrow { color: var(--gold); }
.auth-brand-copy h1 { margin: 14px 0 20px; font-family: Georgia, serif; font-weight: 500; font-size: clamp(44px, 5.2vw, 76px); line-height: .98; letter-spacing: -.035em; }
.auth-brand-copy p { max-width: 500px; color: #c5d0c8; font-size: clamp(16px, 1.35vw, 19px); line-height: 1.7; }
.auth-brand-foot { position: relative; z-index: 1; display: flex; align-items: center; gap: 9px; color: #9fb0a5; font-size: 12px; }
.auth-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 5px rgba(224,197,111,.09); }
.auth-form-panel { display: grid; place-items: center; padding: clamp(28px, 6vw, 90px); background: linear-gradient(135deg, #f8f4e8, #eee6cf); }
.auth-card { width: min(100%, 470px); }
.auth-panel h2 { margin: 7px 0 8px; font-family: Georgia, serif; font-size: clamp(32px, 4vw, 46px); font-weight: 500; letter-spacing: -.025em; color: var(--green-950); }
.auth-intro { margin: 0 0 26px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 14px; }
.auth-form .field input { background: rgba(255,255,255,.72); }
.check-row { display: flex; align-items: center; gap: 9px; color: #62675c; font-size: 13px; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--green-900); }
.auth-submit { min-height: 50px; margin-top: 2px; }
.auth-error { border-left: 3px solid var(--expense); background: rgba(161,63,49,.08); color: #7d3027; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.auth-success { border-left: 3px solid var(--income); background: rgba(44,115,100,.09); color: #275f53; border-radius: 10px; padding: 14px 15px; font-size: 13px; line-height: 1.55; }
.auth-confirm-icon { width: 54px; height: 54px; margin: 18px 0 12px; border-radius: 50%; display: grid; place-items: center; background: var(--green-900); color: var(--gold); font-size: 26px; font-weight: 900; box-shadow: 0 0 0 7px rgba(22,59,47,.08); }
.auth-confirm-actions { display: grid; gap: 10px; margin-top: 18px; }
.auth-resend { width: 100%; }
.auth-local-note { margin-top: 28px; padding-top: 20px; border-top: 1px solid #d6ccb0; display: grid; gap: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.auth-local-note strong { color: var(--green-900); }
.hero-controls { display: flex; align-items: end; gap: 12px; }
.user-pill { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 7px 8px 7px 10px; border: 1px solid rgba(224,197,111,.22); border-radius: 14px; background: rgba(255,255,255,.055); }
.user-avatar { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--gold); color: var(--green-950); font-weight: 900; }
.user-copy { display: grid; min-width: 88px; }
.user-copy small { color: #9fb0a5; font-size: 10px; }
.user-copy strong { color: var(--cream); max-width: 130px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.logout-btn { border: 0; border-left: 1px solid rgba(224,197,111,.18); padding: 9px 8px 9px 13px; background: transparent; color: var(--gold); font-weight: 800; font-size: 12px; }
.change-password-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.account-panel { margin-top: 18px; }
.sidebar-foot strong { color: var(--gold); font-weight: 700; }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: 250px; padding: 32px 26px; }
  .auth-brand-copy h1 { font-size: 42px; }
  .auth-brand-copy p { margin-bottom: 0; }
  .auth-brand-foot { display: none; }
  .auth-form-panel { padding: 32px 22px 48px; }
  .hero-controls { margin-top: 20px; align-items: stretch; flex-direction: column; }
  .user-pill, .period-control { width: 100%; box-sizing: border-box; }
  .user-copy { flex: 1; }
  .change-password-form { grid-template-columns: 1fr 1fr; }
  .change-password-form .field:first-child, .change-password-form button { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .auth-brand-panel { min-height: 210px; }
  .auth-brand-lockup { margin-bottom: 30px; }
  .auth-brand-copy h1 { font-size: 36px; }
  .auth-brand-copy p { font-size: 14px; }
  .auth-form-panel { place-items: start stretch; }
  .change-password-form { grid-template-columns: 1fr; }
  .change-password-form .field:first-child, .change-password-form button { grid-column: auto; }
}
