@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #211814;
  --muted: #74655e;
  --paper: #fffaf7;
  --panel: #ffffff;
  --line: #eadbd2;
  --deep: #e36c2f;
  --deep-2: #b84b18;
  --sky: #ffc08f;
  --sky-soft: #fff0e4;
  --mint: #e5f4ea;
  --green: #176b52;
  --coral-soft: #fff0ed;
  --coral: #aa4d3d;
  --sand: #fff8e9;
  --shadow: 0 16px 40px rgba(71, 37, 22, 0.09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: 'Atkinson Hyperlegible', Inter, system-ui, -apple-system, sans-serif; font-size: 16px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.login-screen { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--paper); }
.login-screen.is-hidden { display: none; }
.login-card { width: min(100%, 390px); padding: 34px 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); text-align: center; }
.brand-logo { display: block; object-fit: contain; }
.login-logo { width: 180px; height: 180px; margin: 0 auto 10px; }
.login-card h1 { margin-bottom: 10px; font-size: 29px; }
.login-card > p:not(.eyebrow) { margin-bottom: 24px; color: var(--muted); line-height: 1.4; }
.login-card .field { text-align: left; }
.login-card .primary-button { margin-top: 12px; }
.login-error { min-height: 18px; margin: 11px 0 0; color: var(--coral); font-size: 13px; }
.primary-button:disabled { cursor: wait; opacity: .65; }
.app-shell.is-locked { display: none; }
.app-shell { max-width: 1180px; margin: 0 auto; padding: 22px 22px 46px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 46px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.header-logo { width: 54px; height: 54px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--sky); background: #191310; font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 600; letter-spacing: -1px; box-shadow: 4px 4px 0 var(--deep); }
.eyebrow { margin: 0 0 7px; color: var(--deep); font-family: 'IBM Plex Mono', monospace; font-size: 10px; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 22px; line-height: 1; letter-spacing: -.02em; }
h2 { max-width: 560px; margin-bottom: 10px; font-size: clamp(36px, 6vw, 62px); line-height: .98; letter-spacing: -.055em; }
h3 { margin-bottom: 0; font-size: 24px; line-height: 1.05; letter-spacing: -.03em; }
h4 { margin-bottom: 7px; font-size: 18px; }
.top-actions { display: flex; align-items: center; gap: 18px; }
.sync-status { color: var(--muted); font-size: 11px; white-space: nowrap; }
.sync-status.success { color: var(--green); }
.sync-status.error { color: var(--coral); }
.ghost-button, .text-button { border: 0; color: var(--deep); background: transparent; font-weight: 700; }
.ghost-button { text-decoration: none; }
.ghost-button { padding: 9px 0; font-size: 14px; border-bottom: 1px solid var(--sky); }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.hero-copy { max-width: 520px; margin-bottom: 0; color: var(--muted); font-size: 18px; line-height: 1.35; }
.today-chip { flex: none; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--deep); background: white; font-family: 'IBM Plex Mono', monospace; font-size: 11px; }
.balance-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.balance-card { min-height: 155px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.stone-card { border-top: 4px solid var(--deep); }
.dg-card { border-top: 4px solid #6d9eb1; }
.cash-card { border-top: 4px solid #2e7d57; }
.pix-card { border-top: 4px solid #7c5bb5; }
.voucher-card { border-top: 4px solid #c58c2f; }
.total-card { border-top: 4px solid #d3a447; background: var(--sand); }
.card-topline, .balance-meta { display: flex; align-items: center; gap: 8px; }
.card-topline { font-weight: 700; }
.card-label { margin-left: auto; color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: .08em; }
.account-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--deep); }
.stone-dot { background: var(--deep); }
.dg-dot { background: #6d9eb1; }
.cash-dot { background: #2e7d57; }
.pix-dot { background: #7c5bb5; }
.voucher-dot { background: #c58c2f; }
.total-dot { background: #d3a447; }
.balance-value { display: block; margin: 22px 0 16px; color: var(--deep-2); font-family: 'IBM Plex Mono', monospace; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.07em; }
.balance-breakdown { display: flex; gap: 15px; margin: -3px 0 15px; color: var(--muted); font-size: 11px; }
.balance-breakdown span { display: flex; gap: 4px; align-items: baseline; }
.balance-breakdown span:first-child strong { color: var(--green); }
.balance-breakdown span:last-child strong { color: var(--coral); }
.balance-breakdown strong { font-family: 'IBM Plex Mono', monospace; font-size: 11px; }
.balance-meta { justify-content: space-between; color: var(--muted); font-size: 13px; }
.text-button { padding: 0; font-size: 13px; }
.text-button:hover, .ghost-button:hover { color: #0c2e3a; }
.workspace-grid { display: grid; grid-template-columns: 1.35fr .95fr; align-items: start; gap: 22px; margin-bottom: 50px; }
.panel { padding: 26px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.entry-panel { position: relative; overflow: hidden; }
.entry-panel::after { content: ''; position: absolute; width: 180px; height: 180px; right: -85px; bottom: -95px; border-radius: 50%; background: var(--sky-soft); pointer-events: none; }
.panel-heading, .history-heading { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 25px; }
.step-badge { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; color: white; background: var(--deep); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
.step-badge.muted { color: var(--deep); background: var(--sky-soft); }
fieldset { min-width: 0; padding: 0; border: 0; }
legend { margin-bottom: 9px; font-size: 14px; font-weight: 700; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.segment { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: #fff; font-weight: 700; transition: all .16s ease; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment.is-selected { border-color: var(--deep); color: var(--deep); background: var(--sky-soft); box-shadow: inset 0 0 0 1px var(--deep); }
.sign { font-family: 'IBM Plex Mono', monospace; font-size: 18px; }
.positive { color: var(--green); }
.negative { color: var(--coral); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.optional, .required { color: var(--muted); font-size: 11px; font-weight: 400; }
.required { color: var(--coral); }
input, select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; outline: none; color: var(--ink); background: white; transition: border .16s, box-shadow .16s; }
input:focus, select:focus { border-color: var(--deep); box-shadow: 0 0 0 3px rgba(162, 213, 242, .34); }
.money-input { display: flex; align-items: center; min-height: 46px; padding-left: 12px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.money-input:focus-within { border-color: var(--deep); box-shadow: 0 0 0 3px rgba(162, 213, 242, .34); }
.money-input > span { color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 13px; }
.money-input input { min-height: 43px; padding-left: 7px; border: 0; box-shadow: none !important; font-family: 'IBM Plex Mono', monospace; font-weight: 600; }
.primary-button, .secondary-button { width: 100%; min-height: 48px; border-radius: 12px; font-weight: 700; transition: transform .16s, box-shadow .16s, background .16s; }
.primary-button { margin-top: 20px; border: 0; color: white; background: var(--deep); box-shadow: 0 6px 0 #0b3342; }
.primary-button:hover { background: var(--deep-2); transform: translateY(-1px); box-shadow: 0 7px 0 #0b3342; }
.button-plus { margin-right: 4px; font-size: 20px; vertical-align: -1px; }
.secondary-button { border: 1px solid var(--deep); color: var(--deep); background: white; }
.secondary-button:hover { background: var(--sky-soft); }
.save-note, .small-note { margin: 15px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.save-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--green); }
.form-error { min-height: 17px; margin: 12px 0 -4px; color: var(--coral); font-size: 13px; }
.panel-copy { margin: -10px 0 23px; color: var(--muted); line-height: 1.4; }
.starting-balance-list { display: grid; gap: 11px; margin-bottom: 20px; }
.starting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); font-weight: 700; }
.starting-row > span { display: flex; align-items: center; gap: 8px; }
.money-input.compact { width: 150px; }
.history-section { padding-top: 5px; }
.closing-section { margin-top: 26px; scroll-margin-top: 20px; }
.closing-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 22px 0 17px; }
.closing-summary > div { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--sky-soft); }
.closing-summary span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.closing-summary strong { color: var(--deep-2); font-family: 'IBM Plex Mono', monospace; font-size: 17px; }
.closing-save-button { max-width: 300px; }
.saved-closings { display: grid; gap: 8px; margin-top: 20px; }
.closing-empty { margin: 0; color: var(--muted); font-size: 13px; }
.closing-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 14px; border-top: 1px solid var(--line); }
.closing-row div { display: grid; gap: 4px; }
.closing-row span { color: var(--muted); font-size: 12px; }
.closing-row > strong { color: var(--deep-2); font-family: 'IBM Plex Mono', monospace; white-space: nowrap; }
.history-heading { align-items: end; margin-bottom: 16px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-tab { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: white; font-size: 13px; }
.filter-tab.is-active { border-color: var(--deep); color: white; background: var(--deep); }
.history-list { display: grid; gap: 9px; }
.transaction-row { display: grid; grid-template-columns: 90px 1fr auto auto; align-items: center; gap: 14px; min-height: 69px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.transaction-date { color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
.transaction-main { min-width: 0; }
.transaction-description { overflow: hidden; margin: 0 0 4px; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.transaction-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.account-tag { padding: 3px 7px; border-radius: 999px; color: var(--deep); background: var(--sky-soft); font-size: 11px; }
.transaction-amount { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 600; white-space: nowrap; }
.transaction-amount.in { color: var(--green); }
.transaction-amount.out { color: var(--coral); }
.delete-button { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 20px; }
.delete-button:hover { color: var(--coral); background: var(--coral-soft); }
.empty-state { padding: 56px 20px; border: 1px dashed #b8ced7; border-radius: var(--radius); color: var(--muted); background: rgba(255,255,255,.6); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 13px; color: var(--deep); background: var(--sky-soft); font-family: 'IBM Plex Mono', monospace; font-size: 24px; }
.empty-state p { max-width: 390px; margin: 0 auto; line-height: 1.4; }
.footer-note { margin-top: 44px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-align: center; }

@media (max-width: 820px) {
  .app-shell { padding: 18px 15px 34px; }
  .topbar { margin-bottom: 35px; }
  .hero-row { display: block; }
  .today-chip { display: inline-block; margin-top: 18px; }
  .balance-grid { grid-template-columns: 1fr; gap: 10px; }
  .balance-card { min-height: auto; padding: 17px; }
  .balance-value { margin: 16px 0 12px; }
  .workspace-grid { grid-template-columns: 1fr; gap: 15px; margin-bottom: 38px; }
  .panel { padding: 21px 17px; }
  .closing-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  h2 { font-size: 45px; }
  .topbar { align-items: start; }
  .top-actions { align-items: end; flex-direction: column; gap: 6px; }
  .ghost-button { font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .transaction-row { grid-template-columns: 1fr auto; gap: 5px 12px; }
  .transaction-date { grid-column: 1 / -1; }
  .transaction-main { min-width: 0; }
  .transaction-amount { grid-column: 2; grid-row: 2; }
  .delete-button { grid-column: 2; grid-row: 1; justify-self: end; }
  .starting-row { align-items: start; }
  .money-input.compact { width: 136px; }
}
