html, body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font-sans); font-size: 13px; font-weight: 400; line-height: 21px; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; box-sizing: border-box; }
button { cursor: pointer; border: 0; background: transparent; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--charcoal); outline-offset: 2px;
}
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--card) inset;
  -webkit-text-fill-color: var(--ink);
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#message { min-height: 0; color: var(--error); margin: 0; padding: 0 1.5rem; }
#message:empty { display: none; }
#message.is-banner, #message.is-note {
  width: min(440px, calc(100% - 64px)); margin: 24px auto 0; box-sizing: border-box;
  border-radius: var(--radius-card); padding: 12px 16px; font-size: 13px; font-weight: 400; line-height: 21px;
}
#message.is-banner { background: var(--errorbg); color: var(--error); border: 1px solid var(--errorborder); }
#message.is-note { background: var(--inner); color: var(--body); border: 1px solid var(--border); }

.topbar {
  height: 72px; display: grid; grid-template-columns: minmax(196px, 240px) minmax(0, 1fr) auto; align-items: stretch;
  padding: 0 32px; background: var(--canvas); position: relative;
}
.brand { display: flex; align-items: center; gap: 8px; align-self: center; font-weight: 700; font-size: 16px; line-height: 24px; color: var(--ink); }
.mark {
  width: 28px; height: 28px; border-radius: var(--radius-inner); background: var(--primary); color: #fff;
  display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; line-height: 1;
}
.sub { color: var(--aux); font-weight: 400; font-size: 13px; line-height: 21px; }
.main-nav { display: flex; justify-content: center; align-items: stretch; gap: 4px; }
.main-nav[hidden], #nav-upload[hidden], #account-trigger[hidden], #account-menu[hidden],
html.is-signed-out .main-nav, html.is-signed-out #nav-upload,
html.is-signed-out #account-trigger, html.is-signed-out #account-menu { display: none !important; }
.nav-item {
  position: relative; background: transparent; border: 0; color: var(--aux);
  min-height: 72px; padding: 0 14px; font-size: 14.5px; font-weight: 600; line-height: 22px;
}
.nav-item.is-current { color: var(--ink); font-weight: 700; }
.nav-item.is-current::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 2px;
  background: var(--primary); border-radius: 2px 2px 0 0;
}
.top-actions { display: flex; align-items: center; align-self: center; gap: 8px; }
.secondary, .account-menu button, .edit-fields button.secondary, .card-actions .secondary, .desk-nav .secondary {
  background: var(--card); color: var(--ink); border: 1px solid var(--control); border-radius: var(--radius-control);
  min-height: 32px; padding: 0 12px; font-size: 13px; font-weight: 600; line-height: 20px;
}
.primary, #confirm.primary, .edit-fields button.primary, .mobile-confirm {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border: 1px solid var(--primary); border-radius: var(--radius-control);
  min-height: 32px; padding: 0 16px; font-size: 13px; font-weight: 600; line-height: 20px;
}
#nav-upload {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 32px; padding: 0 14px;
}
.account-trigger {
  background: transparent; border: 0; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 32px; padding: 0 10px; border-radius: var(--radius-control);
  color: var(--body); font-size: 13px; font-weight: 600; line-height: 20px;
}
.person { width: 16px; height: 16px; border: 1.5px solid currentColor; border-radius: 50%; display: inline-block; }
.account-menu {
  position: absolute; top: calc(100% + 4px); right: 32px; width: 224px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-float); padding: 6px; z-index: 30;
}
.account-menu[hidden] { display: none; }
.account-menu button { display: flex; align-items: center; justify-content: flex-start; width: 100%; text-align: left; margin: 2px 0; min-height: 44px; padding: 0 12px; }
.account-menu .danger { background: var(--charcoal); color: #fff; border-color: var(--charcoal); }
.account-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }
button.primary:disabled, button.secondary:disabled, button.charcoal:disabled {
  opacity: 1; background: var(--disabled); color: var(--aux); border-color: var(--soft); box-shadow: none;
}
button.is-working:not(#export-submit) { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button.is-working:not(#export-submit)::before {
  content: ""; width: 14px; height: 14px; box-sizing: border-box; flex: none;
  border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: intake-spin 1.2s linear infinite;
}
button.primary.is-working:disabled { background: var(--primary); color: #fff; border-color: var(--primary); cursor: progress; }
button.secondary.is-working:disabled { background: var(--card); color: var(--ink); border-color: var(--control); cursor: progress; }
button.charcoal.is-working:disabled { background: var(--charcoal); color: #fff; border-color: var(--charcoal); cursor: progress; }
#export-submit { gap: 8px; }
#export-submit.is-working:disabled {
  background: var(--primary); color: #fff; border-color: var(--primary); cursor: progress;
}
#export-submit.is-working:disabled:hover, #export-submit.is-working:disabled:active { box-shadow: none; }
button.view-source:disabled {
  opacity: 1; background: var(--inner); color: var(--ink); border-color: var(--control); cursor: default; box-shadow: none;
}
html.is-signed-out main { min-height: 100dvh; display: flex; flex-direction: column; }
html.is-signed-out #sign-in { margin: auto; }

#sign-in {
  width: min(440px, calc(100% - 64px)); margin: 32px auto 48px; box-sizing: border-box;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 32px 32px 28px;
  box-shadow: var(--shadow-card);
}
#sign-in h2 { margin: 0 0 24px; font-size: 24px; font-weight: 700; line-height: 34px; letter-spacing: 0; color: var(--ink); }
#sign-in form.sign-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto;
  column-gap: 12px; row-gap: 8px; align-items: center; margin: 0;
}
#sign-in form.sign-row + form.sign-row { margin-top: 20px; }
#sign-in label { grid-column: 1 / -1; margin: 0; font-size: 12px; font-weight: 600; line-height: 18px; color: var(--aux); }
#sign-in input {
  grid-column: 1; width: 100%; box-sizing: border-box; height: 40px; min-height: 40px; margin: 0; padding: 0 12px;
  appearance: none; background: var(--card); border: 1px solid var(--control); border-radius: var(--radius-control);
  color: var(--ink); font-size: 15px; font-weight: 400; line-height: 24px; box-shadow: none;
}
#sign-in button.primary {
  grid-column: 2; width: 120px; min-width: 120px; box-sizing: border-box; height: 40px; min-height: 40px; margin: 0; padding: 0 12px;
  border-radius: var(--radius-control); font-size: 13px; font-weight: 600; line-height: 20px; letter-spacing: 0;
}
#sign-in input:focus-visible, #sign-in button.primary:focus-visible { outline: 2px solid var(--charcoal); outline-offset: 2px; }
@media (hover: hover) {
  .primary:hover { box-shadow: inset 0 0 0 1px var(--charcoal); }
  .secondary:hover, .chip:hover, .account-trigger:hover, .more-menu summary:hover { background: var(--inner); }
  .primary:active, .secondary:active { box-shadow: inset 0 0 0 2px var(--charcoal); }
  button.view-source:disabled:hover, button.primary:disabled:hover, button.secondary:disabled:hover { box-shadow: none; }
}
@media (max-width: 900px) {
  #message.is-banner, #message.is-note { width: min(440px, calc(100% - 32px)); margin-top: 16px; }
  #sign-in { width: min(440px, calc(100% - 32px)); margin: 16px auto 24px; padding: 24px 16px 20px; }
  #sign-in h2 { margin-bottom: 20px; font-size: 18px; line-height: 28px; }
  #sign-in form.sign-row { column-gap: 8px; }
  #sign-in form.sign-row + form.sign-row { margin-top: 16px; }
  #sign-in input, #sign-in button.primary { height: 44px; min-height: 44px; }
  #sign-in button.primary { width: 108px; min-width: 108px; }
}
.edit-fields input, select, #integration-keep input, #integration-keep select {
  appearance: none; background: var(--card); color: var(--ink); border: 1px solid var(--control);
  border-radius: var(--radius-control); min-height: 36px; height: 36px; padding: 0 12px; box-sizing: border-box;
  font-size: 13px; line-height: 21px;
}
.edit-fields input { width: 100%; }
.edit-fields input[name="amount"], .edit-fields input[name="currency"] {
  font-family: var(--money); font-variant-numeric: tabular-nums;
}
#app-shell { min-height: calc(100dvh - 72px); padding: 4px 32px 24px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 12px 0 16px; }
.title-row h1 { font-size: 24px; line-height: 34px; margin: 0; font-weight: 700; color: var(--ink); letter-spacing: 0; }
.pool-count { margin: 0; color: var(--aux); font-size: 13px; font-weight: 400; line-height: 21px; }
.summary-card {
  display: grid; grid-template-columns: minmax(156px, 196px) minmax(0, 1fr) auto auto; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 20px; margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.summary-cell { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-height: 68px; padding: 4px 0 4px 24px; }
.summary-cell:first-child { padding-left: 4px; }
.summary-cell + .summary-cell { border-left: 1px solid var(--border); }
.kicker { display: block; color: var(--aux); font-size: 12px; font-weight: 400; line-height: 18px; margin: 0; }
#summary-lead { font-size: 20px; font-weight: 700; line-height: 28px; color: var(--ink); }
.currency-row { display: flex; gap: 28px; align-items: baseline; flex-wrap: wrap; min-height: 28px; }
.currency-chip {
  font-family: var(--money); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 20px; line-height: 28px;
  color: var(--ink); white-space: nowrap;
}
.currency-empty { color: var(--aux); font-family: var(--font-sans); font-size: 13px; font-weight: 400; line-height: 21px; }
.review-chip {
  margin-left: 20px; background: var(--errorbg); color: var(--error); border: 0; border-radius: var(--radius-inner);
  min-height: 44px; padding: 0 14px; font-size: 13px; font-weight: 600; line-height: 20px;
}
.review-chip[aria-pressed="true"] { outline: 2px solid var(--error); outline-offset: 2px; }
#pool-summary #confirm { margin-left: 16px; }
.work { display: grid; grid-template-columns: minmax(0, 1fr) 472px; gap: 24px; align-items: start; }
.list-wrap { min-height: 0; }
.list-toolbar { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.list-toolbar strong { font-size: 14.5px; font-weight: 700; line-height: 22px; color: var(--ink); margin-right: 4px; }
.batch-bar { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; min-height: 32px; }
.select-all { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 13px; font-weight: 600; color: var(--ink); }
.select-all input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.select-all input:disabled { cursor: not-allowed; }
.batch-count { color: var(--aux); font-size: 13px; line-height: 20px; font-variant-numeric: tabular-nums; }
.batch-delete { margin-left: auto; color: var(--error); border-color: var(--error); }
.batch-delete:disabled { color: var(--aux); border-color: var(--control); }
.toolbar-spacer { flex: 1; }
.chip {
  background: var(--card); color: var(--ink); border: 1px solid var(--control); border-radius: var(--radius-control);
  min-height: 32px; padding: 0 12px; font-size: 13px; font-weight: 600; line-height: 20px;
}
.chip.is-current, .chip[aria-pressed="true"] { border-color: var(--charcoal); background: var(--selected); }
#original-desk { background: var(--desk); border-radius: var(--radius-card); padding: 16px 16px 24px; min-height: 640px; position: sticky; top: 16px; }
#original-desk .page-tools { margin-bottom: 12px; }
.desk-head, .desk-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.desk-kicker { background: var(--charcoal); color: #fff; border-radius: var(--radius-badge); padding: 2px 8px; font-size: 12px; font-weight: 600; line-height: 18px; }
#original-desk [data-source-title], .original-screen [data-source-title] {
  margin: 16px 0 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 15px; font-weight: 600; line-height: 24px; color: var(--ink);
}
.original-screen header { min-width: 0; }
.original-screen [data-source-title] { flex: 1; margin: 0; }
#original-desk [data-source-status] { margin: 4px 0 0; min-height: 18px; color: var(--aux); font-size: 12px; line-height: 18px; }
[data-source-window] { color: var(--ready); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; }
[data-source-window][hidden] { display: none; }
.paper { background: #fff; min-height: 420px; border-radius: 2px; box-shadow: var(--shadow-paper); margin-top: 16px; overflow: hidden; color: var(--aux); font-size: 13px; line-height: 21px; }
.paper:not(:has(canvas, .sheet)) { display: flex; align-items: center; justify-content: center; padding: 32px 24px; text-align: center; }
.paper.is-opening { opacity: .72; }
.paper canvas { width: 100%; height: auto; display: block; }
.mobile-only { display: none; }
.sheet { padding: 28px 26px 20px; color: var(--ink); }
.sheet h2 { margin: 0; font-size: 22px; letter-spacing: .04em; }
.sheet-sub { margin: .15rem 0 0; color: var(--aux); font-size: 12px; letter-spacing: .12em; }
.sheet-meta { margin: .8rem 0; color: var(--aux); font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: .7rem; }
.sheet-line { display: flex; justify-content: space-between; gap: 1rem; margin: .55rem 0; }
.sheet-line strong { font-family: var(--money); font-variant-numeric: tabular-nums; }
.page-tools { display: flex; gap: .55rem; margin-top: .8rem; }
.page-tools button {
  width: 72px; height: 96px; background: var(--card); border: 1px solid var(--border); border-radius: 4px;
  color: var(--aux); padding: 4px 4px 2px; display: grid; align-content: end; justify-items: center;
}
.page-tools canvas { width: 62px; height: auto; background: #fff; }
.page-tools button[aria-current="page"] { border: 2px solid var(--charcoal); color: var(--ink); }

.expense-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px;
  margin: 0 0 12px; box-shadow: var(--shadow-card); position: relative;
}
.expense-card.is-preview {
  background: var(--selected); border-color: var(--charcoal);
  box-shadow: 0 0 0 1px var(--charcoal), var(--shadow-card);
}
.expense-card.is-financial-hold { outline: 2px solid var(--error); outline-offset: 1px; }
.expense-card { container-type: inline-size; }
@container (max-width: 560px) {
  .card-head { flex-wrap: wrap; }
  .card-head .money { margin-left: auto; }
}
.card-top { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-top: 12px; }
.card-head h3 {
  margin: 0; font-size: 15px; font-weight: 600; line-height: 24px; color: var(--ink); flex: 1; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.card-head .money {
  margin: 0; flex: 0 0 auto; font-family: var(--money); font-variant-numeric: tabular-nums;
  font-size: 20px; font-weight: 700; line-height: 28px; text-align: right; white-space: nowrap; color: var(--ink);
}
.meta, .file-line { color: var(--aux); font-size: 12px; font-weight: 400; line-height: 18px; margin: 4px 0 0; }
.file-line { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.file-line::before { content: "▸"; color: var(--soft); font-size: 11px; }
.status-word { color: var(--aux); font-size: 12px; font-weight: 400; line-height: 18px; }
.status-word.is-review { color: var(--error); font-weight: 600; }
.tag { border-radius: var(--radius-badge); padding: 2px 8px; font-size: 12px; font-weight: 600; line-height: 18px; background: var(--inner); color: var(--aux); }
.tag-ready { background: var(--readybg); color: var(--ready); }
.tag-preview { background: var(--charcoal); color: #fff; }
.check { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: -8px 0 -8px -12px; }
.check-slot, .check input { width: 18px; height: 18px; border: 1px solid var(--control); border-radius: 4px; background: var(--card); margin: 0; box-sizing: border-box; }
.check-slot { border-color: var(--soft); background: var(--disabled); display: inline-block; }
.check input { appearance: none; }
.check input:checked {
  border-color: var(--primary); background-color: var(--primary);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3.5 8.5 6.5 11.5 12.5 4.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: center; background-size: 14px;
}
.check input:disabled {
  border-color: var(--control); background-color: var(--disabled);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 8h8' fill='none' stroke='%2357534E' stroke-width='1.6' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: center; background-size: 14px;
}
.preview-note {
  display: flex; flex-direction: column; gap: 4px; background: var(--obsbg); border: 1px solid var(--obsborder);
  border-radius: var(--radius-inner); padding: 12px 14px; margin: 12px 0 0; color: var(--ink); font-size: 13px; line-height: 21px;
}
.preview-note strong { color: var(--obs); font-size: 12px; font-weight: 700; line-height: 18px; }
.block-reason {
  color: var(--error); font-size: 13px; font-weight: 400; line-height: 21px; margin: 12px 0 0;
  padding: 10px 12px; background: var(--errorbg); border: 1px solid var(--errorborder); border-radius: var(--radius-inner);
}
.card-actions { display: none; align-items: center; gap: 12px; margin-top: 16px; }
.expense-card.is-preview .card-actions { display: flex; }
.card-actions .secondary { min-width: 104px; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.card-actions .edit-toggle { min-width: 72px; background: transparent; border-color: transparent; color: var(--body); }
.more-menu { margin-left: auto; position: relative; }
.more-menu summary {
  list-style: none; cursor: pointer; min-width: 32px; min-height: 32px; display: grid; place-items: center;
  color: var(--aux); font-size: 18px; line-height: 1; letter-spacing: 0; border-radius: var(--radius-control);
}
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu[open] { position: absolute; right: 0; top: 36px; z-index: 4; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-float); padding: 6px; }
.more-menu .provenance, .more-menu .remove-pool { display: block; width: 100%; text-align: left; }
#deliveries { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#history-page { display: none; padding: 8px 32px 32px; }
body.show-history #app-shell, body.show-habits #app-shell, body.show-school #app-shell { display: none; }
body.show-history #history-page, body.show-habits #habits-page, body.show-school #school-page { display: block !important; }
#habits-page, #school-page { display: none; padding: 8px 32px 32px; }
.habit-create, .school-card, #school-teach { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; margin: 0 0 12px; }
.habit-create label, .habit-card form label, #school-teach label { display: flex; flex-direction: column; gap: .2rem; margin: 0 0 8px; font-size: 13px; color: var(--aux); }
.habit-create input, .habit-card form input, #school-teach textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--control); border-radius: var(--radius-control); min-height: 40px; padding: 0 12px; font: inherit; color: var(--ink); background: var(--card); }
#school-teach textarea { min-height: 96px; }
.school-card h3, .habit-card h3 { margin: 0 0 6px; font-size: 16px; }
.habit-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; margin: 0 0 12px; box-shadow: var(--shadow-card); }
.school-examples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.school-examples p { margin: 0; background: var(--inner); border-radius: 10px; padding: 8px 10px; }
.habit-actions, .school-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.habit-actions button, .school-actions button, .habit-create button, #school-teach button { min-height: 44px; }
.habit-prompt { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px 16px; margin: 0 0 12px; animation: habit-in 180ms var(--ease); }
.school-badge { display: inline-block; margin: 0 0 8px; border-radius: 999px; padding: .12rem .55rem; background: var(--inner); color: var(--body); font-size: 12px; }
.school-badge.is-live { background: var(--readybg); color: var(--ready); }
@keyframes habit-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .habit-prompt { animation: none; }
}
.pack-list { display: flex; flex-direction: column; gap: 12px; }
.pack-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 18px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; box-shadow: var(--shadow-card); }
.pack-main { min-width: 0; }
.pack-card h3, .hit-top h3, .habit-card h3 {
  margin: 0 0 4px; font-size: 16px; min-width: 0; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.hit-top h3 { margin: 0; }
.empty-note, #history-status.is-empty {
  margin: 0; background: var(--inner); border: 1px solid var(--border); border-radius: var(--radius-inner);
  padding: 16px; color: var(--body); box-shadow: var(--shadow-card);
}
select {
  appearance: none; background: var(--card); color: var(--ink); border: 1px solid var(--control);
  border-radius: var(--radius-control); min-height: 36px; padding: 0 12px; font: inherit;
}
.pack-main .meta { margin: 0 0 4px; }
.pack-money { text-align: right; font-family: var(--money); font-variant-numeric: tabular-nums; font-weight: 700; }
.pack-money p { margin: 0 0 4px; }
.pack-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.history-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 12px; }
.history-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.history-search { display: flex; gap: 12px; align-items: center; margin: 0 0 14px; }
.history-search input { flex: 1; appearance: none; background: var(--card); border: 1px solid var(--control); border-radius: var(--radius-card); min-height: 48px; padding: 0 14px; font: inherit; color: inherit; }
.hit-card { list-style: none; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; margin: 0; box-shadow: var(--shadow-card); }
.hit-card.is-selected { border-color: var(--charcoal); background: var(--selected); }
.hit-top { display: flex; align-items: center; gap: 10px; }
.hit-top h3 { flex: 1; margin: 0; font-size: 16px; min-width: 0; }
.hit-top .money { margin: 0; font-family: var(--money); font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.hit-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.hit-actions a.secondary, .pack-actions a.secondary { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.hit-more { position: relative; }
.hit-more summary { list-style: none; cursor: pointer; min-height: 32px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--card); display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; }
.hit-more summary::-webkit-details-marker { display: none; }
.hit-menu { position: absolute; z-index: 5; left: 0; top: calc(100% + 4px); min-width: 160px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(28,25,23,.10); padding: .35rem; }
.hit-menu a { display: block; min-height: 40px; line-height: 40px; padding: 0 .7rem; color: var(--ink); text-decoration: none; border-radius: 8px; }
#history-page.is-searched #history-browse { display: none; }
#history-export { margin: 0; padding: 0; border: 0; background: transparent; }
.reexport { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px; margin-top: 16px; }
.reexport h2 { margin: 0 0 8px; font-size: 18px; }
.reexport .primary { margin-top: 12px; }
#archive-total p { display: flex; justify-content: space-between; font-family: var(--money); font-weight: 700; margin: 8px 0; }
.history-footnote { margin-top: 12px; }
body.show-history .mobile-bar, body.show-habits .mobile-bar, body.show-school .mobile-bar { display: none !important; }
#issue-drawer { position: fixed !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: auto !important; width: 520px !important; max-width: 520px !important; height: 100dvh !important; max-height: none !important; margin: 0 !important; border: 0; padding: 0; background: var(--card); }
#issue-reason, #issue-items label { display: flex; align-items: center; gap: .4rem; min-height: 36px; }
#issue-reason { appearance: none; background: var(--card); border: 1px solid var(--control); border-radius: var(--radius-control); padding: 0 12px; min-height: 36px; font: inherit; color: inherit; }
.edit-fields {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; row-gap: 12px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); align-items: end;
}
.edit-fields[hidden] { display: none; }
.edit-fields label { display: flex; flex-direction: column; gap: 8px; font-size: 12px; font-weight: 600; line-height: 18px; color: var(--aux); min-width: 0; }
.edit-fields > button { width: 100%; margin-top: 4px; }
.financial-review {
  grid-column: 1 / -1; display: flex; flex-direction: column; gap: 10px;
  margin: 0 0 4px; padding: 12px; background: var(--errorbg); border: 1px solid var(--errorborder);
  border-radius: var(--radius-inner);
}
.financial-review h4 { margin: 0; font-size: 13px; line-height: 20px; color: var(--ink); }
.financial-field { display: flex; flex-direction: column; gap: 4px; }
.financial-headline, .financial-prompt { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink); }
.financial-value {
  margin: 0; font-family: var(--money); font-variant-numeric: tabular-nums;
  font-size: 18px; font-weight: 700; line-height: 28px; color: var(--ink);
}
.financial-reason, .financial-status { margin: 0; font-size: 12px; line-height: 18px; color: var(--aux); }
.financial-field.is-pending .financial-status { color: var(--error); font-weight: 700; }
.edit-fields label.financial-accept {
  flex-direction: row; align-items: center; gap: 8px; min-height: 32px;
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.edit-fields label.financial-accept input {
  width: 18px; height: 18px; min-height: 18px; padding: 0; flex: 0 0 auto;
}
.charcoal { background: var(--charcoal); color: #fff; border: 1px solid var(--charcoal); border-radius: var(--radius-control); min-height: 32px; padding: 0 12px; font-size: 13px; font-weight: 600; }
#remove-dialog, #batch-delete-dialog { border: 0; padding: 0; background: transparent; }
#remove-dialog::backdrop, #batch-delete-dialog::backdrop { background: rgba(28,25,23,.35); }
.remove-sheet { width: min(400px, calc(100% - 32px)); background: var(--card); border-radius: 12px; padding: 1rem; }
#original-page { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: 100vw; margin: 0; border: 0; padding: 0; }
.original-screen { min-height: 100dvh; background: var(--desk); display: flex; flex-direction: column; padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
.original-screen header { display: flex; align-items: center; gap: .6rem; min-height: 56px; padding: 0 1rem; background: var(--card); }
.mobile-bar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--card);
  border-top: 1px solid var(--border); padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  flex-direction: column; align-items: stretch; gap: .45rem;
}
.bar-line { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.mobile-money { font-family: var(--money); font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.mobile-confirm { width: 100%; }
#integration-keep { display: none; }
#operations { display: none !important; }
body.show-upload #integration-keep, body.show-history #integration-keep, body.show-habits #integration-keep { display: block; margin: 16px 32px 32px; }
body.show-upload #integration-keep > :not(#upload-section),
body.show-history #integration-keep > :not(#history-assistance),
body.show-habits #integration-keep > :not(#preferences) { display: none; }
@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "nav nav";
    height: auto; row-gap: 0; padding: 8px 16px 0;
  }
  .brand { grid-area: brand; }
  .top-actions { grid-area: actions; gap: .15rem; }
  .main-nav { grid-area: nav; justify-content: space-around; flex-wrap: wrap; }
  .nav-item { min-height: 44px; font-size: 14px; font-weight: 600; }
  .upload-label, .account-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #nav-upload::before { content: "↑"; font-size: 18px; }
  #nav-upload, .account-trigger { width: 44px; min-width: 44px; height: 44px; justify-content: center; padding: 0; }
  .work { display: block; }
  #original-desk { display: none; }
  .list-wrap, #items, .work, #app-shell { overflow: visible; height: auto; max-height: none; }
  .mobile-bar { display: flex; }
  #app-shell { padding: 8px 16px calc(148px + env(safe-area-inset-bottom)); }
  .summary-card { grid-template-columns: auto minmax(0, 1fr); align-items: center; padding: 14px 16px; }
  .summary-cell, .summary-cell + .summary-cell { min-height: 0; padding: 0; border-left: 0; }
  .summary-cell:nth-child(2) { grid-column: 2; grid-row: 1 / span 2; text-align: right; padding-left: 12px; border-left: 1px solid var(--border); }
  .kicker, #summary-lead, .review-chip { white-space: nowrap; }
  .review-chip { grid-column: 1; justify-self: start; margin-left: 0; padding-left: 12px; padding-right: 12px; }
  .currency-row { flex-direction: column; align-items: flex-end; justify-content: center; gap: .35rem; }
  #pool-summary #confirm { display: none; }
  .expense-card { padding: 14px; }
  .card-actions { display: flex; }
  .card-actions .view-source { flex: 1; }
  .card-actions > .edit-toggle { display: none; }
  .expense-card.is-preview .card-actions > .edit-toggle { display: inline-flex; align-items: center; justify-content: center; text-align: center; }
  .more-menu summary { min-width: 44px; min-height: 44px; }
  .edit-fields input, .edit-fields select { height: 44px; min-height: 44px; }
  .edit-fields > button { min-height: 44px; }
  .card-head { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
  .card-head .money { justify-self: end; }
  .list-toolbar { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  .list-toolbar strong, .toolbar-spacer, .desk-chip { display: none; }
  .batch-bar { flex-wrap: wrap; }
  .select-all, .batch-delete { min-height: 44px; }
  .mobile-only { display: block; }
  #filter-review { display: inline-flex; align-items: center; justify-content: center; width: 100%; }
  .chip-menu { position: relative; }
  .chip-menu summary { list-style: none; display: flex; align-items: center; justify-content: center; min-height: 44px; width: 100%; }
  .chip-menu summary::-webkit-details-marker { display: none; }
  .chip-menu summary::after { content: " ▾"; }
  .chip-panel { position: absolute; z-index: 6; right: 0; top: 48px; width: 168px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 24px rgba(28,25,23,.10); padding: .35rem; }
  .chip-panel button { display: block; width: 100%; min-height: 44px; text-align: left; background: var(--card); border: 0; border-radius: 8px; padding: 0 .7rem; }
  .chip, .card-actions .secondary, .review-chip, .nav-item, .account-trigger { min-height: 44px; }
  .edit-fields { grid-template-columns: 1fr; }
  #original-page { overflow: hidden; }
  #original-page .original-screen { height: 100dvh; min-height: 0; overflow: auto; }
  #original-page .paper { min-height: 0; flex: 0 1 auto; }
  #original-page .paper canvas { max-height: 340px; width: auto; max-width: 100%; margin: 0 auto; }
  #original-page .desk-nav,
  #original-page .page-tools { flex: 0 0 auto; position: relative; }
  #original-page .desk-nav { min-height: 44px; margin: 10px 16px 0; z-index: 2; }
  #original-page .page-tools { min-height: 104px; margin: 12px 16px 8px; gap: 10px; align-items: flex-start; z-index: 1; }
  #original-page .page-tools button {
    width: 72px; height: 104px; min-height: 104px; max-height: 104px; overflow: hidden; box-sizing: border-box;
  }
  #original-page .page-tools canvas { width: 62px; height: 74px; max-height: 74px; }
}
.intake-strip { margin: 0 0 12px; color: var(--aux); font-size: 13px; line-height: 21px; }
.intake-strip.is-live {
  position: relative; margin: 0 0 12px; padding: 12px 16px 16px; background: var(--card); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  font-weight: 600; line-height: 21px; overflow: hidden;
}
.intake-strip.is-live::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: 7px; height: 2px; border-radius: 999px;
  background-image: linear-gradient(90deg, rgba(15, 107, 96, 0), var(--primary), rgba(15, 107, 96, 0)), linear-gradient(var(--readybg), var(--readybg));
  background-size: 36% 100%, 100% 100%; background-repeat: no-repeat; background-position: -40% 0, 0 0;
  animation: intake-bar 1.6s var(--ease) infinite;
}
.case-sources { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.case-sources[hidden] { display: none; }
#upload-dialog {
  width: min(560px, calc(100vw - 32px)); max-width: calc(100vw - 32px); height: auto; max-height: calc(100dvh - 48px);
  margin: auto; border: 0; padding: 0; background: transparent; overflow: visible;
}
body:has(#export-drawer[open]) { overflow: hidden; }
#export-drawer {
  position: fixed !important; top: 0 !important; right: 0 !important; bottom: 0 !important; left: auto !important;
  width: 520px !important; max-width: 520px !important; height: 100dvh !important; max-height: none !important;
  margin: 0 !important; border: 0; padding: 0; background: var(--card); overflow: hidden;
  box-shadow: -8px 0 24px rgba(28,25,23,.10);
}
#upload-dialog::backdrop, #export-drawer::backdrop { background: rgba(28,25,23,.35); }
.upload-sheet, .export-sheet { box-sizing: border-box; width: 100%; border: 0; background: var(--card); color: var(--ink); padding: 20px; }
.upload-sheet { border-radius: var(--radius-card); max-height: calc(100dvh - 48px); overflow: auto; }
.export-sheet { height: 100dvh; border-radius: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.hint { color: var(--aux); font-size: 13px; margin: 0; }
.pending-picker {
  margin: 16px 0 4px; padding: 14px 14px 12px; background: var(--selected);
  border: 1px solid var(--primary); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
}
.pending-picker[hidden], .prior-intake[hidden] { display: none; }
.pending-count { margin: 0 0 10px; color: var(--ink); font-size: 16px; font-weight: 700; line-height: 24px; }
.pending-picker .file-rows { margin: 0; }
.pending-picker .file-row {
  background: var(--card); border-color: var(--border);
  grid-template-columns: minmax(0, 1fr) auto auto;
}
.prior-intake { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--border); }
.prior-label { margin: 0 0 4px; color: var(--aux); font-size: 13px; font-weight: 600; line-height: 21px; }
.prior-intake .hint { margin: 0 0 8px; }
.prior-intake .file-rows { margin-bottom: 0; }
.file-size { font-size: 12px; line-height: 18px; color: var(--aux); text-align: right; white-space: nowrap; }
.picker {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--card); color: var(--ink);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.file-rows { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-row {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(9em, 16em) auto; gap: 12px; align-items: center;
  background: var(--inner); border: 1px solid transparent; border-radius: var(--radius-inner); padding: 12px 14px;
}
.file-state { max-width: 16em; white-space: normal; text-align: right; }
.file-row:has(.file-state.is-processing) {
  background: var(--card); border-color: var(--border); box-shadow: var(--shadow-card); padding-bottom: 18px;
}
.file-row:has(.file-state.is-processing)::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 8px; height: 2px; border-radius: 999px;
  background-image: linear-gradient(90deg, rgba(15, 107, 96, 0), var(--primary), rgba(15, 107, 96, 0)), linear-gradient(var(--readybg), var(--readybg));
  background-size: 42% 100%, 100% 100%; background-repeat: no-repeat; background-position: -42% 0, 0 0;
  animation: intake-bar 1.5s var(--ease) infinite;
}
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 21px; color: var(--ink); }
.file-row.is-recovery {
  background: var(--obsbg); border-color: var(--obsborder); box-shadow: var(--shadow-card);
}
.file-row.is-recovery .file-state { color: var(--obs); font-weight: 600; }
.file-state { font-size: 12px; font-weight: 400; line-height: 18px; color: var(--aux); }
.file-state.is-processing { color: var(--ink); font-weight: 600; }
.intake-spin {
  width: 14px; height: 14px; margin-right: 8px; box-sizing: border-box; display: inline-block; vertical-align: -2px;
  border: 1.5px solid var(--readybg); border-top-color: var(--primary); border-radius: 50%;
  animation: intake-spin 1.2s linear infinite;
}
@keyframes intake-spin { to { transform: rotate(360deg); } }
@keyframes intake-bar { to { background-position: 142% 0, 0 0; } }
@keyframes export-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }
.export-spin {
  width: 14px; height: 14px; box-sizing: border-box; flex: none;
  border: 1.5px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: intake-spin 1.2s linear infinite;
}
.export-status.is-waiting {
  padding: 12px 14px 14px; background: var(--inner); border: 1px solid var(--border);
  border-radius: var(--radius-inner); box-shadow: var(--shadow-card);
}
.export-status.is-waiting #export-message {
  margin: 0 0 10px; color: var(--ink); font-weight: 600; line-height: 21px;
  animation: export-breathe 2.2s var(--ease) infinite;
}
.export-wait { height: 4px; border-radius: 999px; overflow: hidden; }
.export-wait-bar {
  display: block; height: 4px; border-radius: inherit;
  background-image: linear-gradient(90deg, rgba(15, 107, 96, 0), var(--primary), rgba(15, 107, 96, 0)), linear-gradient(var(--readybg), var(--readybg));
  background-size: 36% 100%, 100% 100%; background-repeat: no-repeat; background-position: -40% 0, 0 0;
  animation: intake-bar 1.6s var(--ease) infinite;
}
.view-source:disabled {
  opacity: 1; background: var(--inner); color: var(--ink); border-color: var(--control); cursor: default;
}
.file-state.is-retryable, .file-state.is-rejected, .file-state.is-recovery_required { color: var(--error); }
.file-state.is-in_pool { color: var(--ready); }
.scope-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.scope-list li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; min-width: 0; }
.scope-list li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-list strong { font-family: var(--money); font-variant-numeric: tabular-nums; white-space: nowrap; }
.scope-list.is-blocked li { color: var(--error); display: block; background: var(--errorbg); border-radius: 8px; padding: 8px 10px; }
.total-list p { display: flex; justify-content: space-between; margin: 0; font-family: var(--money); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; }
#export-files-toggle { display: none; }
.deliverable-links { display: flex; flex-wrap: wrap; gap: 8px; }
.deliverable-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius-control); color: var(--ink); text-decoration: none; background: var(--card); font-size: 13px; font-weight: 600; }
.s-panel { background: var(--inner); border-top: 1px solid var(--border); margin: 16px -16px -16px; padding: 16px; border-radius: 0 0 11px 11px; }
.s-head, .s-actions { display: flex; align-items: center; gap: 12px; }
.s-head { justify-content: space-between; margin-bottom: 8px; }
.s-body { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 12px; }
.s-thumb { display: inline-flex; align-items: center; justify-content: center; width: 80px; height: 104px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: #fff; color: var(--aux); }
.s-summary, .s-note { margin: 0 0 8px; color: var(--aux); font-size: 13px; }
.s-panel textarea { width: 100%; min-height: 88px; box-sizing: border-box; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--card); padding: 12px; font: inherit; color: var(--ink); }
@media (max-width: 900px) {
  body:has(#export-drawer[open]) { overflow: hidden; }
  #upload-dialog, #export-drawer { inset: 0 !important; left: 0 !important; right: 0 !important; width: 100vw !important; max-width: 100vw !important; height: 100dvh !important; margin: 0 !important; }
  .upload-sheet, .export-sheet { width: 100%; max-width: 100%; min-height: 100dvh; border-radius: 0; }
  #export-files-toggle { display: inline-flex; width: 100%; justify-content: center; }
  #export-files .deliverable-links { display: none; flex-direction: column; }
  #export-files.is-open .deliverable-links { display: flex; }
  .intake-strip, .case-sources { margin-left: 0; margin-right: 0; }
  .case-sources .file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .case-sources .file-name { flex: 1 1 88px; min-width: 72px; }
  .s-panel { margin: 12px -14px -14px; }
  #issue-drawer { left: 0 !important; right: 0 !important; width: 100vw !important; max-width: 100vw !important; }
  #history-page { padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }
}
#history-search { display: flex; gap: 12px; align-items: center; margin: 0 0 14px; }
#history-search input, #history-refresh, #history-export-refresh { appearance: none; background: var(--card); border: 1px solid var(--control); border-radius: var(--radius-card); min-height: 48px; padding: 0 14px; font: inherit; color: inherit; }
#history-search input { flex: 1; min-width: 0; }
.history-hits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
body.show-history #integration-keep, body.show-habits #integration-keep, body.show-school #integration-keep { display: none !important; }
@media (max-width: 900px) {
  #habits-page, #school-page { padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }
  .school-examples { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .history-tools, #history-search, .pack-actions { flex-direction: column; align-items: stretch; }
  #history-count { white-space: nowrap; }
  #history-search button, .pack-actions > .secondary, .hit-more summary, .reexport .primary { min-height: 44px; width: 100%; }
  .pack-actions .deliverable-links { width: 100%; }
  .pack-actions .deliverable-links a { flex: 1 1 30%; min-height: 44px; }
  .hit-actions { flex-wrap: wrap; }
  .hit-actions .secondary, .hit-more summary { min-height: 44px; }
  .pack-money, .hit-top .money { text-align: right; }
  .history-filters { display: flex; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
}
