:root {
  color-scheme: light;
  --navy: #0F172A;
  --emerald: #108981;
  --background: #F8FAFC;
  --slate: #475569;
  --muted: #64748B;
  --border: #E2E8F0;
  --mint: #ECF8F6;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--navy);
  background: var(--background);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 1rem; line-height: 1.5; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button, input, select { transition: border-color .15s, background .15s, box-shadow .15s; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--emerald); outline-offset: 4px; }
input:focus, select:focus { outline: none; border-color: var(--emerald); box-shadow: 0 0 0 3px #10898118; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--navy); box-shadow: 0 0 0 2px #0F172A18; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2rem); line-height: 1.3; font-weight: 700; letter-spacing: -.045em; }
h2 { font-size: 1.125rem; font-weight: 650; letter-spacing: -.025em; }
h3 { font-size: 1rem; font-weight: 650; }
[hidden] { display: none !important; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 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; }
.topbar { background: white; border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1264px; padding: 20px 32px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy); font-weight: 700; font-size: 1.125rem; letter-spacing: -.025em; line-height: 1.2; }
.brand-caption { display: block; margin-top: 5px; font-size: .75rem; color: var(--muted); font-weight: 500; letter-spacing: .17em; }
.brand-mark { display: flex; align-items: flex-end; gap: 4px; background: var(--navy); border-radius: 12px; width: 43px; height: 43px; padding: 11px; }
.brand-mark span { width: 4px; border-radius: 2px; background: var(--emerald); height: 9px; }
.brand-mark span:nth-child(2) { height: 15px; background: #58B6AE; }
.brand-mark span:nth-child(3) { height: 21px; background: #9DD8D2; }
.header-meta { display: flex; gap: 9px; align-items: center; color: var(--slate); font-size: .875rem; }
.header-meta .icon { width: 17px; height: 17px; }
.workspace { max-width: 1264px; margin: auto; padding: 34px 32px 20px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.currency-badge { display: flex; gap: 9px; align-items: center; font-size: .875rem; color: var(--slate); }
.currency-badge > span { font-size: .75rem; letter-spacing: .06em; font-weight: 650; color: var(--navy); border: 1px solid var(--border); border-radius: 6px; padding: 4px 7px; background: white; }
.metrics { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.metric { background: white; border: 1px solid var(--border); padding: 22px 24px; border-radius: 16px; min-width: 0; }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric-top h2 { font-size: .875rem; color: var(--slate); font-weight: 550; letter-spacing: 0; }
.metric-icon { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--background); border-radius: 10px; color: var(--slate); }
.metric-icon.income-icon { color: var(--emerald); background: var(--mint); }
.metric-value { font-size: clamp(1.5rem, 3.3vw, 2.3rem); font-weight: 650; letter-spacing: -.055em; line-height: 1.25; margin-top: 11px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric-note { font-size: .875rem; color: var(--muted); margin-top: 9px; }
.income-text { color: var(--emerald); }
.balance-card { color: white; background: var(--navy); border-color: var(--navy); }
.balance-card .metric-top h2, .balance-card .metric-note { color: #CBD5E1; }
.balance-card .metric-icon { color: #8AD6CE; background: #FFFFFF0F; }
.entry-grid { display: grid; grid-template-columns: minmax(320px, 370px) minmax(0, 1fr); gap: 24px; margin-bottom: 24px; }
.panel { background: white; border: 1px solid var(--border); border-radius: 16px; min-width: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.entry-panel { padding: 24px; }
.entry-panel .panel-heading { align-items: center; margin-bottom: 19px; }
.heading-icon { color: var(--emerald); display: flex; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; min-width: 0; }
.field label, .type-field legend { color: var(--slate); font-size: .875rem; font-weight: 550; }
.category-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.text-button { border: 0; background: transparent; color: var(--emerald); padding: 8px 0 8px 8px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: .875rem; font-weight: 550; }
.text-button:hover { color: #0B736C; text-decoration: underline; }
.text-button .icon { width: 15px; height: 15px; }
#category-form { margin-top: 20px; }
.type-field { border: 0; padding: 0; margin: 0 0 17px; min-width: 0; }
.type-field legend { padding: 0; margin-bottom: 8px; }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); padding: 4px; border-radius: 9px; background: var(--background); gap: 4px; }
.type-switch label { position: relative; cursor: pointer; min-width: 0; }
.type-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.type-switch span { display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--slate); font-size: .875rem; border-radius: 6px; padding: 8px 5px; border: 1px solid transparent; }
.type-switch .icon { width: 17px; height: 17px; }
.type-switch input:checked + span { background: white; border-color: var(--border); color: var(--emerald); box-shadow: 0 1px 3px #0F172A0A; font-weight: 650; }
.type-switch input[value="expense"]:checked + span { color: var(--navy); }
.type-switch input:focus-visible + span { outline: 3px solid var(--emerald); outline-offset: 1px; }
input, select { width: 100%; min-width: 0; background: white; color: var(--navy); border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; line-height: 1.35; font-size: .875rem; min-height: 44px; }
input::placeholder { color: var(--muted); }
select { padding-right: 28px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; }
.amount-field { position: relative; }
.amount-field > span { position: absolute; top: 11px; left: 12px; color: var(--slate); font-size: .875rem; }
.amount-field input { padding-left: 29px; }
.primary-button, .secondary-button { border-radius: 8px; padding: 11px 16px; min-height: 44px; font-size: .875rem; font-weight: 600; display: inline-flex; justify-content: center; align-items: center; gap: 7px; }
.primary-button { color: white; background: var(--emerald); border: 1px solid var(--emerald); }
.primary-button:hover { background: #0B736C; border-color: #0B736C; }
.primary-button .icon { width: 17px; height: 17px; }
#movement-form .primary-button { width: 100%; margin-top: 3px; }
.secondary-button { background: white; color: var(--slate); border: 1px solid var(--border); }
.secondary-button:hover { background: var(--background); }
.local-note { display: flex; justify-content: center; align-items: center; gap: 7px; color: var(--muted); font-size: .75rem; margin-top: 15px; }
.local-note .icon { width: 15px; height: 15px; }
.chart-panel { display: flex; flex-direction: column; padding: 24px 26px 0; }
.panel-subtitle { color: var(--muted); font-size: .875rem; margin-top: 4px; }
.small-badge { font-size: .75rem; color: var(--slate); background: var(--background); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; flex-shrink: 0; margin-top: 2px; }
.chart-layout { display: flex; align-items: center; gap: 30px; flex: 1; padding: 24px 0; }
.donut-wrapper { position: relative; width: 240px; max-width: 50%; flex: 0 0 240px; }
#expense-chart { width: 100%; display: block; overflow: visible; }
.donut-track { stroke: #EDF2F6; }
.donut-segment { transform-origin: 120px 120px; transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 7px; pointer-events: none; padding: 45px; text-align: center; }
.donut-center span { font-size: .75rem; color: var(--muted); }
.donut-center strong { font-size: 1.375rem; letter-spacing: -.04em; line-height: 1.2; max-width: 100%; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.chart-empty { flex: 1; }
.empty-icon { display: inline-flex; justify-content: center; align-items: center; width: 43px; height: 43px; border-radius: 12px; background: var(--background); color: var(--slate); margin-bottom: 12px; }
.empty-icon .icon { width: 22px; height: 22px; }
.chart-empty p { font-size: .875rem; color: var(--muted); margin-top: 7px; max-width: 235px; line-height: 1.7; }
.category-legend { list-style: none; padding: 0 5px 0 0; margin: 0; flex: 1; min-width: 0; max-height: 310px; overflow-y: auto; }
.category-legend li { padding: 10px 0; border-bottom: 1px solid #F1F5F9; }
.category-legend li:last-child { border-bottom: 0; }
.legend-line { display: flex; align-items: center; gap: 8px; font-size: .875rem; min-width: 0; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-name { color: var(--slate); flex: 1; overflow-wrap: anywhere; }
.legend-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend-percent { font-size: .75rem; color: var(--muted); margin-left: 17px; margin-top: 3px; }
.chart-footer { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding: 16px 0; color: var(--muted); font-size: .75rem; }
.chart-footer .icon { width: 16px; height: 16px; color: var(--emerald); }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 26px 20px; }
.filters { display: flex; padding: 4px; gap: 3px; border-radius: 8px; background: var(--background); border: 1px solid var(--border); }
.filters button { border: 1px solid transparent; color: var(--slate); background: transparent; font-size: .875rem; padding: 6px 14px; min-height: 36px; border-radius: 5px; }
.filters button.active { color: var(--navy); border-color: var(--border); background: white; box-shadow: 0 1px 3px #0F172A08; font-weight: 600; }
.filters button:hover { color: var(--emerald); }
.history-empty { text-align: center; padding: 23px 20px 39px; border-top: 1px solid #F1F5F9; }
.history-empty p { margin-top: 6px; font-size: .875rem; color: var(--muted); }
.history-empty .empty-icon { background: var(--mint); color: var(--emerald); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; text-align: left; }
thead { background: var(--background); color: var(--muted); }
th { font-weight: 550; font-size: .75rem; padding: 12px 18px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid #F1F5F9; padding: 16px 18px; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 26px; }
th:last-child, td:last-child { padding-right: 26px; width: 62px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #F8FAFC80; }
.date-cell { color: var(--slate); white-space: nowrap; }
.description-cell { font-weight: 550; max-width: 330px; overflow-wrap: anywhere; }
.category-cell { color: var(--slate); }
.type-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; background: #F1F5F9; border-radius: 6px; color: var(--slate); font-size: .75rem; white-space: nowrap; }
.type-badge .icon { width: 13px; height: 13px; }
.type-badge.income { background: var(--mint); color: var(--emerald); }
.amount-column, .amount-cell { text-align: right; }
.amount-cell { font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delete-button { color: var(--muted); border: 0; background: transparent; padding: 11px; display: flex; border-radius: 8px; min-height: 44px; min-width: 44px; }
.delete-button:hover { color: var(--navy); background: #E2E8F0; }
.delete-button .icon { width: 18px; height: 18px; }
.page-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 25px; color: var(--muted); font-size: .75rem; }
.page-footer > span:first-child { color: var(--slate); }
.footer-divider { padding: 0 10px; color: #CBD5E1; }
.form-error { color: var(--navy); background: var(--background); border-left: 3px solid var(--slate); padding: 10px 12px; font-size: .875rem; margin: 0 0 12px; }
.storage-alert { background: white; border: 1px solid var(--slate); border-radius: 10px; padding: 14px 16px; font-size: .875rem; margin-bottom: 20px; }
dialog { max-width: 440px; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: 16px; padding: 0; color: var(--navy); box-shadow: 0 24px 80px #0F172A40; }
dialog::backdrop { background: #0F172A80; backdrop-filter: blur(3px); }
.dialog-content { padding: 28px; }
.dialog-content h2 { font-size: 1.25rem; margin-bottom: 12px; }
.dialog-content p { color: var(--slate); font-size: .875rem; overflow-wrap: anywhere; }
.dialog-note { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 13px 20px; background: var(--navy); color: white; border-radius: 10px; box-shadow: 0 5px 25px #0F172A25; font-size: .875rem; z-index: 10; max-width: calc(100% - 32px); text-align: center; }
@media (min-width: 1600px) { .workspace { padding-top: 45px; } }
@media (max-width: 1080px) {
  .donut-wrapper { flex-basis: 210px; width: 210px; }
  .chart-layout { gap: 18px; }
  .donut-center { padding: 40px; }
  .donut-center strong { font-size: 1.125rem; }
  .small-badge { display: none; }
  .metric { padding: 20px; }
  .entry-grid { grid-template-columns: minmax(305px, 340px) minmax(0, 1fr); gap: 20px; }
  .chart-panel { padding: 24px 20px 0; }
  .legend-line { flex-wrap: wrap; }
  .legend-amount { width: calc(100% - 17px); margin-left: 17px; }
}
@media (max-width: 880px) {
  .topbar-inner { padding: 17px 24px; }
  .workspace { padding: 28px 24px 20px; }
  .entry-grid { grid-template-columns: minmax(290px, 1fr) minmax(0, 1fr); }
  .chart-layout { flex-direction: column; justify-content: center; gap: 16px; }
  .donut-wrapper { flex: 0 0 auto; max-width: 100%; width: 205px; }
  .chart-empty { text-align: center; flex: 0 0 auto; }
  .chart-empty .empty-icon { display: none; }
  .category-legend { width: 100%; flex: 0 0 auto; }
  .legend-line { flex-wrap: nowrap; }
  .legend-amount { width: auto; margin-left: 0; }
  .metrics { gap: 14px; }
  .metric { padding: 16px; }
  .metric-icon { width: 30px; height: 30px; }
  .metric-icon .icon { width: 17px; height: 17px; }
  .currency-badge { font-size: .75rem; }
}
@media (max-width: 680px) {
  .topbar-inner { padding: 15px 18px; }
  .brand { font-size: 1rem; }
  .brand-mark { width: 38px; height: 38px; padding: 9px; }
  .brand-caption { font-size: .75rem; margin-top: 3px; }
  .header-meta { font-size: .75rem; gap: 5px; }
  .header-meta .icon { display: none; }
  .workspace { padding: 24px 16px 20px; }
  .page-heading { align-items: flex-start; margin-bottom: 20px; }
  .currency-badge { font-size: 0; }
  .currency-badge > span { font-size: .75rem; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
  .balance-card { grid-column: 1 / -1; }
  .balance-card .metric-value { font-size: 2.125rem; margin-top: 4px; }
  .metric-value { font-size: clamp(1.25rem, 5vw, 1.75rem); margin-top: 12px; }
  .metric-top h2 { font-size: .875rem; }
  .metrics > :not(.balance-card) .metric-icon { display: none; }
  .metric-note { font-size: .75rem; margin-top: 7px; }
  .entry-grid { grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
  .entry-panel { padding: 21px; }
  input, select { font-size: 1rem; }
  .chart-panel { padding: 21px 21px 0; }
  .chart-layout { flex-direction: row; align-items: center; padding: 26px 0; gap: 20px; }
  .donut-wrapper { width: 180px; flex: 0 0 180px; max-width: 50%; }
  .donut-center { padding: 32px; }
  .donut-center strong { font-size: 1rem; }
  .chart-empty { text-align: left; }
  .chart-empty h3 { font-size: .875rem; }
  .chart-empty p { font-size: .875rem; line-height: 1.6; }
  .legend-line { flex-wrap: wrap; }
  .legend-amount { width: calc(100% - 17px); margin-left: 17px; }
  .history-heading { flex-direction: column; align-items: stretch; gap: 16px; padding: 21px; }
  .filters { align-self: flex-start; }
  .filters button { padding: 7px 16px; }
  .table-wrap { overflow: visible; padding: 0 21px; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  tr { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; gap: 6px 8px; padding: 16px 0; border-top: 1px solid var(--border); align-items: center; }
  td, td:first-child, td:last-child { display: block; border: 0; padding: 0; width: auto; }
  .description-cell { grid-column: 1; grid-row: 1; max-width: none; }
  .amount-cell { grid-column: 2; grid-row: 1; }
  .date-cell { grid-column: 1; grid-row: 3; font-size: .75rem; }
  .category-cell { grid-column: 1; grid-row: 2; font-size: .875rem; }
  .type-cell { grid-column: 2; grid-row: 2; text-align: right; }
  .action-cell { grid-column: 3; grid-row: 1 / 4; }
  .page-footer { font-size: .75rem; gap: 8px; }
}
@media (max-width: 390px) {
  .chart-layout { flex-direction: column; }
  .donut-wrapper { max-width: 100%; flex: 0 0 auto; width: 205px; }
  .chart-empty { text-align: center; }
  .legend-line { flex-wrap: nowrap; }
  .legend-amount { width: auto; margin-left: 0; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .header-meta { max-width: 110px; text-align: right; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
