:root {
  --ink: #17211d;
  --muted: #66736d;
  --green-950: #10221b;
  --green-800: #244d3e;
  --green-600: #3f7f65;
  --green-100: #e8f1ec;
  --lime: #c8e56d;
  --sand: #f4f1e9;
  --paper: #fffdf8;
  --line: #dfe5e1;
  --danger: #b5403c;
  --shadow: 0 16px 45px rgba(26, 48, 39, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--sand);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, label.file-button { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 78px;
  padding: 15px max(24px, calc((100vw - 1440px) / 2));
  background: var(--green-950);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-wrap { display: flex; align-items: center; gap: 13px; }
.brand-logo {
  display: block;
  width: auto;
  height: auto;
  object-fit: contain;
  flex: 0 0 auto;
}
.header-logo {
  max-width: clamp(54px, 7vw, 82px);
  max-height: 58px;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.2));
}
.login-logo {
  max-width: clamp(86px, 28vw, 132px);
  max-height: 98px;
  filter: drop-shadow(0 10px 22px rgba(16,34,27,.16));
}
.brand { font-weight: 850; letter-spacing: .13em; font-size: 18px; }
.brand-subtitle { color: #afbeb8; font-size: 12px; margin-top: 3px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.button {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 750;
  font-size: 13px;
  transition: transform .15s, background .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.button:hover { transform: translateY(-1px); }
.button-ghost { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,.22); }
.button-primary { background: var(--lime); color: var(--green-950); padding: 14px 18px; }
.button-primary:hover { background: #d4ed88; }
.button-danger { background: var(--danger); color: white; }
.button-full { width: 100%; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.button:disabled { opacity: .55; cursor: wait; transform: none; }

.container { max-width: 1440px; margin: 0 auto; padding: 42px 24px 52px; }
.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 26px; }
.eyebrow { color: var(--green-600); font-size: 11px; font-weight: 850; letter-spacing: .16em; margin: 0 0 9px; }
h1 { font-family: Georgia, serif; font-size: clamp(34px, 4vw, 57px); line-height: 1; letter-spacing: -.035em; margin: 0 0 14px; font-weight: 500; }
.intro-copy { color: var(--muted); max-width: 790px; margin: 0; line-height: 1.6; }
.intro-copy strong { color: var(--ink); }
.period-filter { min-width: 230px; }
.period-filter label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 7px; }

select, input, textarea {
  width: 100%;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus, textarea:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(63,127,101,.13); }
textarea { resize: vertical; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 34px;
}
.summary-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 19px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.summary-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.summary-card strong {
  font-family: Georgia, serif;
  font-size: clamp(21px, 2vw, 29px);
  font-weight: 500;
  white-space: nowrap;
}
.summary-card small { color: #8a948f; font-size: 10px; line-height: 1.35; }
.summary-card.dark { background: var(--green-950); color: white; border-color: var(--green-950); }
.summary-card.dark span, .summary-card.dark small { color: #b8c5c0; }
.summary-card.highlight { border-top: 4px solid var(--lime); padding-top: 16px; }
.summary-card.general-cost { background: #f7f0df; border-color: #eadcc0; }
.summary-card.personal { background: #eef5d6; border-color: #d9e7a9; }
.summary-card.robson { background: var(--green-100); border-color: #cee1d6; }

.section-heading {
  margin: 8px 0 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.section-heading h2 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: clamp(25px, 3vw, 36px);
  font-weight: 500;
}
.section-heading p:not(.eyebrow) {
  color: var(--muted);
  margin: 7px 0 0;
  line-height: 1.55;
  max-width: 760px;
}
.cost-section-heading { margin-top: 38px; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(350px, 440px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-panel { padding: 27px; }
.records-panel { padding: 27px; min-height: 630px; }
.cost-records-panel { min-height: 500px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.panel-heading h2 { margin: 0; font-family: Georgia, serif; font-weight: 500; font-size: 26px; }
.text-button { border: 0; background: transparent; color: var(--green-600); cursor: pointer; padding: 5px; font-weight: 700; font-size: 12px; }
.hidden { display: none !important; }
.field { display: block; margin-bottom: 15px; }
.field > span { display: block; color: #52605a; font-size: 12px; font-weight: 700; margin-bottom: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.money-field { position: relative; }
.money-field::after { content: "R$"; position: absolute; right: 12px; top: 37px; font-size: 10px; color: #8a948f; pointer-events: none; }

.calculation-box { background: var(--green-950); color: white; border-radius: 13px; padding: 17px; margin: 7px 0 16px; }
.calculation-box > div { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.calculation-box span { color: #afbeb8; font-size: 11px; }
.calculation-box strong { font-size: 14px; }
.calculation-main { padding: 11px 0; margin: 8px 0 10px; border-top: 1px solid rgba(255,255,255,.12); border-bottom: 1px solid rgba(255,255,255,.12); }
.calculation-main strong { color: var(--lime); font-size: 20px; }
.calculation-box p { margin: 0; color: #afbeb8; font-size: 10px; line-height: 1.45; }

.records-heading { align-items: center; }
.search-field { width: min(280px, 46%); }
.search-field input { background: #f8f7f2; }
.records-list { display: flex; flex-direction: column; gap: 11px; }
.record-card { border: 1px solid var(--line); border-radius: 13px; padding: 17px 18px; transition: border-color .15s, transform .15s; }
.record-card:hover { border-color: #bacbc3; transform: translateY(-1px); }
.record-top { display: flex; justify-content: space-between; gap: 18px; }
.record-title { min-width: 0; }
.record-title h3 { margin: 0 0 3px; font-size: 15px; overflow-wrap: anywhere; }
.record-title p { color: var(--muted); margin: 0; font-size: 12px; overflow-wrap: anywhere; }
.record-amount { text-align: right; white-space: nowrap; }
.record-amount strong { font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.record-amount small { display: block; color: var(--muted); margin-top: 2px; }
.record-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 14px; margin: 13px 0; color: var(--muted); font-size: 11px; }
.status, .cost-category { border-radius: 30px; padding: 4px 8px; font-weight: 750; }
.status-pendente { background: #fff0cc; color: #80601d; }
.status-recebido { background: #e4f1eb; color: #2a674f; }
.cost-category { background: #f1ead8; color: #725f36; }
.record-split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.record-split.two-columns { grid-template-columns: repeat(2, 1fr); }
.record-split div { background: #f7f7f2; border-radius: 8px; padding: 9px; }
.record-split span { color: var(--muted); font-size: 9px; display: block; margin-bottom: 3px; }
.record-split strong { font-size: 12px; }
.cost-card { border-left: 4px solid #d9c898; }
.negative { color: var(--danger) !important; }
.record-notes { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 11px 0 0; white-space: pre-wrap; }
.record-actions { display: flex; gap: 4px; justify-content: flex-end; margin-top: 8px; }
.icon-button { border: 0; background: transparent; color: var(--green-600); cursor: pointer; padding: 5px 8px; font-size: 11px; font-weight: 750; }
.icon-button.delete { color: var(--danger); }

.empty-state { min-height: 390px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin: 14px 0 5px; }
.empty-state p { margin: 0; font-size: 13px; }
.empty-icon { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin: auto; background: var(--green-100); color: var(--green-600); font-size: 28px; }

.method-note {
  margin-top: 28px;
  padding: 17px 20px;
  border: 1px dashed #b8c6bf;
  border-radius: 12px;
  display: flex;
  gap: 22px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.method-note strong { color: var(--ink); white-space: nowrap; }

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--green-950);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

dialog { border: 0; border-radius: 16px; padding: 0; max-width: 420px; color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(9, 20, 16, .55); backdrop-filter: blur(2px); }
.dialog-content { padding: 27px; }
.dialog-content h2 { margin: 0 0 10px; font-family: Georgia, serif; font-weight: 500; }
.dialog-content p { color: var(--muted); line-height: 1.55; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 23px; }
.dialog-actions .button-ghost { color: var(--ink); border-color: var(--line); }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background:
    radial-gradient(circle at 15% 10%, rgba(200,229,109,.24), transparent 28%),
    linear-gradient(145deg, var(--green-950), #1d4033 55%, #315b49);
}
.login-card {
  width: min(100%, 460px);
  background: var(--paper);
  border-radius: 22px;
  padding: 34px;
  box-shadow: 0 30px 90px rgba(0,0,0,.24);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; }
.brand-dark { color: var(--green-950); }
.login-subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }
.login-title { font-size: clamp(32px, 8vw, 46px); margin-bottom: 14px; }
.login-copy { color: var(--muted); line-height: 1.55; margin: 0 0 24px; }
.config-warning, .form-error {
  border-radius: 10px;
  padding: 12px 13px;
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.45;
}
.config-warning { background: #fff3d9; color: #755514; border: 1px solid #eed59c; }
.form-error { background: #fbe7e6; color: #8e302c; border: 1px solid #efc2bf; }
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #c9d5d0;
  font-size: 11px;
  padding: 0 5px;
}
.sync-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e3b344;
  box-shadow: 0 0 0 3px rgba(227,179,68,.14);
}
.sync-status.online::before { background: #8fca75; box-shadow: 0 0 0 3px rgba(143,202,117,.14); }
.sync-status.error::before { background: #e77b75; box-shadow: 0 0 0 3px rgba(231,123,117,.14); }
.loading-spinner {
  width: 40px;
  height: 40px;
  margin: auto;
  border: 4px solid var(--green-100);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1250px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .workspace-grid { grid-template-columns: 380px minmax(0, 1fr); }
}

@media (max-width: 850px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .records-panel { min-height: 400px; }
  .intro { align-items: flex-start; flex-direction: column; }
  .period-filter { width: 100%; }
  .method-note { flex-direction: column; align-items: flex-start; gap: 5px; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 15px 18px; }
  .header-logo { max-width: 62px; max-height: 48px; }
  .top-actions { width: 100%; }
  .top-actions .button { flex: 1; padding: 9px; }
  .container { padding: 30px 14px 40px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card { min-height: 116px; padding: 15px; }
  .form-panel, .records-panel { padding: 19px 15px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .records-heading { align-items: flex-start; flex-direction: column; }
  .search-field { width: 100%; }
  .record-split, .record-split.two-columns { grid-template-columns: 1fr; }
  .record-top { flex-direction: column; gap: 10px; }
  .record-amount { text-align: left; }
  .login-card { padding: 27px 20px; }
  .login-brand { align-items: center; gap: 12px; margin-bottom: 26px; }
  .login-logo { max-width: 92px; max-height: 70px; }
  .sync-status { width: 100%; }
}
