.import-panel,.preview,.period,.list-head,.overview,.breakdown{display:flex;align-items:center;justify-content:space-between;gap:18px}
.import-panel .help,.preview .help{margin-top:3px}.file-pick{position:relative;white-space:nowrap;overflow:hidden;cursor:pointer}.file-pick input{position:absolute;inset:0;opacity:0;width:100%;cursor:pointer}.file-pick:focus-within{outline:3px solid var(--accent);outline-offset:3px}
#info{margin:12px 0 20px;color:var(--muted)}.preview{background:#fff7d8;border-color:#d4b85e;margin-bottom:20px}.preview .actions{flex-shrink:0}.period{margin:21px 0 10px}select{font:inherit;color:var(--ink);background:white;border:1px solid var(--control);border-radius:7px;padding:6px 10px;min-height:40px}
#household{display:block;font-variant-numeric:tabular-nums;font-size:clamp(2rem,5vw,3.3rem);line-height:1.2;color:var(--ink);margin:8px 0}.overview dl{margin:0;min-width:240px}.overview dl>div{display:flex;justify-content:space-between;gap:18px;padding:4px 0;border-bottom:1px solid var(--edge)}dd{margin:0;font-weight:650}.overview p,.breakdown p,#matches{font-size:.88rem;color:var(--muted)}.breakdown,.details{margin-top:16px}.chart-wrap{display:flex;align-items:center;gap:20px}#chart{width:126px;height:126px}#legend{list-style:none;margin:0;padding:0;min-width:190px}#legend li{font-size:.88rem}#legend li span:last-child{margin-left:auto}.swatch{width:11px;height:11px;border-radius:3px;flex:none}.statement-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px;border-top:1px solid var(--edge);padding:13px 0}.title{overflow-wrap:anywhere;font-weight:650}.meta,#matches{font-size:.85rem;color:var(--muted)}.amount{font-weight:750;text-align:right;font-variant-numeric:tabular-nums}.row-controls{display:flex;gap:10px;align-items:center;flex-wrap:wrap;grid-column:1/-1}.row-controls label{font-size:.85rem}.row-controls select{font-size:.9rem;margin-left:4px;min-height:40px}#matches{margin:12px 0}.refund{color:#006e59}.empty{padding:12px 0}.category{font-size:.88rem;margin-right:10px}
@media(max-width:740px){.import-panel,.preview,.overview,.breakdown{align-items:stretch;flex-direction:column;gap:12px}.chart-wrap{justify-content:space-around;gap:12px}#chart{width:95px;height:95px}#legend{min-width:0;flex:1}.list-head,.period{gap:6px}.period label,.list-head label{font-size:.9rem}}

.fixed-panel {margin-top:12px}
.fixed-panel summary {color:var(--ink);font-weight:700;cursor:pointer}
.fixed-panel[open] summary {margin-bottom:12px}
#fixed-form {display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr));align-items:end;gap:12px;margin:12px 0}
#fixed-form label {display:grid;gap:3px;font-size:.9rem}
#fixed-form input {width:100%;min-width:0;min-height:44px;padding:7px 9px;font:inherit;border:1px solid var(--control);border-radius:7px;color:var(--ink)}
#fee-message {color:var(--accent)}
@media(max-width:540px){#fixed-form {grid-template-columns:1fr 1fr}#fixed-form button {grid-column:1/-1}}


.overview {background:var(--sky);border-color:#a8d8ee}
#household {color:#124e8b}
.overview dl>div {border-color:#b4d3e5}
.swatch {border:1px solid rgba(25,55,87,.18)}
.export-tools {margin-top:14px}
.export-tools p {margin-top:4px}

#queue-count {font-variant-numeric:tabular-nums}
#queue-list {margin-top:10px}
#all-summary {color:var(--ink);font-weight:700;cursor:pointer}
#all-details[open] .list-head {justify-content:flex-end;margin-top:8px}


#chart {cursor:pointer;flex:none}
#legend button {display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:4px 8px;color:var(--ink);background:transparent;border:1px solid transparent;border-radius:7px;font:inherit;text-align:left}
#legend button[aria-pressed="true"] {background:var(--sky);border-color:var(--accent)}
#category-panel {scroll-margin-top:12px}
#category-count {margin-top:8px;font-weight:650}
#category-status:not(:empty) {margin:8px 0;color:var(--ink)}
#category-list {margin-top:10px}
#category-list select {font-size:1rem;min-height:44px}
@media(max-width:540px){
  .chart-wrap {flex-direction:column;align-items:stretch}
  #chart {align-self:center;width:150px;height:150px}
}

.view-switch {display:flex;gap:4px;margin:18px 0 12px;padding:4px;width:fit-content;background:white;border:1px solid var(--edge);border-radius:12px}
.view-switch button {min-height:44px;border:0;border-radius:8px;padding:6px 14px;background:white;color:var(--ink);font:inherit}
.view-switch button[aria-pressed=true] {background:var(--accent);color:white;font-weight:650}
.calendar-grid {display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:3px}
.weekdays {margin:14px 0 6px;text-align:center;font-size:.875rem;color:var(--muted)}
#calendar-days button {min-width:0;min-height:58px;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3px 1px;line-height:1.4;background:white;color:var(--ink);border:1px solid var(--edge);border-radius:6px}
#calendar-days button[aria-pressed=true] {background:var(--sky);border:2px solid var(--accent)}
#calendar-days small {font-size:clamp(.66rem,2.8vw,.88rem);overflow-wrap:anywhere;max-width:100%;font-variant-numeric:tabular-nums}
#calendar-fixed {margin-top:12px;color:var(--muted);font-size:.9rem}
#day-detail {margin-top:18px;border-top:1px solid var(--edge)}
#day-list {margin-top:8px}

.cash-entry + .import-panel {margin-top:12px}
.cash-entry nav {display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.cash-entry a {text-decoration:none}

.rule-action {border:0;padding:6px;background:transparent;color:var(--accent);font:inherit;font-size:.9rem;text-decoration:underline;min-height:44px;cursor:pointer}
#merchant-dialog,#memo-dialog {width:min(26rem,calc(100% - 2rem));max-height:90vh;overflow:auto;border:1px solid var(--edge);border-radius:14px;padding:20px;color:var(--ink);background:white}
#merchant-dialog::backdrop,#memo-dialog::backdrop {background:rgb(22 43 62 / .4)}
#merchant-form {display:grid;gap:10px}
#merchant-description {overflow-wrap:anywhere;font-weight:650}
#merchant-form select {width:100%;min-height:44px}
#merchant-message:empty,#merchant-current:empty {display:none}
#merchant-forget {justify-self:start}

/* The report reads like a monthly notebook; entry controls stay together. */
.notebook-layout {
  display:grid;
  grid-template-columns:minmax(0,1fr);
  gap:20px;
  align-items:start;
}
.notebook-layout > * {min-width:0}
#entry-tools {scroll-margin-top:12px}
.notebook .intro {padding:32px 0 18px}
.top-links {display:flex;align-items:center;gap:12px}
.top-links a,.top-links button {
  display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:4px 8px;
  background:transparent;border:0;color:var(--ink);font:inherit;font-size:.94rem;font-weight:650;
  text-underline-offset:4px;
}
.top-links button {border:1px solid #bcac6a;border-radius:24px;padding-inline:16px}
.top-links button:hover {background:#fff8d6}
#info {margin:0 0 16px;color:var(--ink)}
#info:empty {margin:0}
.period {margin:0 0 10px}
.period label {display:flex;align-items:center;gap:6px}
.period select {font-size:1rem;min-height:44px}
.overview {
  display:block;
  background:linear-gradient(120deg,#e5fcf4,#e5f4ff 80%);
  border:1px solid #b3dcd5;border-top:4px solid #25a888;
}
#household {font-size:clamp(2.4rem,5vw,3.6rem);color:#115754;line-height:1.15}
.overview h2 {font-size:1rem;color:#215951}
.overview dl {
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;
  min-width:0;margin:16px 0 0;padding-top:12px;border-top:1px solid #afd6d5;
}
.overview dl>div {display:block;min-width:0;padding:0;border:0}
.overview .spending-split {grid-template-columns:repeat(2,minmax(0,1fr));width:fit-content;gap:24px;margin:4px 0 10px;padding:0;border:0}
.overview dt {font-size:.875rem;color:var(--muted)}
.overview dd {margin:2px 0 0;overflow-wrap:anywhere}
#card-latest {margin-top:4px}
.import-panel {display:grid;gap:12px;border-top:4px solid #569ef1}
.import-panel .file-pick {justify-self:start}
.cash-entry {border-top:4px solid #f7bd40}
.cash-entry a {font-size:.94rem}
.fixed-panel {padding-block:12px}
.fixed-panel>summary {padding:9px 0}
.preview {display:grid}
.preview .actions {grid-template-columns:repeat(2,minmax(0,1fr))}
.breakdown {display:grid;gap:16px;margin-top:0}
.breakdown .help {margin-top:4px}
.chart-wrap {display:grid;grid-template-columns:minmax(100px,155px) minmax(0,1fr);gap:18px}
#chart {width:100%;height:auto;align-self:start}
#legend {min-width:0}
#legend button {border-radius:6px;border-bottom:1px solid var(--edge)}
#legend button:hover {background:var(--sky)}
#legend button[aria-pressed=true] {border-color:var(--accent)}
.export-tools {margin-top:18px}
#export-note {font-size:.875rem;color:var(--muted)}

#usage-guide {
  width:min(34rem,calc(100vw - 2rem));max-height:85vh;max-height:85dvh;overflow:auto;
  border:1px solid var(--edge);border-radius:16px;padding:22px;background:white;color:var(--ink);
}
#usage-guide::backdrop {background:rgb(22 43 62 / .4)}
.guide-head {display:flex;align-items:center;justify-content:space-between;gap:12px}
.guide-head form {flex:none}
.guide-steps {padding-left:1.65em;margin:16px 0}
.guide-steps li {padding-left:4px;margin-top:14px}
.guide-steps li::marker {font-weight:750;color:var(--accent)}
.guide-steps h3 {font-size:1rem;margin:0 0 2px}
.guide-steps p,.guide-tip p {line-height:1.7}
.guide-tip {border-top:1px solid var(--edge)}
.guide-tip summary {min-height:44px;padding:10px 0;cursor:pointer;font-weight:650}
.guide-tip p {padding:0 0 12px;color:var(--muted)}
@media (max-width:780px) {
  .notebook-layout {gap:16px}
  .notebook .intro {padding:20px 0 14px}
  .notebook .brand {gap:6px;font-size:1.04rem;letter-spacing:0}
  .top-links {gap:3px}
  .top-links button {padding-inline:10px}
  .top-links a {padding-inline:5px}
  .import-panel .file-pick {justify-self:stretch}
}
@media (max-width:540px) {
  .chart-wrap {grid-template-columns:minmax(0,1fr)}
  #chart {width:150px;justify-self:center}
  .period h2 {font-size:1rem}
  #usage-guide {padding:16px}
}

.backup-panel {margin-top:12px;padding-block:12px}
.backup-panel summary {padding:9px 0;cursor:pointer;font-weight:700}
.backup-actions {display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
#backup-download {text-decoration:none}
#restore-dialog,#reset-dialog,#cash-delete-dialog {
  width:min(30rem,calc(100vw - 2rem));max-height:85vh;overflow:auto;padding:22px;
  border:1px solid var(--edge);border-radius:16px;background:white;color:var(--ink)
}
#restore-dialog::backdrop,#reset-dialog::backdrop,#cash-delete-dialog::backdrop {background:rgb(22 43 62 / .4)}
#restore-dialog p,#reset-dialog p,#cash-delete-dialog p {margin-top:10px}
#restore-impact {background:#fff6cd;border-radius:8px;padding:10px 12px}

.memo-link {display:block;max-width:100%;overflow-wrap:anywhere;text-align:left}
#memo-form .actions {margin-top:14px}
#memo-message:not(:empty) {margin-top:8px}

#legend button > span {text-align:right;font-variant-numeric:tabular-nums}
.category-net {display:block;font-size:.9rem}
.category-difference {display:block;color:var(--muted);font-size:.875rem}

#annual-special {margin-top:16px}
#annual-special summary {cursor:pointer;padding:10px 0;font-weight:650;overflow-wrap:anywhere}
.annual-head {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;margin:12px 0}
#special-groups details {border-bottom:1px solid var(--edge)}
#special-groups summary {display:grid;grid-template-columns:.65rem minmax(0,1fr) max-content;align-items:center;gap:8px;list-style:none}
#special-groups summary::-webkit-details-marker {display:none}
#special-groups summary::before {content:"";width:.43rem;height:.43rem;border:solid currentColor;border-width:0 2px 2px 0;transform:rotate(-45deg)}
#special-groups details[open] > summary::before {transform:rotate(45deg)}
#special-groups label {display:grid;grid-template-columns:auto minmax(0,1fr) max-content;align-items:center;gap:8px;min-height:44px;padding:7px 0;border-top:1px solid var(--edge)}
#special-groups label > span {min-width:0;overflow-wrap:anywhere}
#special-groups label small {display:block;color:var(--muted);font-size:.875rem}
#special-groups strong {white-space:nowrap;text-align:right;font-variant-numeric:tabular-nums}
.special-select-all {font-weight:650}
#special-group-form {margin-top:16px}
#special-group-name {display:block;width:100%;min-height:44px;margin:4px 0 10px;padding:8px;border:1px solid var(--control);border-radius:8px;font:inherit}

.cash-delete {color:#973725;margin-inline-start:auto}
#cash-delete-detail {overflow-wrap:anywhere}

#undo-edit {position:fixed;z-index:5;bottom:max(.5rem,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 1rem);display:flex;align-items:center;gap:.5rem;padding:.45rem .7rem;background:#fff;border:1px solid var(--control);box-shadow:0 2px 12px #26374a30;border-radius:12px}
#undo-edit button {flex:none}
#undo-label {font-size:.9rem;overflow-wrap:anywhere}
body:has(#undo-edit:not([hidden])) {padding-bottom:6rem}
#annual-category-edit:not(:empty) {margin-top:12px}
#annual-category-edit select {margin-inline-start:8px}

.use-totals {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:16px;padding-top:12px;border-top:1px solid #afd6d5}
.use-totals > * {min-width:0;padding:7px 6px;text-align:left;overflow-wrap:anywhere}
.use-totals span,.use-totals small {display:block;font-size:.875rem;color:var(--muted)}
.use-totals strong {display:block;font-variant-numeric:tabular-nums}
.use-totals button {font:inherit;background:white;color:var(--ink);border:1px solid var(--control);border-radius:8px}
.use-totals button span {color:var(--accent);text-decoration:underline;text-underline-offset:3px}
.use-totals button[aria-expanded=true] {border-color:var(--accent);background:var(--sky)}
#use-panel {margin-bottom:14px}
#use-count {margin-top:8px;font-weight:650}
#use-list {margin-top:12px}

.owner-form{display:flex;align-items:flex-end;gap:10px;flex-wrap:wrap;margin:10px 0}.owner-form label{display:grid;gap:4px;flex:1;min-width:10em}.owner-form input{font:inherit;padding:8px 10px;border:1px solid #b8c6d2;border-radius:8px}
#sync-share,#sync-download{margin-top:10px}
#all-details[open] .list-head{gap:12px}
