:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --ink: #393a3d;
  --muted: #6b6c72;
  --line: #d4d7dc;
  --line-strong: #8d9096;
  --sidebar: #ffffff;
  --sidebar-ink: #393a3d;
  --sidebar-muted: #6b6c72;
  --green: #2ca01c;
  --green-hover: #248617;
  --green-active: #1b6b10;
  --green-soft: #e5f6e3;
  --green-soft-ink: #0d6b0a;
  --button: #2ca01c;
  --button-ink: #ffffff;
  --link: #0077c5;
  --link-hover: #005a96;
  --good: #0d7a12;
  --bad: #d52b1e;
  --good-bg: #e5f6e3;
  --good-ink: #0d6b0a;
  --bad-bg: #fdecea;
  --bad-ink: #a11d14;
  --mid-bg: #fff4e5;
  --mid-ink: #8a4b08;
  --shadow: 0 1px 2px rgba(15, 15, 20, 0.06), 0 0 0 1px rgba(15, 15, 20, 0.02);
  --sans: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 8px;
  --radius-control: 4px;
  --control-pad-y: 0.45rem;
  --control-pad-x: 0.6rem;
  --control-line: 1.45;
  --control-height: calc((var(--control-line) * 1em) + (var(--control-pad-y) * 2) + 2px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

.dev-banner {
  position: sticky;
  top: 0;
  z-index: 80;
  background: #c41212;
  color: #fff;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.4rem 0.75rem;
}
body.dev {
  --dev-banner-height: calc(env(safe-area-inset-top) + 2rem);
  padding-top: 0;
}
body.dev .dev-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: var(--dev-banner-height);
  margin-left: calc(-1 * env(safe-area-inset-left));
  margin-right: calc(-1 * env(safe-area-inset-right));
  padding: env(safe-area-inset-top) 0.75rem 0;
}
body.dev aside {
  top: var(--dev-banner-height);
  height: calc(100vh - var(--dev-banner-height));
  height: calc(100dvh - var(--dev-banner-height));
}
body.dev .shell {
  min-height: calc(100vh - var(--dev-banner-height));
  min-height: calc(100dvh - var(--dev-banner-height));
}

h1, h2, h3 {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--ink);
}

h1 { margin: 0 0 0.75rem; font-size: 1.7rem; }
h2 { margin: 0 0 0.55rem; font-size: 1.2rem; }
h3 { margin: 0 0 0.35rem; font-size: 1rem; }
p { margin: 0.35rem 0; }
a { color: var(--link); text-decoration: none; touch-action: manipulation; }
a:hover { color: var(--link-hover); text-decoration: underline; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.skip {
  position: absolute;
  left: -999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0.4rem 0.6rem;
}
.skip:focus { left: 0.5rem; top: calc(0.5rem + env(safe-area-inset-top)); z-index: 60; }

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: calc(100vh - env(safe-area-inset-top));
  min-height: calc(100dvh - env(safe-area-inset-top));
}

aside {
  position: sticky;
  top: 0;
  height: calc(100vh - env(safe-area-inset-top));
  height: calc(100dvh - env(safe-area-inset-top));
  overflow: auto;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-right: 1px solid var(--line);
  padding: 1rem 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

aside a { color: inherit; text-decoration: none; }
aside a:hover { text-decoration: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--green);
  padding: 0.15rem 0.45rem 0.35rem;
}
.brand::before {
  content: "";
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 6px;
  background-color: var(--green);
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3E%3Cpath%20fill='%23fff'%20d='M5%204.5h10.2a3.3%203.3%200%200%201%200%206.6H5V4.5zm0%208.4h12.2a3.3%203.3%200%200%201%200%206.6H5v-6.6z'/%3E%3Cpath%20stroke='%232ca01c'%20stroke-width='1.2'%20d='M5%204.5v15'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
}
.brand:hover { color: var(--green-hover); text-decoration: none; }

.user, .book { margin: 0; }
.user {
  color: var(--sidebar-muted);
  font-size: 0.85rem;
  padding: 0 0.55rem;
}
.nav.foot .user {
  padding: 0.45rem 0.65rem 0.1rem;
}
a.book {
  display: block;
  margin: 0.85rem 0.35rem 0.15rem;
  padding: 0.45rem 0.6rem;
  background: var(--bg);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
  text-decoration: none;
}
a.book:hover { background: #e7e9ee; color: var(--ink); text-decoration: none; }
a.book.active { background: var(--green-soft); color: var(--green-soft-ink); }

.nav { display: grid; gap: 0.1rem; margin-top: 0.55rem; }
.nav a, .nav button.linkish {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  color: var(--sidebar-ink);
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.nav a:hover, .nav button.linkish:hover {
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
}
.nav a.active {
  background: var(--green-soft);
  color: var(--green-soft-ink);
  font-weight: 700;
}
.nav a.active:hover { background: #d8f0d4; }
.nav a.sub { padding-left: 1.85rem; }
.nav-label {
  margin: 0.85rem 0 0.15rem;
  padding: 0 0.65rem;
  color: var(--sidebar-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav.foot {
  margin-top: auto;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.main {
  min-width: 0;
  max-width: 100%;
  padding: 1.5rem 1.75rem calc(3.5rem + env(safe-area-inset-bottom));
  overflow-wrap: anywhere;
}
.wrap { max-width: min(1080px, 100%); min-width: 0; }

.gate {
  min-height: calc(100vh - env(safe-area-inset-top));
  min-height: calc(100dvh - env(safe-area-inset-top));
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1rem;
  padding: 2rem 1rem 3rem;
  background: var(--bg);
}
.gate-brand { text-align: center; max-width: 26rem; }
.gate-brand .brand {
  font-size: 1.55rem;
  justify-content: center;
  padding-bottom: 0.15rem;
}
.gate-brand p { color: var(--muted); margin-top: 0.35rem; }
.gate .wrap { width: min(26rem, 100%); }
.gate .sheet { padding: 1.35rem 1.4rem 1.2rem; }
.gate button, .gate .button { width: 100%; text-align: center; }

.sheet, .empty, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
}
.empty { color: var(--muted); }
.cards + .sheet, .sheet + .form, form + .sheet { margin-top: 0.85rem; }
.main .sheet { margin-bottom: 0.85rem; }
.main .stats > .sheet,
.main .cards > .sheet,
.main .form > .sheet { margin-bottom: 0; }
.sheet-gap { margin-top: 0.85rem; }

.narrow {
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 2rem 1rem;
}
.narrow .card { width: min(28rem, 100%); }

.cards {
  list-style: none;
  padding: 0;
  margin: 0.7rem 0 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
  gap: 0.75rem;
  align-items: stretch;
}
.cards > li {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 6.5rem;
}
.card-main {
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
}
.cards > li .card-title::after {
  content: "";
  position: absolute;
  inset: 0;
}
.card-action { position: relative; z-index: 1; }
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-top: 0.85rem;
  position: relative;
  z-index: 1;
}
.card-actions .card-action,
.card-actions p,
.card-actions button { margin: 0; }
.sheet form + form, .sheet form + .note { margin-top: 0.85rem; }
.import-form { display: flex; flex-direction: column; gap: 0.75rem; }
.import-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.or-divider { margin: 0.85rem 0; text-align: center; color: var(--muted); font-size: 0.85rem; }
.name-row { display: flex; align-items: end; gap: 0.6rem; flex-wrap: wrap; }
.name-row label { flex: 1; min-width: 0; }
.card-title {
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: var(--ink);
}
.card-title:hover { color: var(--link); text-decoration: none; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 0.85rem 0 1.4rem;
}
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.figure {
  margin: 0.35rem 0 0;
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}
.note { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.in { color: var(--good); }
.out { color: var(--bad); }
.transfer { color: var(--muted); }

.title-row, .year-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.title-row h1, .title-row h2 { margin-bottom: 0; flex: 1; }
.title-row { margin-bottom: 0.85rem; }
.title-row form { display: flex; align-items: center; margin: 0; }
details.accounts-fold > summary {
  list-style: none;
}
details.accounts-fold > summary::-webkit-details-marker { display: none; }
details.accounts-fold > summary::marker { content: none; }
details.accounts-fold > summary h2::before { content: none; }
.year-nav { margin: 0.4rem 0 0.9rem; }
.year-nav span { font-weight: 700; font-size: 1.05rem; }

.form { display: grid; gap: 0.85rem; }
.row-2, .split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
[data-line-rows] {
  display: grid;
  gap: 0.85rem;
}
.line-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.15fr) minmax(6.5rem, 0.55fr) auto;
  gap: 0.6rem;
  align-items: end;
}
.line-row label { gap: 0.12rem; line-height: 1.15; }
.line-row > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tx-meta-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 0.9fr 0.9fr 1.3fr;
  gap: 0.55rem 0.65rem;
  align-items: start;
}
.tx-meta-grid .tx-party { grid-column: 1 / -1; }
/* The duplicate-check note grows the reference label in place; top alignment keeps the row's controls level. */
.tx-meta-grid .ref-duplicate {
  margin: 0;
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
}
.tx-lines {
  display: grid;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem 0.95rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
h2.tx-section {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}
.tx-lines .line-total { margin: 0; }
.tx-lines .note { margin: 0; }
.tx-lines > button { justify-self: start; }
.default-kind { max-width: 16rem; }
.default-fields {
  display: grid;
  grid-template-columns: minmax(0, 16rem) minmax(0, 22rem);
  gap: 0.85rem;
  align-items: end;
}
[data-amount-field] {
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
}
.line-total {
  margin: 0.35rem 0 0.45rem;
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.line-total [data-line-total] {
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}
.tx-summary {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr);
  gap: 0.75rem 1.5rem;
  align-items: start;
}
.tx-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem 1.1rem;
  margin: 0;
}
.tx-facts div { min-width: 0; }
.tx-facts dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.tx-facts dd { margin: 0.12rem 0 0; font-weight: 600; }
.tx-facts .tx-wide { grid-column: 1 / -1; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
dialog.popup {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem 1.2rem;
  width: min(34rem, calc(100% - 1.25rem - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-width: calc(100vw - 1.25rem - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-height: calc(100dvh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  box-shadow: 0 18px 48px rgba(15, 15, 20, 0.2);
  color: var(--ink);
  background: var(--surface);
}
dialog.popup::backdrop { background: rgba(15, 15, 20, 0.45); }
dialog.popup h2 { margin-top: 0; }
.combo { position: relative; }
.combo-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.combo-button {
  display: flex;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: var(--control-pad-y) 1.7rem var(--control-pad-y) 0.6rem;
  font-weight: 500;
  align-items: center;
  position: relative;
}
.combo-button::after {
  content: "";
  position: absolute;
  right: 0.65rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
}
.combo-button:hover { background: #fff; color: var(--ink); border-color: #6b6c72; }
.combo-panel {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 15, 20, 0.16);
  padding: 0.4rem;
}
.combo-scrim {
  position: fixed;
  inset: 0;
  z-index: 45;
  margin: 0;
  border: 0;
  padding: 0;
  background: rgba(15, 15, 20, 0.45);
  cursor: pointer;
}
.combo-panel.combo-sheet {
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
  padding: 0.55rem 0.55rem calc(0.55rem + env(safe-area-inset-bottom));
  border-radius: 12px;
}
.combo-panel.combo-sheet .combo-list {
  max-height: none;
  min-height: 0;
  flex: 1 1 auto;
}
.combo-search { margin-bottom: 0.35rem; }
.combo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
}
.combo-group {
  margin: 0.35rem 0.45rem 0.1rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.combo-list button,
.combo-add {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-control);
  padding: 0.38rem 0.5rem;
  font-weight: 500;
}
.combo-list button { white-space: pre-wrap; }
.combo-list button[aria-selected="true"],
.combo-list button:hover,
.combo-add:hover {
  background: var(--green-soft);
  color: var(--ink);
}
.combo-add { color: var(--link); font-weight: 700; }
.combo-empty { margin: 0.35rem 0.45rem; color: var(--muted); }
.js-only { display: none; }
html.js .js-only { display: inline-block; }
html.js .delete-fallback { display: none; }
.ledger-delete-bottom { display: none; }
html.js .title-row > button.ledger-delete { display: none; }
html.js .ledger-delete-bottom {
  display: block;
  margin-top: 1.25rem;
}
html.js button.nav-keys {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0.35rem 0 0 0.35rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
  flex: none;
}
html.js button.nav-keys:hover,
html.js button.nav-keys:active {
  background: var(--bg);
  color: var(--ink);
}
html.js button.nav-keys svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shortcut-groups { display: grid; gap: 0.9rem; margin: 0 0 1rem; }
.shortcut-group h3 {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.ledger-notes {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.shortcuts { display: grid; gap: 0.45rem; margin: 0; }
.shortcuts > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 1.25rem;
  align-items: baseline;
}
.shortcuts dt, .shortcuts dd { margin: 0; }
.shortcuts dt { white-space: nowrap; }
.shortcuts kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05rem 0.38rem;
  background: var(--bg);
  color: var(--ink);
}
.shortcut-plus { margin: 0 0.18rem; color: var(--muted); }
tr.click-row { cursor: pointer; }
tr.click-row a.stretch { color: inherit; font-weight: 600; text-decoration: none; }
tr.click-row:hover a.stretch { color: var(--link); text-decoration: underline; }
tr.today-divider td {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid #eceef1;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
tr.today-divider:hover td { background: transparent; }

label { display: grid; gap: 0.3rem; font-size: 0.92rem; font-weight: 600; color: var(--ink); }
label.check { display: flex; align-items: center; grid-template-columns: none; font-weight: 500; }
label.check input { width: auto; }
th.check, td.check { width: 2.2rem; text-align: center; }
td.check input { width: auto; }
tr.is-parent td { font-weight: 700; }
details.adder {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem 0.75rem;
  background: var(--surface);
}
details.adder summary { cursor: pointer; font-weight: 700; }
.adder-fields { display: grid; gap: 0.7rem; margin-top: 0.75rem; }
.exports { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.15rem 0 0.9rem; }
.contact-address, .memo-text { white-space: pre-line; overflow-wrap: anywhere; }

input, select, textarea, button, .button, label, summary { font: inherit; touch-action: manipulation; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  padding: var(--control-pad-y) var(--control-pad-x);
  line-height: var(--control-line);
  font-weight: 500;
}
input:not([type="checkbox"]):not([type="radio"]),
select,
.combo-button,
.line-row > button {
  min-height: var(--control-height);
  line-height: var(--control-line);
}
input:not([type="checkbox"]):not([type="radio"]):disabled,
textarea:disabled {
  background: #f4f5f8;
  color: var(--ink);
  opacity: 1;
  cursor: default;
}
input:hover, select:hover, textarea:hover { border-color: #6b6c72; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--link);
  outline-offset: 0;
  border-color: var(--link);
}
/* iOS date fields treat width as the content box, so the horizontal padding
   sticks out on the right (WebKit 301648). The border stays inside.
   Desktop and Android already honor border-box. */
@supports (-webkit-touch-callout: none) {
  @media (hover: none) and (pointer: coarse) {
    input[type="date"] {
      width: calc(100% - (2 * var(--control-pad-x)));
      max-width: calc(100% - (2 * var(--control-pad-x)));
    }
  }
}
textarea { min-height: 5.5rem; resize: vertical; }
button, .button {
  display: inline-block;
  width: fit-content;
  background: var(--button);
  color: var(--button-ink);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: var(--control-pad-y) 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.3;
}
button:hover, .button:hover {
  background: var(--green-hover);
  color: var(--button-ink);
  text-decoration: none;
}
button:active, .button:active { background: var(--green-active); }
button.secondary, .button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}
button.secondary:hover, .button.secondary:hover {
  background: var(--bg);
  color: var(--ink);
  border-color: #6b6c72;
}
button.danger { background: var(--bad); color: #fff; border-color: transparent; }
button.danger:hover { background: #b32218; color: #fff; }
button.outline {
  background: #fff;
  color: var(--button);
  border-color: var(--button);
}
button.outline:hover { background: var(--green-soft); color: var(--green-soft-ink); }
button.outline:active { background: #d8f0d4; color: var(--green-soft-ink); }
button.danger-outline {
  background: #fff;
  color: var(--bad);
  border-color: var(--bad);
}
button.danger-outline:hover,
button.danger-outline:active { background: var(--bad-bg); color: var(--bad); }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.form-actions .end { margin-left: auto; }
.danger-zone { border-color: #f3c1bb; }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin: 0.2rem 0 1rem;
}
.filter-form label { min-width: 9rem; font-weight: 600; }
.filter-form button { margin-bottom: 0.05rem; }
.transactions-filter label:has(select[name="account"]),
.transactions-filter label:has(select[name="category"]),
.transactions-filter label:has(select[name="contact"]) {
  flex: 1 1 9rem;
}

.presets { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.15rem 0 0.7rem; }
.chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  border-radius: 999px;
  padding: 0.22rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.chip:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.chip.active {
  background: var(--green-soft);
  color: var(--green-soft-ink);
  border-color: #b7e2b2;
}
.chip.active:hover { background: #d8f0d4; color: var(--green-soft-ink); }
.range-label { margin-top: 0.2rem; color: var(--muted); }

.alert { padding: 0.7rem 0.85rem; border-radius: var(--radius); margin: 0 0 0.9rem; border: 1px solid transparent; }
.alert.ok { background: var(--good-bg); color: var(--good-ink); border-color: #b7e2b2; }
.alert.err { background: var(--bad-bg); color: var(--bad-ink); border-color: #f3c1bb; }
.alert.deleted { background: var(--bad-bg); color: var(--bad-ink); border-color: #f3c1bb; }
.alert.deleted .eyebrow { color: var(--bad); font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase; }
.alert.deleted p:last-child { margin: 0.15rem 0 0; }

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  contain: inline-size;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.table-wrap.sheet { padding: 0.25rem 0.35rem 0.15rem; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 0.55rem 0.55rem;
  border-bottom: 1px solid #eceef1;
  vertical-align: baseline;
}
tbody tr:last-child td { border-bottom: 0; }
.audit-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.audit-line form { margin: 0; flex: none; }
.audit-log table { width: 100%; }
.audit-log th:nth-child(-n+2),
.audit-log td:nth-child(-n+2) {
  width: 1%;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.category-totals th:nth-child(2),
.category-totals tbody td:nth-child(2) {
  width: 1%;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
@media (hover: hover) {
  tbody tr:hover td { background: #f7f8fa; }
  .tx-scroll tbody tr:hover td:first-child { background: #f7f8fa; }
}
th {
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--muted);
  font-weight: 700;
  background: transparent;
}
td.num, th.num { text-align: right; white-space: nowrap; }
.tx-scroll table {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  table-layout: fixed;
}
.tx-scroll col.fit-date { width: 8rem; }
.tx-scroll col.fit-method { width: 4.75rem; }
.tx-scroll col.fit-reference { width: 5.5rem; }
.tx-scroll col.fit-money { width: 10rem; }
.tx-scroll col.fit-mark { width: 2.5rem; }
.tx-scroll th,
.tx-scroll td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.tx-scroll td.tx-clip > span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
th.recon-col, td.recon-col {
  padding-left: 0.3rem;
  padding-right: 0.35rem;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}
.tx-scroll th.file-col,
.tx-scroll td.file-col,
.tx-scroll th.recon-col,
.tx-scroll td.recon-col {
  width: auto;
}
th.recon-col .recon-mark { color: var(--muted); }
td.recon-col .recon-mark { color: var(--green); }
.recon-mark {
  display: inline-flex;
  line-height: 1;
  vertical-align: middle;
}
.recon-mark svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}
th.file-col, td.file-col {
  width: 1px;
  padding-left: 0.3rem;
  padding-right: 0.4rem;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}
.file-mark {
  color: var(--muted);
  display: inline-flex;
  line-height: 1;
  vertical-align: middle;
}
.file-mark svg {
  width: 0.85rem;
  height: 0.85rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.files { color: var(--muted); font-size: 0.85rem; }
ul.files img, .files img {
  display: block;
  max-width: min(420px, 100%);
  margin-top: 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
ul.plain, ul.files { list-style: none; padding: 0; margin: 0.3rem 0 0.8rem; }
ul.plain li, ul.files li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid #eceef1;
}
ul.plain a.row-end { margin-left: auto; white-space: nowrap; }
button.drag-handle {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.55rem;
  margin: 0 0.15rem 0 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  flex: none;
  vertical-align: middle;
}
button.drag-handle:hover,
button.drag-handle:active {
  background: #eef1f4;
  color: var(--ink);
}
button.drag-handle:active { cursor: grabbing; }
.grip {
  display: block;
  width: 10px;
  height: 16px;
  background-image: radial-gradient(currentColor 1.15px, transparent 1.3px);
  background-size: 5px 5.4px;
  background-position: center;
  background-repeat: repeat;
}
body.is-reordering { cursor: grabbing; user-select: none; }
td .drag-handle { margin-right: 0.35rem; }
.order-placeholder {
  box-sizing: border-box;
  background: #e8f3fc;
  border: 1px dashed var(--link);
  border-radius: var(--radius);
  list-style: none;
}
tr.order-placeholder td {
  background: #e8f3fc;
  border-bottom: 0;
  padding: 0;
}
.drag-ghost {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  margin: 0;
  padding: 0.3rem 0.55rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 700;
  transform: translate(10px, 12px);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button.secondary:disabled:hover {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}
ul.plain li.depth-1 { margin-left: 1.35rem; }
ul.plain li.depth-2 { margin-left: 2.85rem; }
ul.plain li.depth-1,
ul.plain li.depth-2 {
  border-left: 3px solid var(--line);
  padding-left: 0.7rem;
}
td.depth-1 { padding-left: 1.9rem; }
td.depth-2 { padding-left: 3.5rem; }
form.inline { display: inline; }
.archived { opacity: 0.72; }

.pill, .status {
  display: inline-block;
  border-radius: var(--radius-control);
  padding: 0.08rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  background: #eceef1;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.status-under, .status-met { background: var(--good-bg); color: var(--good-ink); }
.status-close { background: var(--mid-bg); color: var(--mid-ink); }
.status-over, .status-behind { background: var(--bad-bg); color: var(--bad-ink); }
.status-none { background: #eceef1; color: var(--muted); }

.facts { margin: 0; }
.facts div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid #eceef1;
}
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.topbar, .nav-scrim { display: none; }

@media (max-width: 860px) {
  body.signed-in { padding: 0; }
  .shell { grid-template-columns: 1fr; min-width: 0; max-width: 100%; }
  body.dev .topbar {
    top: var(--dev-banner-height);
    height: 3.5rem;
    padding-top: 0;
  }
  body.dev .nav-scrim,
  body.dev aside {
    top: calc(var(--dev-banner-height) + 3.5rem);
    height: auto;
  }
  .topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 30;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    max-width: 100%;
    height: calc(env(safe-area-inset-top) + 3.5rem);
    padding: env(safe-area-inset-top) calc(0.7rem + env(safe-area-inset-right)) 0 calc(0.85rem + env(safe-area-inset-left));
    background: var(--sidebar);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand {
    flex: none;
    font-size: 1rem;
    padding: 0.2rem 0.15rem;
  }
  .topbar-ledger {
    display: block;
    flex: 1 1 0%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
  }
  a.book {
    flex-shrink: 0;
    overflow: visible;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.35;
  }
  .topbar-ledger.active { color: var(--green-soft-ink); }
  .topbar-ledger:hover { color: var(--link); text-decoration: none; }
  .menu-button {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    margin: 0;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    background: #fff;
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
  }
  .menu-button:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
  .nav-toggle {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }
  .nav-toggle:focus { outline: none; }
  .menu-bars {
    width: 1.05rem;
    height: 0.8rem;
    background:
      linear-gradient(currentColor, currentColor) 0 0 / 100% 2px,
      linear-gradient(currentColor, currentColor) 0 50% / 100% 2px,
      linear-gradient(currentColor, currentColor) 0 100% / 100% 2px;
    background-repeat: no-repeat;
  }
  .nav-scrim {
    display: block;
    position: fixed;
    z-index: 35;
    top: calc(env(safe-area-inset-top) + 3.5rem);
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(15, 15, 20, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 160ms ease, visibility 0s linear 160ms;
  }
  body:has(#nav-toggle:checked) .nav-scrim {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 160ms ease;
  }
  aside {
    position: fixed;
    z-index: 40;
    top: calc(env(safe-area-inset-top) + 3.5rem);
    bottom: 0;
    left: 0;
    width: min(19rem, calc(100% - 3.25rem));
    height: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    padding-top: 0.85rem;
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
    padding-left: calc(0.75rem + env(safe-area-inset-left));
    transform: translateX(-105%);
    visibility: hidden;
    overflow: auto;
    overscroll-behavior: contain;
    box-shadow: none;
    transition: transform 160ms ease, visibility 0s linear 160ms;
  }
  body:has(#nav-toggle:checked) aside {
    transform: none;
    visibility: visible;
    box-shadow: 0 12px 32px rgba(15, 15, 20, 0.18);
    transition: transform 160ms ease;
  }
  body:has(#nav-toggle:checked),
  body.combo-open {
    overflow: hidden;
    overscroll-behavior: none;
  }
  aside .brand { display: none; }
  .nav, .nav.foot { display: grid; margin-top: 0.35rem; }
  .nav.foot {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding-top: 0.7rem;
    width: auto;
  }
  .nav a, .nav button.linkish {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
  .stats, .row-2, .split, .facts div, .tx-facts { grid-template-columns: 1fr 1fr; }
  .tx-meta-grid { grid-template-columns: 1fr 1fr; }
  .tx-summary { grid-template-columns: 1fr; }
  .tx-lines { padding: 0.7rem; gap: 0.65rem; }
  .line-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem;
    padding: 0.75rem 0.75rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .line-row > label:nth-child(1),
  .line-row > label:nth-child(2) { grid-column: 1 / -1; }
  .line-items table,
  .line-items tbody { display: block; width: 100%; }
  .line-items thead { display: none; }
  .line-items tr {
    display: grid;
    gap: 0.45rem;
    margin: 0 0 0.7rem;
    padding: 0.75rem 0.8rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }
  .line-items tr:last-child { margin-bottom: 0; }
  .line-items td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }
  .line-items td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.08rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
  }
  .line-items td[data-label="Description"]:empty { display: none; }
  .line-items td[data-label="Amount"] {
    font-weight: 700;
    font-size: 1.05rem;
  }
  .main { padding: 1rem calc(0.9rem + env(safe-area-inset-right)) calc(3rem + env(safe-area-inset-bottom)) calc(0.9rem + env(safe-area-inset-left)); }
  .gate { padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom)); }
  .gate .main { padding: 0 0 calc(1rem + env(safe-area-inset-bottom)); }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea,
  .combo-button,
  .combo-search { font-size: 16px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
  select,
  .combo-button,
  .combo-search { min-height: 44px; }
  button:not(.drag-handle),
  .button,
  .chip,
  html.js button.js-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
  }
  html.js button.nav-keys {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .chip { padding: 0.4rem 0.85rem; }
  .combo-list button,
  .combo-add {
    justify-content: flex-start;
    min-height: 44px;
    padding: 0.65rem 0.75rem;
  }
  .title-row > h1,
  .title-row > h2,
  .stats,
  .stats > .sheet,
  .cards,
  .cards > li,
  ul.plain,
  ul.files,
  ul.plain li,
  ul.files li,
  ul.plain li > a,
  ul.files li > a,
  .filter-form,
  .presets { min-width: 0; max-width: 100%; }
  .table-wrap.cards-narrow {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  .cards-narrow table,
  .cards-narrow tbody,
  .cards-narrow tfoot {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .cards-narrow thead { display: none; }
  .cards-narrow tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.12rem 0.75rem;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eceef1;
  }
  .cards-narrow tbody tr:last-child,
  .cards-narrow tfoot tr:last-child { border-bottom: 0; }
  .cards-narrow td {
    display: block;
    grid-column: 1 / -1;
    min-width: 0;
    max-width: 100%;
    padding: 0.12rem 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }
  .cards-narrow td.num { text-align: left; white-space: normal; }
  .cards-narrow td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.08rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
  }
  .cards-narrow td[data-label="Date"],
  .cards-narrow td[data-label="Statement date"] {
    grid-column: 1;
    grid-row: 1;
    font-weight: 700;
  }
  .cards-narrow td[data-label="Date"]::before,
  .cards-narrow td[data-label="Statement date"]::before,
  .cards-narrow td[data-label="Amount"]::before,
  .cards-narrow td[data-label="Party"]::before,
  .cards-narrow td[data-label="Details"]::before { content: none; }
  .cards-narrow tr:has(td[data-label="Date"]) td[data-label="Amount"],
  .cards-narrow tr:has(td[data-label="Statement date"]) td[data-label="Amount"] {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 0;
    white-space: nowrap;
  }
  .cards-narrow td[data-label="Party"] { font-weight: 600; }
  .cards-narrow td[data-label="Reference"]:empty,
  .cards-narrow td.file-col:empty,
  .cards-narrow td.recon-col:empty { display: none; }
  .tx-scroll.cards-narrow td,
  .tx-scroll.cards-narrow th {
    overflow: visible;
    text-overflow: clip;
  }
  .tx-scroll.cards-narrow td.tx-clip > span {
    display: inline;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
  .tx-scroll.cards-narrow td.num { white-space: nowrap; }
  .cards-narrow td:has(input)::before { margin-bottom: 0.3rem; }
  .cards-narrow tr:has(td.check) { grid-template-columns: auto minmax(0, 1fr) auto; }
  .cards-narrow tr:has(td.check) td.check {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    padding: 0;
  }
  .cards-narrow tr:has(td.check) td[data-label="Date"] { grid-column: 2; }
  .cards-narrow tr:has(td.check) td[data-label="Amount"] { grid-column: 3; }
  .cards-narrow tfoot tr {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .cards-narrow tfoot td { width: auto; font-weight: 700; }
  .cards-narrow tfoot td::before { content: none; }
  .cards-narrow tfoot td:empty { display: none; }
  details.accounts-fold > summary { cursor: pointer; }
  details.accounts-fold > summary h2 {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
  }
  details.accounts-fold > summary h2::before {
    content: "";
    display: block;
    flex: none;
    width: 0.7rem;
    height: 0.7rem;
    background: currentColor;
    transform: translateY(0.08em);
    clip-path: polygon(20% 10%, 85% 50%, 20% 90%);
  }
  details.accounts-fold[open] > summary h2::before {
    clip-path: polygon(10% 25%, 90% 25%, 50% 85%);
  }
}

@media (min-width: 861px) {
  .tx-meta-grid .tx-party {
    justify-self: start;
    width: 33%;
  }
  details.accounts-fold {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.75rem;
    align-items: center;
  }
  details.accounts-fold > summary {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }
  details.accounts-fold:not([open])::details-content,
  details.accounts-fold::details-content {
    display: contents;
    content-visibility: visible;
  }
  details.accounts-fold > .button {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }
  details.accounts-fold > .cards,
  details.accounts-fold > .empty {
    grid-column: 1 / -1;
  }
  details.accounts-fold > summary {
    cursor: default;
    pointer-events: none;
  }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .figure { font-size: clamp(0.95rem, 3.8vw, 1.35rem); white-space: normal; }
  .facts div { grid-template-columns: minmax(5.5rem, 42%) minmax(0, 1fr); gap: 0.35rem; }
  .tx-facts, .tx-meta-grid, .row-2, .split, .default-fields { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
  .title-row { align-items: stretch; }
  .title-row > h1,
  .title-row > h2 { flex: 1 1 100%; }
  .title-row > .button,
  .title-row > button {
    flex: 1 1 calc(50% - 0.75rem);
    text-align: center;
  }
  details.accounts-fold > .button {
    width: 100%;
    text-align: center;
  }
  .filter-form { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-form label { min-width: 0; }
  .filter-form label:has(select),
  .filter-form label:has(input[name="q"]),
  .filter-form > button { grid-column: 1 / -1; }
  .filter-form > button { width: 100%; }
  dialog.popup .dialog-actions { display: grid; grid-template-columns: 1fr; }
  dialog.popup .dialog-actions button { width: 100%; text-align: center; }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .form-actions .end { grid-column: 1 / -1; margin-left: 0; }
  .form-actions > button,
  .form-actions > form,
  .form-actions form button { width: 100%; text-align: center; }
  ul.plain li .note { flex-basis: 100%; }
  ul.plain li.depth-1 { margin-left: 0.75rem; }
  ul.plain li.depth-2 { margin-left: 1.5rem; }
  td.depth-1 { padding-left: 1.15rem; }
  td.depth-2 { padding-left: 2rem; }
  .audit-line { align-items: flex-start; flex-wrap: wrap; }
  .audit-line form { margin-left: auto; }
}

@media (max-width: 400px) {
  .topbar .brand {
    width: 44px;
    height: 44px;
    justify-content: center;
    padding: 0;
    font-size: 0;
  }
}

@media (hover: none) {
  tr.click-row:active td { background: #f3f8f2; }
}

@media (pointer: coarse) {
  html.js button.nav-keys,
  button.drag-handle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  td.check input[type="checkbox"],
  label.check input[type="checkbox"] {
    width: 1.35rem;
    height: 1.35rem;
  }
  th.check, td.check { width: 2.75rem; }
  th, td { padding-top: 0.7rem; padding-bottom: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  aside, .nav-scrim { transition: none; }
}

@media print {
  aside, .presets, .filter-form, .noprint, .gate-brand, .skip, .topbar, .nav-scrim, .dev-banner { display: none !important; }
  .shell { display: block; }
  body { background: white; color: black; padding-top: 0; }
  .sheet, .card, .line-row { box-shadow: none; }
  .tx-lines { background: none; }
  .line-items table { display: table; width: 100%; }
  .line-items thead { display: table-header-group; }
  .line-items tbody { display: table-row-group; }
  .line-items tr {
    display: table-row;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
  }
  .line-items td { display: table-cell; }
  .line-items td::before { content: none; }
  .line-items td[data-label="Description"]:empty { display: table-cell; }
  a { color: black; text-decoration: none; }
  .cards-narrow { overflow: visible; padding: 0; }
  .cards-narrow table { display: table; }
  .cards-narrow thead { display: table-header-group; }
  .cards-narrow tbody { display: table-row-group; }
  .cards-narrow tfoot { display: table-footer-group; }
  .cards-narrow tr { display: table-row; }
  .cards-narrow td { display: table-cell; }
  .cards-narrow td::before { content: none; }
  .tx-scroll table { width: 100%; min-width: 0; max-width: none; table-layout: auto; }
  .tx-scroll th,
  .tx-scroll td { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; }
  .tx-scroll td.tx-clip,
  .tx-scroll td.tx-clip > span {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
  .tx-scroll th:first-child,
  .tx-scroll td:first-child { position: static; box-shadow: none; }
  details.accounts-fold > summary h2::before { content: none; display: none; }
  details.accounts-fold::details-content { content-visibility: visible; }
}
