:root { --ink:#17243a; --muted:#62708a; --paper:#f5f7fb; --panel:#fff; --line:#e2e7f0; --accent:#225bda; --accent-pale:#eaf0ff; --red:#ba3658; --green:#08775b; }
:root { color-scheme:light; }
:root[data-theme="dark"] { color-scheme:dark; --ink:#ececec; --muted:#b4b4b4; --paper:#212121; --panel:#2f2f2f; --line:#484848; --accent:#ececec; --accent-pale:#3a3a3a; --red:#ff9cb1; --green:#72dfbd; }
.header-preferences { display:flex; gap:20px; align-items:center; flex-wrap:wrap; }
#finance-tools { margin-bottom:32px; }
#finance-tools details { margin:18px 0; }
#finance-tools summary { cursor:pointer; font-weight:650; margin-bottom:12px; }
#finance-tools form { margin:16px 0; align-items:end; grid-template-columns:repeat(2,minmax(0,1fr)); }
#finance-tools form p { grid-column:1/-1; }
#finance-tools form .button { justify-self:start; align-self:end; }
#finance-tools label,.report-actions>* { min-width:0; max-width:100%; }
#finance-tools select,.settlement-form select { width:100%; min-width:0; }
.report-actions input,.report-actions select { min-width:0; }
.layout-grid { align-items:start; }
@media(max-width:600px) { #finance-tools form { grid-template-columns:minmax(0,1fr); } }
[data-theme="dark"] input,[data-theme="dark"] select { background:var(--paper); border-color:var(--line); color:var(--ink); }
[data-theme="dark"] .table-wrap th { background:var(--paper); }
[data-theme="dark"] .button:not(.button-quiet),[data-theme="dark"] .file-input { background:#ececec; color:#171717; }
[data-theme="dark"] .allocation-buttons button { background:var(--paper); }
[data-theme="dark"] .allocation-buttons button[aria-pressed="true"] { background:#ececec; color:#171717; }
[data-theme="dark"] .tag { background:var(--line); color:var(--ink); }
[data-theme="dark"] .tag.shared { background:#544324; color:#ffe2a1; }
[data-theme="dark"] .tag.review { background:#542c3b; color:#ffbacb; }
[data-theme="dark"] dialog { background:var(--panel); color:var(--ink); }
[data-theme="dark"] .close { color:var(--ink); }
#credit-preview { max-height:440px; overflow:auto; }
.analytics-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; margin:18px 0; }
.report-actions,.report-presets { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:12px 0; }
.report-actions input,.report-actions select { max-width:100%; }
.report-controls { margin:14px 0; }
.report-chart { max-height:350px; overflow:auto; }
.report-bar { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:4px 12px; width:100%; text-align:left; border:0; background:transparent; color:var(--ink); padding:9px 0; font:inherit; cursor:pointer; }
.report-bar span { overflow-wrap:anywhere; }
.report-bar progress { grid-column:1/-1; width:100%; height:8px; accent-color:var(--accent); }
.report-row { display:flex; justify-content:space-between; gap:14px; padding:12px 0; border-bottom:1px solid var(--line); }
.report-row span { overflow-wrap:anywhere; min-width:0; }
.report-row strong { text-align:right; }
.report-quality { margin-bottom:18px; }
#analytics-view { padding-bottom:40px; }
#analytics-view .metric small { display:block; color:var(--muted); margin-top:8px; }
.report-footnote { margin-top:32px; }
@media(max-width:700px) { .analytics-grid { grid-template-columns:minmax(0,1fr); } .report-row { flex-direction:column; gap:5px; } .report-row strong { text-align:left; } }
@media print {
  :root[data-theme] { color-scheme:light; --ink:#17243a; --muted:#62708a; --paper:#fff; --panel:#fff; --line:#e2e7f0; --accent:#225bda; --accent-pale:#eaf0ff; --red:#ba3658; --green:#08775b; }
  .app-header,#auth-panel,#app-feedback,.profile-settings,.view-tabs,#migration-panel,#app-main>p,#overview-view,#import-view,.report-controls,.report-actions,#report-clear-drill,dialog { display:none!important; }
  body { background:white; font-size:10pt; } main { max-width:none; padding:0; }
  #analytics-view { display:block!important; } .analytics-grid { display:block; }
  .panel,.metric { box-shadow:none; margin-bottom:12px; break-inside:avoid; }
  .report-chart { max-height:none; overflow:visible; } .table-wrap { overflow:visible; }
  .table-wrap table { min-width:0; width:100%; } .report-bar { break-inside:avoid; }
  tr { break-inside:avoid; } .summary-grid { grid-template-columns:repeat(2,1fr); }
}
[hidden] { display:none!important; }
.auth-panel { max-width:520px; margin:30px auto; }
.auth-panel form { display:grid; gap:16px; }
.app-feedback { max-width:1280px; margin:10px auto; padding:0 24px; color:var(--accent); }
#migration-panel { margin-bottom:20px; }
#session-user { display:inline-block; margin-right:12px; font-weight:600; }
.layout-grid > * { min-width:0; }
.profile-settings { margin:0 0 20px; }
.profile-settings form { display:grid; gap:12px; max-width:440px; padding:15px 0; }
.mapping-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:14px; }
#credit-settings { flex-basis:100%; display:grid; grid-template-columns:1fr 1fr; gap:12px; }
#credit-settings p { grid-column:1/-1; }
#credit-mapping, #credit-reconciliation { margin-bottom:18px; }
.mapping-preview small,.credit-match small { display:block; color:var(--muted); overflow-wrap:anywhere; }
.credit-match { display:flex; flex-wrap:wrap; align-items:center; gap:16px; border-top:1px solid var(--line); padding:16px 0; }
.credit-match > div { flex:1; min-width:200px; }
.mapping-preview { margin-top:16px; }
.view-tabs,.import-actions { display:flex; gap:10px; flex-wrap:wrap; margin:0 0 20px; }
.import-actions { margin-top:18px; }
.import-panel { flex-wrap:wrap; }
#import-view { padding-bottom:40px; }
#import-body small { display:block; color:var(--muted); font-size:12px; margin-top:5px; overflow-wrap:anywhere; }
.import-description { min-width:220px; max-width:360px; }
.allocation-buttons { display:flex; gap:5px; flex-wrap:wrap; min-width:210px; }
.allocation-buttons button { cursor:pointer; border:1px solid var(--line); border-radius:7px; padding:8px 10px; color:var(--ink); background:white; font:inherit; }
.allocation-buttons button[aria-pressed="true"] { background:var(--accent); color:white; border-color:var(--accent); }
.button:disabled { opacity:.45; cursor:not-allowed; }
.settlement-form { display:grid; gap:10px; }
.settlement-form p { margin:0; }
.settlement-panel h3 { margin-top:28px; }
:focus-visible { outline:3px solid #80a7ff; outline-offset:2px; }
* { box-sizing:border-box; }
body { margin:0; background:var(--paper); color:var(--ink); font:15px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif; }
.app-header, main { max-width:1280px; margin:auto; padding-left:24px; padding-right:24px; }
.app-header { min-height:106px; display:flex; align-items:center; justify-content:space-between; gap:24px; }
h1,h2,p { margin-top:0; } h1 { margin-bottom:0; font-size:28px; } h2 { font-size:20px; margin-bottom:8px; }
.eyebrow { color:var(--accent); font-size:12px; font-weight:750; letter-spacing:.08em; text-transform:uppercase; margin-bottom:4px; }
.panel { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:22px; box-shadow:0 2px 8px #17243a08; }
.import-panel { display:flex; align-items:center; gap:28px; margin-bottom:18px; } .import-panel > div { flex:1; } .import-panel p:not(.eyebrow) { color:var(--muted); margin-bottom:0; }
.file-input { display:inline-flex; white-space:nowrap; cursor:pointer; padding:10px 14px; border-radius:8px; background:var(--accent); color:white; font-weight:650; } .file-input input { display:none; }
.feedback { flex-basis:100%; color:var(--green); font-weight:600; }
.summary-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin:18px 0; }.metric { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:18px; }.metric span{display:block;color:var(--muted);font-size:13px}.metric strong{font-size:21px;display:block;margin-top:5px}.metric:nth-child(2) strong{color:var(--red)}
.controls { display:flex; gap:14px; align-items:end; margin-bottom:18px; }.controls > div { min-width:180px; }.controls .button { margin-left:auto; } label { display:grid; gap:5px; font-weight:650; font-size:13px; } select,input { font:inherit; border:1px solid #cbd4e2; border-radius:7px; padding:8px; color:var(--ink); background:white; }
.button { appearance:none; border:0; background:var(--accent); color:white; border-radius:8px; padding:10px 14px; font:inherit; font-weight:700; cursor:pointer; }.button-quiet{background:var(--accent-pale);color:var(--accent)}
.layout-grid { display:grid; grid-template-columns:minmax(0, 2.1fr) minmax(300px, .9fr); gap:18px; padding-bottom:40px; }.section-heading,.dialog-heading { display:flex; justify-content:space-between; align-items:start; }.count{color:var(--muted);font-size:13px}.table-wrap{overflow:auto;margin:6px -22px -22px}.table-wrap table{width:100%;border-collapse:collapse;min-width:730px}.table-wrap th{text-align:left;color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.04em;background:#fbfcfe}.table-wrap th,.table-wrap td{border-top:1px solid var(--line);padding:11px 10px}.table-wrap th:first-child,.table-wrap td:first-child{padding-left:22px}.table-wrap th:last-child,.table-wrap td:last-child{padding-right:22px;text-align:right}.amount-negative{color:var(--red);font-weight:650}.amount-positive{color:var(--green);font-weight:650}.tag{display:inline-block;padding:3px 7px;border-radius:99px;font-size:12px;font-weight:650;background:#eef1f6;color:#526077}.tag.shared{background:#fff4dd;color:#8a5c00}.tag.review{background:#ffe9eb;color:#9b2943}.icon-button{border:0;background:none;color:var(--accent);font:inherit;font-weight:700;cursor:pointer}
.muted{color:var(--muted)}.settlement-details{margin-top:20px}.settlement-row{border-top:1px solid var(--line);padding:12px 0}.settlement-row:first-child{border-top:0}.settlement-row span{display:block;color:var(--muted);font-size:13px}.settlement-row strong{font-size:17px}.settlement-result{margin-top:12px;padding:14px;border-radius:9px;background:var(--accent-pale)}.settlement-result strong{font-size:19px}.empty{text-align:center;color:var(--muted);padding:32px!important}
dialog{border:0;border-radius:14px;width:min(460px,calc(100% - 32px));box-shadow:0 20px 60px #0004;padding:0}dialog::backdrop{background:#17243a77}dialog form{display:grid;gap:14px;padding:22px}.dialog-heading .close{border:0;background:none;font-size:26px;line-height:1;cursor:pointer}.checkbox{display:flex;align-items:center;gap:8px}.checkbox input{width:16px;height:16px}menu{display:flex;justify-content:end;gap:8px;padding:0;margin:4px 0 0}
@media(max-width:800px){.app-header{min-height:auto;padding-top:20px;padding-bottom:20px}.app-header,.import-panel,.controls{align-items:stretch;flex-direction:column}.summary-grid,.layout-grid{grid-template-columns:1fr 1fr}.layout-grid{gap:14px}.controls .button{margin-left:0}.feedback{margin-bottom:0}}@media(max-width:520px){.summary-grid,.layout-grid{grid-template-columns:1fr}.app-header,main{padding-left:14px;padding-right:14px}.app-header h1{font-size:24px}}
