:root {
  color-scheme: light;
  --canvas: #f3f5f7;
  --paper: #fff;
  --ink: #162129;
  --muted: #52606a;
  --border: #dce3e7;
  --green: #176455;
  --green-soft: #e9f3ee;
  --error: #9d3024;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.45; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button, a, input, select, [tabindex] { outline-offset: 3px; }
:focus-visible { outline: 2px solid #297462; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.18rem; line-height: 1.28; letter-spacing: -.014em; }

.shell { max-width: 1168px; margin: 0 auto; padding-inline: 28px; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--border); }
.topbar-inner { min-height: 70px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.025em; }
.brand-icon { display: block; width: 32px; height: 32px; border-radius: 8px; }
.local { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: .875rem; }
.local > span { width: 7px; height: 7px; background: #25836b; border-radius: 50%; }

main { padding-block: 48px 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { font-size: clamp(2rem, 4.5vw, 3.12rem); letter-spacing: -.055em; line-height: 1.02; font-weight: 720; }
.period { display: flex; gap: 10px; align-items: center; font-size: .875rem; color: var(--muted); }
select, input[type="text"], input[type="password"] { border: 1px solid var(--border); border-radius: 8px; background: var(--paper); color: var(--ink); min-height: 43px; padding: 8px 11px; }
select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 13px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.metric { min-height: 114px; display: grid; align-content: center; gap: 7px; padding: 17px 21px; background: var(--paper); border: 1px solid var(--border); border-radius: 14px; }
.metric h2 { color: var(--muted); font-weight: 560; font-size: .875rem; }
.metric.balance { background: var(--green-soft); border-color: #d3e5db; }
.figures { display: flex; flex-wrap: wrap; column-gap: 15px; font-size: clamp(1.42rem, 3vw, 2.04rem); letter-spacing: -.046em; font-variant-numeric: tabular-nums; font-weight: 690; overflow-wrap: anywhere; }
.income { color: var(--green); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 22px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--border); border-radius: 16px; min-width: 0; }
.journal { overflow: hidden; }
.panel-heading { padding: 22px 23px 0; display: flex; align-items: center; justify-content: space-between; }
.quiet { color: var(--muted); font-size: .8rem; }
.filters { display: flex; gap: 5px; overflow-x: auto; padding: 15px 22px 12px; border-bottom: 1px solid #e9eef0; }
.filters button { border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); padding: 6px 10px; white-space: nowrap; font-size: .875rem; }
.filters button:hover, .filters button[aria-pressed="true"] { background: var(--green-soft); color: var(--green); }
.filters button[aria-pressed="true"] { font-weight: 650; }
.empty { display: grid; justify-items: center; align-content: center; gap: 7px; padding: 28px 18px; min-height: 252px; text-align: center; }
.empty p { font-weight: 650; }
.empty > span:last-child { font-size: .875rem; color: var(--muted); }
.empty-icon { width: 40px; height: 40px; border-radius: 11px; background: #eaf1f0; margin-bottom: 4px; position: relative; }
.empty-icon::before { content: ""; position: absolute; inset: 10px 13px; border: 1.5px solid var(--green); border-radius: 3px; }
.empty-icon::after { content: ""; position: absolute; inset: 17px 17px auto; height: 1.5px; background: var(--green); box-shadow: 0 4px var(--green); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 11px 10px; border-bottom: 1px solid #edf0f2; vertical-align: top; }
th { background: #f8fafb; font-size: .8rem; color: var(--muted); font-weight: 620; }
td { font-size: .875rem; }
tr:last-child td { border-bottom: 0; }
table :is(th, td):first-child { padding-left: 22px; }
table :is(th, td):last-child { padding-right: 20px; }
table th:nth-child(3), .amount { text-align: right; }
.date-cell, .amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.date-cell small, .operation-cell small { display: block; margin-top: 2px; }
.operation-cell { overflow-wrap: anywhere; }
.mobile-date { display: none; }
.amount { font-weight: 670; }
.transfer-cell { width: 1%; text-align: right; }
.transfer-button { min-width: 31px; min-height: 28px; padding: 1px 5px; color: var(--muted); background: #f5f7f7; border: 1px solid var(--border); border-radius: 6px; font-size: .8rem; }
.transfer-button[aria-pressed="true"] { color: var(--green); background: var(--green-soft); }
.transfer-button[aria-pressed="true"] .transfer-icon { display: none; }
.more { margin: 12px 22px; }
#journal-error { margin: 12px 22px; }

.importer { padding: 22px; }
.importer h2 { margin-bottom: 18px; }
fieldset { border: 0; margin: 0 0 15px; padding: 0; min-width: 0; }
legend, .field { display: block; margin-bottom: 6px; font-weight: 630; font-size: .875rem; }
.bank-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bank-options label { display: flex; gap: 7px; align-items: start; border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px; font-size: .875rem; cursor: pointer; }
.bank-options label:has(input:checked) { border-color: #84aa9e; background: #f1f8f5; }
.bank-options input { accent-color: var(--green); margin: 3px 0 0; }
.bank-options small { display: block; margin-top: 2px; font-size: .8rem; color: var(--muted); }
#account { width: 100%; }
.hint { font-size: .8rem; color: var(--muted); margin: 6px 0 13px; }
.file-field { position: relative; display: grid; justify-items: center; gap: 4px; padding: 12px 9px; border: 1px dashed #96aaa8; border-radius: 10px; background: #f7faf9; font-weight: 620; font-size: .875rem; overflow-wrap: anywhere; text-align: center; }
.file-field:focus-within, .file-field:hover, .file-field.dragging { background: var(--green-soft); outline: 2px solid #297462; outline-offset: 2px; }
.file-field input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.file-field small { font-size: .8rem; color: var(--muted); font-weight: 400; }
.upload-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--green); background: #e5f1eb; font-size: 1.1rem; }
.primary, .secondary { min-height: 43px; border-radius: 8px; padding: 7px 14px; font-weight: 650; font-size: .9rem; }
.primary { border: 1px solid var(--green); background: var(--green); color: #fff; }
.primary:hover:enabled { background: #124f43; }
.secondary { border: 1px solid var(--border); background: var(--paper); color: var(--ink); }
.secondary:hover:enabled { background: #f4f7f7; }
.importer .primary { width: 100%; margin-top: 11px; }
.status { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
#import-status { margin-top: 9px; }
.status[data-state="error"] { color: var(--error); }
.status[data-state="success"] { color: var(--green); }
.login-shell { max-width: 476px; padding-block: clamp(42px, 12vh, 128px) 32px; }
.login-panel { padding: clamp(20px, 5vw, 30px); }
.login-panel h1 { margin-bottom: 24px; font-size: 2.1rem; }
.login-panel form { display: grid; }
.login-panel .status { margin-top: 8px; }
.login-panel .primary { margin-top: 15px; }
.logout { min-height: 35px; padding-inline: 12px; }

dialog { width: min(768px, calc(100% - 28px)); max-height: calc(100dvh - 26px); margin: auto; padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 22px 56px #15242640; }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #16212978; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; gap: 14px; padding: 21px 22px 14px; }
.dialog-heading p { color: var(--muted); font-size: .875rem; margin-top: 5px; }
.account-mapping { margin: 0 22px 12px; font-size: .875rem; }
.account-mapping summary { cursor: pointer; color: var(--green); font-weight: 620; }
#account-map-fields { max-height: 22vh; overflow-y: auto; }
.account-map-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 6px; }
.account-map-row span { overflow-wrap: anywhere; }
#check-mapping { margin-top: 7px; }
.close { font-size: 1.5rem; line-height: 1; border: 0; background: #f2f5f5; color: var(--ink); border-radius: 7px; min-width: 32px; min-height: 32px; }
.preview-table-wrap { overflow: auto; border-block: 1px solid var(--border); }
.preview-table th { position: sticky; top: 0; }
.preview-state { color: var(--green); }
.duplicate :is(.operation-cell, .amount, .preview-state) { color: var(--muted); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; align-items: center; gap: 8px; padding: 14px 22px; }
.dialog-actions .status { margin-right: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 760px) {
  .shell { padding-inline: 18px; }
  main { padding-block: 31px 36px; }
  .workspace { grid-template-columns: 1fr; gap: 14px; }
  .importer { grid-row: 1; }
  .summary { margin-bottom: 17px; }
}

@media (max-width: 490px) {
  .shell { padding-inline: 14px; }
  .topbar-inner { min-height: 57px; }
  .brand { gap: 7px; font-size: .91rem; white-space: nowrap; }
  .local { font-size: .78rem; text-align: right; }
  .local > span { display: none; }
  .page-heading { align-items: start; flex-direction: column; margin-bottom: 14px; gap: 10px; }
  .summary { grid-template-columns: 1fr; gap: 6px; }
  .metric { display: flex; justify-content: space-between; align-items: center; min-height: 46px; border-radius: 10px; padding: 8px 11px; gap: 8px; }
  .metric h2 { font-size: .78rem; }
  .figures { font-size: 1.12rem; column-gap: 7px; justify-content: end; text-align: right; }
  .panel-heading { padding-inline: 13px; }
  .filters { padding-inline: 9px; gap: 2px; flex-wrap: wrap; }
  .filters button { padding-inline: 8px; }
  .importer { padding: 15px; }
  table :is(th, td):first-child { padding-left: 9px; }
  table :is(th, td):last-child { padding-right: 9px; }
  th, td { padding-inline: 5px; }
  table :is(th, td):first-child { display: none; }
  table :is(th, td):nth-child(2) { padding-left: 12px; }
  .mobile-date { display: block; margin-top: 2px; }
  .transfer-button[aria-pressed="true"] .transfer-icon { display: inline; }
  .transfer-label { display: none; }
  .dialog-heading, .dialog-actions { padding-inline: 13px; }
  .account-mapping { margin-inline: 13px; }
}
