@font-face {
  font-family: Anuphan;
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url("/fonts/anuphan.ttf") format("truetype");
}
:root {
  --bg: #f7f7f6;
  --surface: #ffffff;
  --ink: #171717;
  --muted: #5a5a56;
  --faint: #6a6a67;
  --line: #e7e7e4;
  --fill: #f0f0ee;
  --accent: #f26a1b;
  --tick: #dededb;
  --in: #13773a;
  --in-soft: #e3f3e9;
  --bad: #c0392f;
  --bad-soft: #f9e7e4;
  --wait: #a86400;
  --fix: #4a55b8;
  --fix-soft: #e9ebf9;
  --veil: rgb(23 23 23 / 0.32);
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --gap: 16px;
  --pad: 32px;
  --row: 56px;
  --side: 260px;
  --t-tab: 0.8125rem;
  --t-meta: 0.875rem;
  --t-body: 1rem;
  --t-lead: 1.125rem;
  --t-h2: 1.25rem;
  --t-stat: 1.75rem;
  --t-title: 2rem;
  --t-amount: 2.25rem;
  --font:
    Anuphan, "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  color-scheme: light;
}
html {
  accent-color: var(--ink);
  caret-color: var(--accent);
  scrollbar-color: var(--tick) transparent;
}
:root[data-theme="dark"] {
  --bg: #141413;
  --surface: #1c1c1b;
  --ink: #f2f2f0;
  --muted: #a3a39e;
  --faint: #92928d;
  --line: #2d2d2b;
  --fill: #262624;
  --accent: #ff7d33;
  --tick: #3a3a37;
  --in: #5fcf95;
  --in-soft: #16301f;
  --bad: #f08379;
  --bad-soft: #3a1c18;
  --wait: #e2a84a;
  --fix: #9ba4f4;
  --fix-soft: #1f2344;
  --veil: rgb(0 0 0 / 0.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #141413;
    --surface: #1c1c1b;
    --ink: #f2f2f0;
    --muted: #a3a39e;
    --faint: #92928d;
    --line: #2d2d2b;
    --fill: #262624;
    --accent: #ff7d33;
    --tick: #3a3a37;
    --in: #5fcf95;
    --in-soft: #16301f;
    --bad: #f08379;
    --bad-soft: #3a1c18;
    --wait: #e2a84a;
    --fix: #9ba4f4;
    --fix-soft: #1f2344;
    --veil: rgb(0 0 0 / 0.55);
    color-scheme: dark;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
::selection {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 6px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2 {
  font-weight: 600;
  line-height: 1.3;
  text-wrap: balance;
}
h1 {
  font-size: var(--t-title);
}
h2 {
  font-size: var(--t-h2);
}
[hidden] {
  display: none !important;
}
.ic {
  flex: none;
  width: 20px;
  height: 20px;
}
.num {
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: var(--t-meta);
}
.in {
  color: var(--in);
}
.bad {
  color: var(--bad);
}
.wait {
  color: var(--wait);
}
.fix {
  color: var(--fix);
}
.right {
  text-align: right;
  justify-content: flex-end;
}
.dot:before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 7px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

/* Shell */
.frame {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  min-height: 100dvh;
}
.frame[data-nav="collapsed"] {
  --side: 76px;
}
.side {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 18px;
  border-bottom: 1px solid var(--line);
}
.mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--surface);
}
.brand-name {
  flex: 1;
  min-width: 0;
  font-size: var(--t-lead);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  color: var(--faint);
}
.side-toggle:hover {
  background: var(--fill);
  color: var(--ink);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-label {
  padding: 0 8px 6px;
  font-size: var(--t-meta);
  color: var(--faint);
}
.nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--muted);
  white-space: nowrap;
}
.nav button .ic {
  color: var(--faint);
}
.nav button:hover {
  background: var(--fill);
}
.nav [aria-current="page"] {
  background: var(--fill);
  color: var(--ink);
  font-weight: 600;
}
.nav [aria-current="page"] .ic {
  color: var(--ink);
}
.frame[data-nav="collapsed"] .brand {
  flex-direction: column;
  padding-inline: 0;
}
.frame[data-nav="collapsed"] .brand-name,
.frame[data-nav="collapsed"] .nav-label,
.frame[data-nav="collapsed"] .nav button span {
  display: none;
}
.frame[data-nav="collapsed"] .nav button {
  justify-content: center;
  padding: 0;
}
.frame[data-nav="collapsed"] .side-toggle {
  transform: scaleX(-1);
}
.main {
  min-width: 0;
  padding: 20px var(--pad) 64px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1360px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px 16px;
  flex-wrap: wrap;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-meta);
  color: var(--faint);
}
.crumbs span:not(.sep) {
  padding: 3px 10px;
  border-radius: var(--r-sm);
  background: var(--fill);
}
.crumbs .here {
  color: var(--ink);
}
.tools {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
  font-size: var(--t-meta);
  max-width: 100%;
}
.tools select {
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.user-menu {
  position: relative;
  max-width: 100%;
  margin-left: auto;
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 40px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--r-md);
}
.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: var(--fill);
}
.user-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--muted);
}
.user-name {
  max-width: min(240px, 50vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.user-menu-caret {
  color: var(--muted);
}
.user-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(280px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}
.user-menu-item {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
}
.user-menu-item:hover:not(:disabled) {
  background: var(--fill);
}
.user-menu-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 10px;
}
.user-menu-setting select {
  min-width: 0;
}
.theme-options {
  min-width: 0;
  margin: 0;
  padding: 0 4px;
  border: 0;
}
.theme-options legend {
  padding: 0 0 8px 6px;
  color: var(--muted);
}
.theme-segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--fill);
}
.theme-segments label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}
.theme-segments input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.theme-segments input + span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 60px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--muted);
}
.theme-segments input:checked + span {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}
.theme-segments input:hover + span {
  color: var(--ink);
}
.theme-segments input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
#user-menu-logout {
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}
.status {
  color: var(--muted);
}
.page-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}
.page-head p {
  font-size: var(--t-lead);
}
/* Zones (summary, work area) sit 20px apart; controls inside the work area stay 12px apart. */
.main > .stats,
.main > .tabs,
.dock-main > .stats,
.dock-main > .tabs,
.page-head + .toolbar,
.page-head + .rem-toolbar,
.stats + .toolbar,
.stats + .rem-toolbar {
  margin-top: 8px;
}
.notice,
.flagnote,
.tip {
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: var(--t-body);
  overflow-wrap: anywhere;
}
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
}
.flagnote {
  background: var(--bad-soft);
  color: var(--bad);
}
.tip {
  background: var(--fix-soft);
  color: var(--fix);
}
.outbox {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.link {
  margin-left: 12px;
  font-size: var(--t-body);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.B {
  max-width: 460px;
  margin: 15vh auto 0;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.empty,
.none {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
}

/* Buttons, tabs, fields */
.btn,
.go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--t-body);
  font-weight: 500;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.btn:hover:not(:disabled),
.go:hover {
  color: var(--ink);
  border-color: var(--faint);
}
.btn .ic {
  width: 16px;
  height: 16px;
}
.btn.primary,
.sheet .acts .ok {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  color: var(--surface);
  opacity: 0.9;
}
.go {
  min-height: 40px;
  white-space: nowrap;
  color: var(--ink);
}
.tabs {
  display: flex;
  gap: 4px 28px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  white-space: nowrap;
}
.tab .ic {
  color: var(--faint);
}
.tab:hover {
  color: var(--ink);
}
.tab[aria-pressed="true"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}
.tab[aria-pressed="true"] .ic {
  color: var(--ink);
}
.tab:focus-visible {
  outline-offset: -2px;
}
.count {
  font-size: var(--t-meta);
  font-weight: 400;
  color: var(--faint);
}
.toolbar,
.rem-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.find,
.line {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.toolbar > .find {
  flex: 1 1 260px;
  min-width: 0;
  width: auto;
}
.find {
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%239a9a96' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='5.5'/%3E%3Cpath d='m13.5 13.5 3.5 3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 18px;
}
.find:focus,
.line:focus {
  outline: none;
  border-color: var(--ink);
}
textarea.line {
  resize: vertical;
  min-height: 76px;
}
.rem-toolbar > .line {
  width: auto;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 190px;
}
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}
input[type="checkbox"] {
  appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1px solid var(--faint);
  border-radius: 5px;
  background: var(--surface);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--surface);
  clip-path: polygon(8% 52%, 22% 38%, 40% 56%, 78% 16%, 92% 30%, 40% 84%);
  transform: scale(0);
}
input[type="checkbox"]:checked {
  background: var(--ink);
  border-color: var(--ink);
}
input[type="checkbox"]:checked::before {
  transform: scale(1);
}
.seg {
  display: inline-flex;
  background: var(--fill);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}
.seg button {
  padding: 5px 14px;
  border-radius: 7px;
  font-size: var(--t-body);
  color: var(--muted);
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line);
}

/* Stat cards */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}
.stat,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 20px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1 1 230px;
  max-width: 320px;
}
.stat-value {
  font-size: var(--t-stat);
  font-weight: 500;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.stat-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: var(--t-body);
}
.stat-note {
  color: var(--faint);
  font-size: var(--t-meta);
}
.meter {
  display: inline-flex;
  gap: 3px;
}
.meter i {
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--tick);
}
.meter i.on {
  background: var(--accent);
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel .sec {
  border-bottom: 0;
  padding-bottom: 0;
}
.sec {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-meta);
  color: var(--muted);
}

/* Tables */
.table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.thead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--fill);
  font-weight: 500;
  font-size: var(--t-body);
}
.thead > span {
  padding: 12px 16px;
  min-width: 0;
}
.ledger-cols,
.task-cols,
.rem-cols {
  display: grid;
  align-items: stretch;
  gap: 0;
}
.ledger-cols {
  grid-template-columns:
    minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1.2fr)
    150px;
}
.task-cols {
  grid-template-columns: minmax(0, 2fr) minmax(0, 2.4fr) 150px;
}
.rem-cols {
  grid-template-columns: minmax(0, 2fr) minmax(0, 2.6fr) 150px;
}
.row,
.task,
.rem-line,
.queue-check,
.cand {
  border-top: 1px solid var(--line);
}
.row,
.task {
  width: 100%;
  min-height: var(--row);
  background: transparent;
  color: inherit;
}
button.row:hover,
.cand:hover,
.q:hover {
  background: color-mix(in srgb, var(--fill) 55%, transparent);
}
.row > span,
.task > * {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ledger-cols > * + *,
.task-cols > * + *,
.rem-cols > * + * {
  border-left: 1px solid var(--line);
}
.row .nm,
.task .who {
  font-weight: 500;
}
.task .who {
  justify-content: space-between;
  gap: 12px;
}
.task .who .amt {
  font-weight: 600;
  white-space: nowrap;
}
.thead:not([class*="-cols"]) {
  flex-wrap: wrap;
  align-items: baseline;
}
.thead-note {
  font-weight: 400;
  font-size: var(--t-meta);
  color: var(--muted);
}
.row .nm {
  display: block;
  align-self: center;
}
.row .meta,
.row .st,
.task .what {
  font-size: var(--t-body);
}
.row .meta {
  color: var(--muted);
}
.row .amt {
  justify-content: flex-end;
  font-weight: 600;
  white-space: nowrap;
}
.task .what {
  display: block;
  align-self: center;
}
.task .go {
  align-self: center;
  justify-self: stretch;
  margin-inline: 12px;
  border-left-color: var(--line);
}
.thead.task-cols > span:last-child {
  border-left: 0;
}
.day {
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  font-size: var(--t-meta);
  color: var(--muted);
  background: color-mix(in srgb, var(--fill) 45%, transparent);
}
.row.pair {
  display: flex;
  justify-content: space-between;
}
.rem-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  padding: 8px 16px;
}
.panel .rem-line,
.sheet .rem-line {
  padding-inline: 0;
}
.rem-line > span {
  min-width: 0;
  overflow-wrap: anywhere;
}
details summary {
  cursor: pointer;
  font-size: var(--t-body);
  color: var(--muted);
  padding: 6px 0;
}
.fold > summary {
  padding: 10px 2px;
}
.table > .fold > summary,
.table > .fold > .notice {
  padding-inline: 16px;
}
.table > .fold {
  border-top: 1px solid var(--line);
}

/* Reconciliation */
.split {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}
.queue-check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
}
.q {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 12px;
  flex: 1;
  min-width: 0;
  min-height: var(--row);
  padding: 9px 16px 9px 0;
  align-items: baseline;
  align-content: center;
}
.fold .q {
  padding-left: 16px;
  border-top: 1px solid var(--line);
}
.queue-check:has(.q[aria-current="true"]) {
  background: var(--fill);
}
.q .d {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.q .a {
  font-weight: 600;
  white-space: nowrap;
}
.q .m,
.q .h {
  font-size: var(--t-meta);
}
.q .m {
  color: var(--muted);
}
.q .h {
  text-align: right;
  white-space: nowrap;
  margin: 0;
}
.desk {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.bankline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bankline .amt {
  font-size: var(--t-amount);
  font-weight: 500;
  line-height: 1.15;
}
.bankline .desc {
  font-size: var(--t-lead);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.cand {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 2px 12px;
  width: 100%;
  min-height: var(--row);
  padding: 10px 16px;
  align-items: baseline;
  align-content: center;
}
.cand .box {
  width: 18px;
  height: 18px;
  border: 1px solid var(--faint);
  border-radius: 5px;
  text-align: center;
  line-height: 16px;
  font-size: 0.78rem;
  grid-row: 1/3;
  align-self: center;
}
.cand[aria-checked="true"] .box {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.cand .nm {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.cand .am {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}
.cand .why {
  grid-column: 2/4;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: var(--t-meta);
  color: var(--muted);
}
.bal {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
}
.bal > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  min-width: 0;
}
.bal > div + div {
  border-left: 1px solid var(--line);
}
.bal span {
  font-size: var(--t-meta);
  color: var(--muted);
}
.bal b {
  font-size: var(--t-lead);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.desk .acts {
  display: flex;
  gap: 10px 18px;
  flex-wrap: wrap;
  align-items: center;
}
.alt {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  font-size: var(--t-body);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.desktop-label {
  font-size: var(--t-meta);
  color: var(--muted);
}

/* Dialogs */
body.modal-open {
  overflow: hidden;
}
.veil {
  position: fixed;
  inset: 0;
  background: var(--veil);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}
.sheet {
  background: var(--surface);
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.sheet > * + * {
  margin-top: 16px;
}
.sheet .table,
.sheet .rem-lines {
  border-radius: var(--r-md);
}
.sheet > .row {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-top: 8px;
}
.sheet.wide {
  width: min(980px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet.still,
.sheet.dock {
  animation: none;
}
/* Entry panel docked beside the inbox on a wide screen */
.main.docked {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 412px;
  gap: 24px;
  align-items: start;
  max-width: 1784px;
}
.dock-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.sheet.dock {
  width: auto;
  position: sticky;
  top: 20px;
  max-height: calc(100dvh - 40px);
  padding: 20px;
}
/* Beside the panel the table is narrower, so the amount sits under the name instead of squeezing it. */
@media (max-width: 1679px) {
  .main.docked .task .who {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
  }
}
/* The category list makes the panel taller than a laptop screen; saving must stay in reach. */
.sheet.dock .acts {
  position: sticky;
  bottom: -20px;
  margin: 0 -20px -20px;
  padding: 12px 20px 20px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.sheet.wide > * {
  flex: none;
}
.sheet.wide > .pairs {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-block: 1px solid var(--line);
}
.sheet.wide .acts {
  justify-content: flex-end;
}
.sheet.wide .acts button {
  flex: 0 1 auto;
  min-width: 140px;
}
.pairs-head {
  display: grid;
  gap: 2px;
}
.pair {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) minmax(132px, 176px) minmax(0, 1fr);
  gap: 4px 14px;
  align-items: center;
  min-height: var(--row);
  padding: 10px 4px;
}
.pair + .pair {
  border-top: 1px solid var(--line);
}
.pair:has(input:not(:checked)) > div {
  opacity: 0.5;
}
.pair-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1px 12px;
  align-items: baseline;
}
.pair-side .d {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.pair-side .a {
  font-weight: 600;
  white-space: nowrap;
}
.pair-side .m {
  grid-column: 1/3;
  font-size: var(--t-meta);
  color: var(--muted);
}
.pair-link {
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
}
.pair-score {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: stretch;
}
.pair-wire {
  position: absolute;
  inset: 50% -10px auto;
  border-top: 1px solid var(--faint);
}
.pair-score .pct {
  position: relative;
  padding: 0 8px;
  background: var(--surface);
  font-size: var(--t-meta);
  font-weight: 600;
}
.pair-link .why {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 8px;
  font-size: var(--t-tab);
  color: var(--muted);
}
#entry-form,
.entry-fields {
  display: grid;
  gap: 14px;
  min-width: 0;
}
.entry-fields,
.rem-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}
.grid2 > label,
.entry-fields input {
  min-width: 0;
}
.entry-amount-block {
  display: grid;
  gap: 6px;
  text-align: center;
  padding: 14px 12px;
  border-radius: var(--r-md);
  background: var(--bg);
}
#duplicate-warning:empty,
#entry-saved:empty {
  display: none;
}
#entry-form textarea {
  min-height: 42px;
  field-sizing: content;
}
.choice {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.choice legend {
  padding: 0 0 6px;
  font-size: var(--t-meta);
  color: var(--muted);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sheet .chips label {
  display: block;
  position: relative;
  font-size: var(--t-body);
  color: var(--ink);
}
.chips input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.chips span {
  display: block;
  min-height: 38px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.chips input:checked + span {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.chips input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
fieldset:disabled .chips input {
  cursor: default;
}
fieldset:disabled .chips span,
fieldset:disabled .rem-choice span {
  opacity: 0.55;
}
.choice:has(> .rem-choice) > legend {
  position: absolute;
  clip-path: inset(50%);
}
.sheet .big {
  border: 0;
  background: none;
  width: 100%;
  font-size: var(--t-amount);
  font-weight: 500;
  text-align: center;
  padding: 0;
}
.sheet .big:focus {
  outline: none;
}
.sheet label,
.rem-field {
  display: grid;
  gap: 6px;
  font-size: var(--t-meta);
  color: var(--muted);
}
.sheet label input,
.sheet label select,
.sheet label textarea,
.rem-field input {
  color: var(--ink);
  font-size: var(--t-body);
}
.sheet .acts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.sheet .acts button {
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-md);
  text-align: center;
  font-weight: 600;
  border: 1px solid var(--line);
}
.sheet .acts .no {
  background: var(--surface);
  color: var(--ink);
}
.sheet .check,
.sheet .rem-check,
.rem-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: var(--t-body);
}
.sheet .check {
  align-items: center;
}
.rem-check input {
  margin-top: 3px;
}
.details-list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 20px;
  margin: 16px 0 0;
  font-size: var(--t-body);
  border-top: 1px solid var(--line);
}
.details-list dt,
.details-list dd {
  margin: 0;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.details-list dt {
  color: var(--muted);
}
.details-list dd {
  overflow-wrap: anywhere;
}

/* Customers, marketplace, reports */
.rem-form,
.rem-fieldset,
.rem-mapping {
  display: grid;
  gap: 14px;
}
.rem-mapping {
  padding-top: 12px;
}
.rem-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 100px;
  border-bottom: 1px solid var(--line);
}
.rem-bars > div {
  flex: 1;
  display: flex;
  gap: 1px;
  align-items: flex-end;
  min-width: 0;
  height: 100%;
}
.rem-bars i {
  display: block;
  flex: 1;
  background: var(--in);
  min-width: 1px;
  border-radius: 2px 2px 0 0;
}
.rem-bars i.expense {
  background: var(--faint);
}
.rem-feedback {
  overflow-wrap: anywhere;
}
.rem-lines {
  max-height: 40vh;
  overflow: auto;
  border: 1px solid var(--line);
  padding: 4px 14px;
}
.rem-lines .rem-check {
  padding: 8px 0;
}
.rem-comparison {
  font-size: var(--t-meta);
  overflow-wrap: anywhere;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.tag {
  display: inline-block;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--t-meta);
  color: var(--muted);
  white-space: nowrap;
}
.rem-statement-summary {
  display: grid;
  gap: 4px;
  overflow-wrap: anywhere;
}
.rem-statement-summary p {
  margin: 0;
}
.rem-preview {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.rem-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-meta);
}
.rem-preview caption {
  padding: 8px 10px;
  text-align: left;
  color: var(--muted);
}
.rem-preview th,
.rem-preview td {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.rem-preview th {
  background: var(--fill);
  font-weight: 500;
}
.rem-preview .right {
  text-align: right;
}
.rem-preview .desc {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rem-choice {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--fill);
}
.rem-choice label {
  flex: 1;
  display: block;
  cursor: pointer;
}
.rem-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.rem-choice span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border-radius: 7px;
  font-size: var(--t-body);
  color: var(--muted);
}
.rem-choice input:checked + span {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line);
}
.rem-choice input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (max-width: 759px) {
  :root {
    --pad: 16px;
    --gap: 12px;
  }
  .frame {
    display: block;
  }
  /* One-handed reach: the same nav registry renders as a bottom tab bar. */
  .side {
    position: fixed;
    inset: auto 0 0;
    z-index: 20;
    height: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--line);
    display: block;
    overflow: visible;
  }
  .brand,
  .nav-label {
    display: none;
  }
  .nav,
  .nav-group {
    display: contents;
  }
  .side nav {
    display: flex;
    flex-direction: row;
    gap: 2px;
  }
  .rem-toolbar > .line {
    flex: 1 1 140px;
  }
  .nav button,
  .frame[data-nav="collapsed"] .nav button {
    flex: 1 1 auto;
    min-width: 0;
    height: 52px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 0 2px;
    font-size: var(--t-tab);
  }
  .nav button span,
  .frame[data-nav="collapsed"] .nav button span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .main {
    padding: 14px var(--pad) calc(96px + env(safe-area-inset-bottom, 0px));
    gap: 16px;
  }
  h1 {
    font-size: 1.625rem;
  }
  .page-head {
    padding-top: 4px;
    gap: 4px;
  }
  .page-head p {
    font-size: var(--t-body);
  }
  .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat {
    max-width: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    padding: 10px 12px;
  }
  .stat-value {
    font-size: 1.25rem;
  }
  .stat-foot {
    flex: 1 1 auto;
  }
  .stat .meter,
  .stat-note {
    display: none;
  }
  .crumbs {
    display: none;
  }
  .topbar {
    justify-content: flex-end;
  }
  .tabs {
    gap: 4px 20px;
    margin-inline: calc(var(--pad) * -1);
    padding-inline: var(--pad);
  }
  .toolbar .btn.primary {
    flex: 1 1 auto;
  }
  .thead > span + span {
    display: none;
  }
  .thead:not(.ledger-cols, .task-cols, .rem-cols) > span + span {
    display: block;
  }
  .ledger-cols,
  .task-cols,
  .rem-cols {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .thead.ledger-cols,
  .thead.task-cols,
  .thead.rem-cols {
    display: flex;
  }
  .ledger-cols > * + *,
  .task-cols > * + *,
  .rem-cols > * + *,
  .task .go {
    border-left: 0;
  }
  .row,
  .task {
    padding: 10px 14px;
    gap: 2px 12px;
    align-content: center;
  }
  .row > span,
  .task > * {
    padding: 0;
  }
  .row .nm,
  .task .who {
    grid-area: 1 / 1;
  }
  .task .who {
    grid-area: 1 / 1 / 2 / 3;
  }
  .task .what {
    align-self: center;
  }
  .row .amt {
    grid-area: 1 / 2;
  }
  .row .meta,
  .task .what {
    grid-area: 2 / 1;
  }
  .row .st {
    grid-area: 2 / 2;
    justify-content: flex-end;
  }
  .rem-cols .meta {
    grid-area: 2 / 1 / 3 / 3;
  }
  .task .go {
    grid-area: 2 / 2;
    margin-inline: 0;
    padding: 0 12px;
  }
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
  .desk {
    grid-row: 1;
    padding: 16px;
  }
  .queue {
    grid-row: 2;
  }
  .toolbar .auto {
    width: 100%;
  }
  .desktop-label {
    display: none;
  }
  .veil {
    align-items: flex-end;
    padding: 0;
  }
  .sheet {
    width: 100%;
    border-radius: 18px 18px 0 0;
    border-width: 1px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    max-height: 95dvh;
  }
  .sheet.wide .acts button {
    flex: 1;
    min-width: 0;
  }
  .pair {
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    padding-inline: 0;
  }
  .pair > input {
    grid-row: 1/4;
    margin-top: 3px;
  }
  .pair > div {
    grid-column: 2;
  }
  .pair-link {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    justify-items: start;
    text-align: left;
  }
  .pair-score {
    min-height: 40px;
    justify-self: start;
  }
  .pair-wire {
    inset: 0 auto 0 50%;
    border-top: 0;
    border-left: 1px solid var(--faint);
  }
  .pair-link .why {
    justify-content: flex-start;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .sheet {
    animation: up 0.18s ease-out;
  }
  @keyframes up {
    from {
      transform: translateY(16px);
      opacity: 0.6;
    }
  }
}
.sheet > .btn {
  margin-right: 8px;
}

.auth-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 520px); background: var(--surface, #fff); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px; }
.auth-card form { display: grid; gap: 18px; margin: 20px 0; }
.auth-card label, .account-create label { display: grid; gap: 6px; }
.auth-card input { min-height: 44px; }
.account-create { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; margin: 24px 0 32px; }
.account-update { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.account-update select { width: auto; }

.auth-actions { display: flex; flex-wrap: wrap; gap: 12px; }
