:root {
  --primary: #006b9f;
  --primary-strong: #00577f;
  --primary-soft: #eaf5ff;
  --green: #008a5b;
  --green-soft: #e9faf2;
  --red: #c72727;
  --red-soft: #fff0ef;
  --amber: #b66a00;
  --amber-soft: #fff6dc;
  --ink: #102239;
  --muted: #617083;
  --line: #dfe7f1;
  --canvas: #f5f8fd;
  --surface: #fff;
  --shadow: 0 10px 32px rgba(23, 48, 78, .07);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 76px; padding: 12px clamp(16px, 3vw, 40px);
  display: flex; align-items: center; gap: 26px; background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 196px; color: var(--ink); text-decoration: none; }
.brand img { display: block; width: 132px; height: 32px; object-fit: contain; object-position: left center; }
.brand span { padding-left: 11px; border-left: 1px solid var(--line); color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.main-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-item { padding: 10px 13px; border: 0; border-radius: 10px; background: transparent; color: #46576b; font-size: .92rem; }
.nav-item:hover, .nav-item.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.top-actions, .heading-actions { display: flex; gap: 8px; }
.mobile-menu { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: white; }

.btn { min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(23,48,78,.11); }
.btn-income { color: white; background: var(--green); }
.btn-expense { color: var(--red); background: var(--red-soft); border-color: #ffd8d4; }
.btn-primary { color: white; background: var(--primary); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { color: var(--ink); background: white; border-color: var(--line); }
.btn-logout { color: var(--muted); background: white; border-color: var(--line); }
.logout-form { display: flex; margin: 0; }

main { width: min(1500px, 100%); margin: 0 auto; padding: 28px clamp(16px, 3vw, 40px) 60px; }
.view { display: none; }
.view.active { display: block; animation: appear .18s ease-out; }
@keyframes appear { from { opacity: .2; transform: translateY(3px); } }
.page-heading { min-height: 68px; margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.65rem, 3vw, 2.2rem); letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 1.08rem; letter-spacing: -.02em; }
.month-picker { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .83rem; font-weight: 700; }
.month-picker input, .filters input, .filters select, .filters button { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); padding: 0 12px; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.summary-grid.compact { grid-template-columns: repeat(2, minmax(250px, 380px)); }
.summary-card { position: relative; overflow: hidden; min-height: 145px; padding: 21px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 2px 8px rgba(23,48,78,.035); }
.summary-card::after { content: ""; position: absolute; width: 84px; height: 84px; border-radius: 50%; right: -28px; top: -28px; opacity: .7; }
.summary-card span { display: block; margin-bottom: 16px; color: var(--muted); font-size: .77rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.summary-card strong { display: block; margin-bottom: 8px; font-size: clamp(1.45rem, 2.4vw, 2rem); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.summary-card small { color: var(--muted); }
.summary-card.income strong { color: var(--green); }
.summary-card.income::after { background: var(--green-soft); }
.summary-card.expense strong, .summary-card.overdue strong { color: var(--red); }
.summary-card.expense::after, .summary-card.overdue::after { background: var(--red-soft); }
.summary-card.balance strong { color: var(--primary); }
.summary-card.balance::after { background: var(--primary-soft); }
.summary-card.neutral::after { background: #eef1f6; }

.panel { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { padding: 19px 20px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.panel-heading p { margin: 0; color: var(--muted); font-size: .84rem; }
.text-action { padding: 8px; border: 0; background: transparent; color: var(--primary); font-weight: 700; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { padding: 12px 16px; background: #f7f9fc; color: var(--muted); font-size: .72rem; letter-spacing: .045em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 16px; border-top: 1px solid #edf1f6; vertical-align: middle; }
tbody tr:hover { background: #f9fbfe; }
.amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.title-cell strong { display: block; margin-bottom: 3px; }
.title-cell small { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 27px; padding: 4px 9px; border-radius: 999px; font-size: .73rem; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.open { color: var(--primary); background: var(--primary-soft); }
.badge.paid { color: var(--green); background: var(--green-soft); }
.badge.overdue { color: var(--red); background: var(--red-soft); }
.badge.sent { margin-left: 5px; color: var(--amber); background: var(--amber-soft); }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--primary); }
.row-button:hover { background: var(--primary-soft); }
.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { margin-bottom: 6px; color: var(--ink); }

.filters { padding: 12px; display: grid; grid-template-columns: minmax(230px, 1fr) 190px 200px 200px auto; gap: 10px; box-shadow: none; }
.compact-field { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; min-height: 42px; padding-left: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: white; font-size: .77rem; font-weight: 700; }
.compact-field input { min-width: 0; border: 0; padding-left: 0; }
.filter-clear { color: var(--primary) !important; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.register-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.simple-list-panel { margin: 0; }
.mini-add { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 1.3rem; font-weight: 700; }
.simple-list { min-height: 180px; margin: 0; padding: 8px 20px 18px; list-style: none; }
.simple-list li { padding: 12px 2px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid #edf1f6; font-size: .9rem; }
.simple-list li:last-child { border-bottom: 0; }
.simple-list small { color: var(--muted); }
.contact-data { display: grid; gap: 4px; min-width: 0; }
.contact-data strong { font-size: .9rem; }
.contact-data small { display: block; overflow-wrap: anywhere; }
.list-edit { flex: 0 0 auto; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; color: var(--primary); background: white; }

.modal { width: min(900px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 20px; color: var(--ink); box-shadow: 0 24px 80px rgba(7,26,48,.24); }
.modal::backdrop { background: rgba(12,28,48,.52); backdrop-filter: blur(3px); }
.modal form { padding: 25px; }
.modal-heading { margin-bottom: 22px; display: flex; align-items: flex-start; justify-content: space-between; }
.modal-heading h2 { font-size: 1.45rem; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f1f4f8; color: var(--muted); font-size: 1.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid label, .small-modal label { display: flex; flex-direction: column; gap: 7px; color: #34475d; font-size: .82rem; font-weight: 700; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input:not([type="checkbox"]), .form-grid select, .small-modal input, .small-modal select, .small-modal textarea { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; outline: none; }
.small-modal textarea { padding-top: 11px; resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .small-modal input:focus, .small-modal select:focus, .small-modal textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,107,159,.12); }
.form-grid .check-line { flex-direction: row; align-items: center; font-weight: 600; }
.check-line input { width: 18px; height: 18px; accent-color: var(--primary); }
.modal-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 9px; }
.small-modal { width: min(480px, calc(100% - 28px)); }
.party-fields { margin-top: 15px; display: grid; gap: 15px; }
.party-fields[hidden] { display: none !important; }
.address-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.address-street { grid-column: 1 / -1; }
.file-button { cursor: pointer; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; padding: 13px 17px; border-radius: 11px; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.report-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 16px; }
.category-report, .overdue-report { min-height: 240px; padding: 8px 20px 20px; }
.category-row { padding: 13px 0; border-bottom: 1px solid #edf1f6; }
.category-row:last-child { border-bottom: 0; }
.category-line { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .86rem; }
.category-line strong { font-variant-numeric: tabular-nums; }
.category-track { height: 8px; overflow: hidden; border-radius: 999px; background: #eef2f7; }
.category-fill { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: var(--primary); }
.category-fill.receita { background: var(--green); }
.category-fill.despesa { background: var(--red); }
.overdue-item { padding: 14px 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; border-bottom: 1px solid #edf1f6; }
.overdue-item:last-child { border-bottom: 0; }
.overdue-item strong { font-size: .88rem; }
.overdue-item span { color: var(--red); font-weight: 700; font-variant-numeric: tabular-nums; }
.overdue-item small { grid-column: 1 / -1; color: var(--muted); }
.report-empty { padding: 46px 0; color: var(--muted); text-align: center; font-size: .88rem; }

.login-page { min-height: 100vh; background: radial-gradient(circle at 12% 8%, rgba(0,175,239,.15), transparent 28rem), linear-gradient(145deg, #f8fbff 0%, #edf5fb 100%); }
.login-shell { width: 100%; min-height: 100vh; padding: 32px 18px; display: grid; place-items: center; }
.login-card { width: min(430px, 100%); padding: clamp(28px, 6vw, 42px); border: 1px solid rgba(0,107,159,.12); border-radius: 22px; background: rgba(255,255,255,.97); box-shadow: 0 24px 70px rgba(16,34,57,.14); }
.login-logo { width: 150px; height: auto; margin-bottom: 34px; }
.login-card h1 { margin-bottom: 10px; }
.login-intro { margin-bottom: 25px; color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 17px; }
.login-form label { display: grid; gap: 8px; color: #34475d; font-size: .88rem; font-weight: 700; }
.login-form input { min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: white; outline: none; }
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,107,159,.12); }
.login-submit { width: 100%; margin-top: 4px; }
.login-submit:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.login-error { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #ffd4cf; border-radius: 10px; color: #9f2525; background: var(--red-soft); font-size: .86rem; line-height: 1.45; }
.login-security { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; line-height: 1.55; }

@media (max-width: 1080px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .main-nav { order: 3; width: 100%; flex-basis: 100%; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .register-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input[type="search"] { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .topbar { justify-content: space-between; }
  .brand { min-width: 0; }
  .brand img { width: 112px; }
  .brand span, .top-actions { display: none; }
  .mobile-menu { display: block; }
  .main-nav { display: none; flex-direction: column; align-items: stretch; padding-top: 8px; }
  .main-nav.open { display: flex; }
  .nav-item { text-align: left; }
  main { padding-top: 20px; }
  .page-heading { align-items: flex-end; }
  .summary-grid, .summary-grid.compact { grid-template-columns: 1fr; }
  .summary-card { min-height: 130px; }
  .filters { grid-template-columns: 1fr; }
  .filters input[type="search"] { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .address-fields { grid-template-columns: 1fr; }
  .address-street { grid-column: auto; }
  .modal form { padding: 20px; }
  .heading-actions .btn { padding: 0 11px; }
  .report-actions { width: 100%; align-items: stretch; }
  .page-heading:has(.report-actions) { align-items: flex-start; flex-direction: column; }
}
