@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700;12..96,800&family=Geist:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --ink: #22213a;
  --muted: #66647b;
  --accent: #5033c5;
  --border: #e1deee;
  --surface: #fff;
  --background: #f7f6fc;
  --control-height: 40px;
  --icon-control-size: 36px;
  --control-padding: 12px;
  --control-radius: 8px;
  font: 16px/1.5 'Geist', system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
.shell { width: min(1160px, calc(100% - 48px)); margin-inline: auto; }
.masthead { background: #21194b; color: #fff; }
.masthead-inner, #identity, .brand { display: flex; align-items: center; gap: 12px; }
.masthead-inner { justify-content: space-between; min-height: 67px; }
.brand { color: inherit; text-decoration: none; font-weight: 700; }
.brand b { color: #d4c6ff; }
.brand-mark { display: block; width: 40px; height: 40px; flex: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.avatar.large { width: 68px; height: 68px; margin-bottom: 12px; }
#app { padding-bottom: 48px; }
h1, h2, p { margin: 0; }
h1 { font: 750 clamp(2rem, 4.7vw, 3.3rem)/1.03 'Bricolage Grotesque', 'Geist', sans-serif; letter-spacing: -.052em; }
h2 { font-size: 1.15rem; line-height: 1.3; }
p { margin-block: 8px; }
.eyebrow { font-size: .8rem; font-weight: 700; color: var(--accent); margin-bottom: 9px; }
.hint, .empty, .section-title p, small { color: var(--muted); }
small { display: block; font-size: .8rem; }
.hint, .empty { font-size: .9rem; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #7656e9; outline-offset: 3px; }
.primary, .secondary, .quiet, nav button {
  padding: 8px var(--control-padding); min-height: var(--control-height); font-weight: 700; font-size: .88rem;
  border: 1px solid transparent; border-radius: var(--control-radius); color: var(--accent); background: transparent;
}
.primary { background: var(--accent); color: white; }
.primary:hover { background: #3e269e; }
.secondary { background: #f5f2ff; border-color: var(--border); }
.secondary:hover, .quiet:hover, nav button:hover { background: #eae3ff; }
.workspace-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-block: 17px; }
nav, .entry-actions, .row-actions, .report-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
#workspace-tabs { min-width: 0; }
.workspace-tabs {
  position: relative; gap: 3px; padding: 4px; flex-wrap: nowrap;
  background: #ede9f8; border: 1px solid var(--border); border-radius: 12px;
}
.workspace-tabs button { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; color: #5a536e; white-space: nowrap; }
.workspace-tabs button[aria-current] { color: var(--accent); }
.workspace-tabs button:hover { background: #5133c50d; }
.workspace-indicator {
  position: absolute; left: 0; top: 4px; bottom: 4px; pointer-events: none;
  background: white; border-radius: 8px; box-shadow: 0 1px 4px #30235c20;
}
.overview-banner {
  color: white; margin: 7px 0 18px; padding: 27px; border-radius: 21px;
  background: radial-gradient(ellipse at 100% 0%, #6345c7 0%, transparent 52%), #282056;
}
.overview-banner .section-title { margin: 0 0 23px; }
.overview-banner .section-title p { color: #e2d9fa; }
.overview-banner .metrics { margin: 0; }
.overview-banner .metric { background: #ffffff16; border-color: #ffffff30; }
.overview-banner .metric > span { color: #ece6fc; }
.overview-banner .metric strong { color: white; }
.overview-panels { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.direction { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.direction legend { margin-bottom: 4px; font-size: .9rem; font-weight: 700; }
.direction label { position: relative; cursor: pointer; }
.direction input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.direction span { display: grid; place-items: center; text-align: center; min-height: 42px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; }
.direction input:checked + span { background: #efe9ff; color: #4326ae; border-color: #aa96ef; }
.direction input:focus-visible + span { outline: 3px solid #7656e9; outline-offset: 2px; }
.party-picker { display: grid; align-content: start; gap: 8px; }
.entry-preview { margin: 0; padding: 10px 12px; border-radius: 8px; background: #f0ebff; color: #4326ae; font-weight: 600; overflow-wrap: anywhere; }
.entry-preview .entry-balance { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; font-weight: 500; color: #3b3355; }
.entry-preview .entry-balance > span:first-child { font-weight: 600; }
.login { border-top: 4px solid #7656e9; box-shadow: 0 18px 60px #31215713; }
.login form .primary { justify-self: stretch; }

.section-title { margin: 32px 0 21px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.section-title p { margin-bottom: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 17px; box-shadow: 0 3px 9px #29204a06; }
.panel { padding: 20px; margin-bottom: 16px; }
.panel h2 { margin-bottom: 10px; }
.metrics, .two-col { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.two-col { grid-template-columns: repeat(2, minmax(0,1fr)); align-items: start; }
.metric { padding: 19px; display: grid; gap: 8px; }
.metric > span { color: var(--muted); font-size: .9rem; }
.metric strong { font-size: clamp(1.15rem, 2.7vw, 1.65rem); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.account-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 13px; padding-block: 10px; border-top: 1px solid var(--border); }
.account-row strong, .branch-head strong, .admin-row strong, .admin-row small { overflow-wrap: anywhere; }
.amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.branch { border-top: 1px solid var(--border); padding-block: 7px; }
.branch-head, .admin-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 7px; }
.branch-toggle { display: flex; align-items: baseline; gap: 7px; border: 0; background: transparent; color: inherit; padding: 5px 3px; text-align: left; }
.branch-title { padding-block: 5px; }
.children { margin: 4px 0 3px clamp(10px, 2.6vw, 23px); border-left: 1px solid var(--border); padding-left: clamp(6px, 1.6vw, 16px); }
.admin-row { border-top: 1px solid var(--border); }
.spaced { margin-top: 23px; }
.login { max-width: 425px; margin: 55px auto 0; padding: 28px; }
.login h1 { margin-bottom: 20px; }
form, label { display: grid; gap: 5px; }
form { gap: 12px; }
label { font-size: .9rem; font-weight: 700; }
input, select {
  color: var(--ink); background: white; border: 1px solid #cfcae4; border-radius: var(--control-radius);
  width: 100%; min-width: 0; min-height: var(--control-height); padding: 7px var(--control-padding);
}
/* CMS control spacing reserves room for the dropdown chevron across browsers. */
select:not([multiple]) {
  appearance: none;
  padding-inline-end: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366647b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.125rem;
}
select:dir(rtl):not([multiple]) { background-position: left 0.75rem center; }
input[type="date"], input[type="file"] { max-width: 100%; }
@media (max-width: 767px) {
  input[type="date"] { appearance: none; display: block; text-align: left; }
  input[type="date"]::-webkit-date-and-time-value { text-align: left; min-width: 0; }
  input[type="date"]::-webkit-datetime-edit { padding: 0; }
}
input[type="checkbox"] { width: auto; min-height: auto; }
.check { display: flex; align-items: center; }
form .primary { justify-self: start; }
.form-error { color: #9d201d; margin: 0; font-size: .9rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
dialog { width: min(510px, calc(100% - 28px)); border: 1px solid var(--border); border-radius: 14px; padding: 22px; color: var(--ink); }
dialog::backdrop { background: #20163d9e; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
#notice { position: fixed; bottom: 18px; right: 18px; background: #21194b; color: white; border-radius: 9px; padding: 10px 15px; max-width: min(400px, calc(100% - 36px)); }

.statement h2 { font-size: 1.4rem; }

table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 7px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f0ecfb; }
td:nth-child(2) { overflow-wrap: anywhere; }
th:not(:nth-child(-n+2)), td:not(:nth-child(-n+2)) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td:first-child { white-space: nowrap; }
.paper { background: white; color: #22213a; font-size: 14px; }
.paper table { table-layout: fixed; }
.paper th:first-child { width: 17%; }
.paper th:nth-child(n+3) { width: 17%; }
.paper.export, .paper.printing { position: absolute; top: 0; left: -200vw; }
@media (max-width: 800px) {
  .workspace-nav { flex-wrap: wrap; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .overview-panels { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 540px) {
  .shell { width: calc(100% - 24px); }
  .panel, .metric { padding: 12px; }
  .overview-banner { padding: 16px; }
  #workspace-tabs { width: 100%; }
  .workspace-tabs { justify-content: space-between; gap: 0; }
  .workspace-tabs button { flex: 1; gap: 3px; min-width: 0; min-height: 53px; padding: 5px 1px; font-size: clamp(.56rem, 2.35vw, .75rem); flex-direction: column; white-space: normal; line-height: 1.1; text-align: center; }
  .entry-actions { width: 100%; }
  .entry-actions > button { flex: 1; }
  .login { margin-top: 28px; }
  .account-row { grid-template-columns: minmax(0, 1fr) auto; }
  .account-row .row-actions { grid-column: 1 / -1; }
  .branch-head { align-items: start; flex-direction: column; }
  .fields { grid-template-columns: 1fr; }
}
@page { size: A4 portrait; margin: 10mm 8mm; }
@media print {
  body > :not(.printing) { display: none !important; }
  .paper.printing { position: static; width: auto !important; }
  body { background: white; }
  tr { break-inside: avoid; }
  thead { display: table-header-group; }
}
.demo-login { margin-top: 20px; padding-top: 8px; border-top: 1px solid var(--border); }

.profile-menu { position: relative; }
.profile-menu summary {
  display: grid; place-items: center; width: 43px; height: 43px;
  border: 1px solid #ffffff35; background: #ffffff12; border-radius: 50%;
  cursor: pointer; list-style: none;
}
.profile-menu summary::-webkit-details-marker { display: none; }
.profile-menu summary:hover, .profile-menu[open] summary { background: #ffffff26; }
.profile-menu summary:focus-visible { outline: 3px solid #c9b7ff; outline-offset: 3px; }
.profile-dropdown {
  display: grid; position: absolute; inset: calc(100% + 8px) 0 auto auto;
  width: 160px; padding: 5px; z-index: 5;
  background: white; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 26px #2219432b;
}
.profile-dropdown button { text-align: left; color: var(--ink); }
.profile-avatar { display: inline-block; position: relative; width: 30px; height: 30px; color: #ece5ff; }
.profile-avatar::before, .profile-avatar::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); background: currentColor; }
.profile-avatar::before { width: 29%; height: 29%; top: 17%; border-radius: 50%; }
.profile-avatar::after { width: 55%; height: 26%; top: 53%; border-radius: 70% 70% 30% 30% / 100% 100% 30% 30%; }
.profile-avatar.large { width: 60px; height: 60px; border-radius: 50%; color: #5033c5; background: #eee8ff; }
.profile-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.profile-heading h2, .profile-heading .avatar { margin: 0; }
.profile-heading small { overflow-wrap: anywhere; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.setting-row:last-child { padding-bottom: 0; }
.switch { position: relative; flex: none; width: 45px; height: 25px; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; height: 25px; min-height: 0; padding: 0; margin: 0; cursor: pointer; }
.switch span { display: block; height: 25px; border-radius: 16px; background: #6d6680; pointer-events: none; }
.switch span::before { content: ''; display: block; position: absolute; top: 4px; left: 4px; width: 17px; height: 17px; border-radius: 50%; background: white; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid #7656e9; outline-offset: 3px; }
.auth-qr { display: block; width: 160px; height: 160px; margin: 6px auto; }
.auth-qr + label { margin-bottom: 12px; }
.recovery-codes { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 6px; padding: 0; }
.recovery-codes li { padding: 5px 8px; background: #f3efff; border-radius: 5px; }
.remove-account { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.danger { color: #982d31; }

.heads-title { flex-direction: column; align-items: stretch; gap: 12px; }
.heads-toolbar, .view-switch, .head-tabs { display: flex; align-items: center; gap: 4px; }
.heads-toolbar { justify-content: space-between; gap: 8px; }
.view-switch, .head-tabs {
  max-width: 100%; padding: 3px; border: 1px solid var(--border);
  border-radius: var(--control-radius); background: #f0ecf9;
}
.view-option {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px;
  padding: 4px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: .8rem; font-weight: 700;
}
.view-option:hover { background: #eae3ff; }
.view-option[aria-pressed="true"] { color: var(--accent); background: white; border-color: var(--border); }
.head-tabs { flex-wrap: wrap; margin-bottom: 9px; }
.head-tabs button { overflow-wrap: anywhere; text-align: left; }
.tree > .branch:first-child, .children > .branch:first-child, .children > .account-row:first-child { border-top: 0; }
.tree .branch { padding-block: 4px; }
.tree .branch-head { flex-wrap: wrap; }
.tree .row-actions > button { min-height: var(--icon-control-size); padding-inline: 8px; font-size: .8rem; }
.tree .children { margin-inline-start: clamp(8px, 1.6vw, 18px); }
.tree .children .empty { margin-block: 4px; }

.statement-screen .statement-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.statement-screen .statement-heading h2 { overflow-wrap: anywhere; margin: 0; }
.statement-screen .statement-heading p { margin: 2px 0; }

.report-actions { flex-wrap: nowrap; flex: none; gap: 4px; }
.icon-control { display: inline-flex; position: relative; }
.icon-button {
  display: inline-grid; place-items: center; width: var(--icon-control-size); height: var(--icon-control-size);
  padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--accent);
}
.report-actions .icon-button { border-color: var(--border); background: #f5f2ff; }
.icon-button:hover, .report-actions .icon-button:hover { background: #eae3ff; }
.icon-tooltip {
  display: none; pointer-events: none; position: absolute; z-index: 4; inset: calc(100% + 4px) 0 auto auto;
  padding: 4px 7px; border-radius: 5px; white-space: nowrap; background: #21194b; color: white; font-size: .75rem;
}
.icon-control:hover .icon-tooltip, .icon-control:focus-within .icon-tooltip { display: block; }
.statement-screen .interactive { width: 1%; vertical-align: middle; }
.row-menu {
  position: fixed; inset: auto 8px auto auto; margin: 0; padding: 4px; min-width: 112px;
  border: 1px solid var(--border); border-radius: var(--control-radius); background: white;
  box-shadow: 0 8px 20px #21194b26;
}
.row-menu button { width: 100%; text-align: left; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.workspace-links { display: flex; align-items: center; min-width: 0; gap: 8px; }
.setup-accounts { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.setup-accounts h2, .setup-accounts p { margin: 0; }
@media (max-width: 540px) {
  .workspace-links { width: 100%; }
  .workspace-tabs button { font-size: .78rem; min-height: 38px; flex-direction: row; gap: 4px; }
}

.entry-parties, .party-levels, .payment-method {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px;
}
.party-picker {
  min-width: 0; margin: 0; padding: 8px; border: 1px solid var(--border);
  border-radius: var(--control-radius); background: #faf9ff;
}
.party-picker legend { padding-inline: 4px; font-size: .9rem; font-weight: 700; }
.entry-parties .party-levels { grid-template-columns: minmax(0, 1fr); }
.payment-method { align-items: start; }
.payment-method [data-bank-picker] { min-width: 0; }
@media (max-width: 540px) {
  .entry-parties { grid-template-columns: minmax(0, 1fr); }
  .entry-parties .party-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .entry-parties .party-levels, .entry-party .party-levels, .payment-method { grid-template-columns: minmax(0, 1fr); }
}

.head-browser { display: grid; grid-template-columns: minmax(185px, 1fr) minmax(0, 3fr); gap: 12px; align-items: start; }
.head-sidebar { padding: 10px; }
.head-sidebar h2 { font-size: .86rem; color: var(--muted); }
.head-browser-row { display: flex; align-items: center; gap: 3px; min-width: 0; }
.head-browser-row > .view-option {
  flex: 1; min-width: 0; justify-content: flex-start; text-align: left; overflow-wrap: anywhere;
}
.head-browser-row > [aria-pressed="true"], .heads-toolbar > [aria-pressed="true"] {
  color: var(--accent); background: #eee8ff; border-color: #cfc2f6;
}
.order-actions { display: inline-flex; flex: none; gap: 2px; }
.order-actions .icon-button { border-color: var(--border); }
.order-actions .icon-button:disabled { opacity: .3; cursor: default; }
.head-browser-row .order-actions .icon-button { width: 30px; height: 32px; }
@media (max-width: 650px) {
  .head-browser { grid-template-columns: minmax(0, 1fr); }
  .head-sidebar { max-height: 210px; overflow: auto; }
}

.ledger-type { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.ledger-filters .party-levels { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.ledger-filters [data-ledger-scope] > label { max-width: 420px; }

.overview-cash-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center; gap: 9px; min-height: 61px; padding: 8px 0;
  border-top: 1px solid var(--border);
}
.cash-account-icon {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: #f1ebff; color: var(--accent);
}
.cash-account-name { min-width: 0; overflow-wrap: anywhere; }
.cash-account-name small { margin-top: 2px; }
.overview-cash-row .amount { font-size: .9rem; white-space: nowrap; }
.overview-cash-row .icon-button { border-color: var(--border); background: #f5f2ff; }
.overview-cash-row .icon-button:hover { background: #eae3ff; }
.overview-banner .metric { container-type: inline-size; }
.overview-banner .metric strong { font-size: clamp(1rem, 14cqi, 1.65rem); }
.person-opening { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--control-radius); }
.person-opening summary { cursor: pointer; color: var(--accent); font-size: .88rem; font-weight: 700; }
@media (max-width: 380px) {
  .overview-cash-row { gap: 6px; }
  .cash-account-icon { width: 24px; height: 24px; }
}

.ledger-filters summary {
  display: flex; align-items: center; justify-content: space-between; min-height: 32px;
  cursor: pointer; font-weight: 700; list-style: none;
}
.ledger-filters summary::-webkit-details-marker { display: none; }
.ledger-filters[open] summary { margin-bottom: 12px; }
.ledger-filters[open] summary svg { transform: rotate(180deg); }
.statement-heading > div:first-child { min-width: 0; }
.statement-heading h2 { margin: 0; overflow-wrap: anywhere; }
.statement-heading .statement-period { color: var(--muted); font-size: .85rem; }
.statement-balances {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0;
}
.statement-balances > div { display: grid; align-content: start; gap: 2px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.statement-balances > div:last-child { background: #f3efff; }
.statement-balances span { color: var(--muted); font-size: .8rem; }
.statement-balances strong { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.statement-details > span { display: block; color: var(--muted); }
.statement-mobile-label { display: none; }
.statement-empty { margin: 0; padding: 13px 0 2px; border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; }
.statement-share { display: inline-flex; align-items: center; gap: 5px; min-height: var(--icon-control-size); padding: 3px 7px; }
.statement-screen table { table-layout: fixed; }
.statement-screen th:first-child { width: 96px; }
.statement-screen th:nth-child(n+3):nth-child(-n+5) { width: 17%; }
.statement-screen th.interactive { width: 50px; }
.statement-screen td:nth-child(n+3) { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 650px) {
  .statement-screen .statement-heading { flex-wrap: wrap; }
  .statement-screen .report-actions { margin-left: auto; }
  .statement-screen table, .statement-screen tbody, .statement-screen tfoot { display: block; }
  .statement-screen thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .statement-screen tbody tr, .statement-screen tfoot tr {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    align-items: start; gap: 3px 10px; padding: 9px 0; border-top: 1px solid var(--border);
  }
  .statement-screen td { padding: 0; border: 0; min-width: 0; }
  .statement-screen .statement-details { grid-area: 1 / 1; }
  .statement-screen .interactive { grid-area: 1 / 2; justify-self: end; width: auto; }
  .statement-screen .interactive:empty { display: none; }
  .statement-screen .statement-date { grid-area: 2 / 1; color: var(--muted); font-size: .78rem; }
  .statement-screen .statement-debit, .statement-screen .statement-credit { grid-column: 1; text-align: left; }
  .statement-screen .statement-running { grid-area: 2 / 2 / span 3; align-self: end; font-weight: 700; }
  .statement-screen td[data-empty] { display: none; }
  .statement-screen .statement-mobile-label { display: inline; margin-right: 4px; font-size: .76rem; color: var(--muted); font-weight: 500; }
}

.account-row small { overflow-wrap: anywhere; }
dialog { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
@media (pointer: coarse) {
  :root { --control-height: 44px; --icon-control-size: 44px; }
  input, select { font-size: 16px; }
  .workspace-tabs button, .ledger-filters summary, .view-option, .direction span { min-height: 44px; }
  .head-browser-row .order-actions .icon-button { height: 44px; }
}

.method-choice { grid-template-columns: repeat(var(--choices), minmax(0, 1fr)); }
.conditional-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.conditional-fields:not([hidden]) { display: grid; gap: 9px; }
.trade-sale { border: 1px solid var(--border); border-radius: var(--control-radius); padding: 10px; }
.trade-sale > legend { padding-inline: 4px; font-size: .9rem; font-weight: 700; }
.stock-heading, .trade-row-head { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 8px; }
.stock-heading { margin-bottom: 8px; }
.stock-table { table-layout: fixed; }
.stock-table th:first-child { width: 21%; }
.stock-table th, .stock-table td { white-space: normal; overflow-wrap: anywhere; vertical-align: middle; }
.stock-table th[scope="row"] { background: transparent; }
.stock-table button { width: 100%; padding-inline: 5px; }
.trade-row { border-top: 1px solid var(--border); padding: 12px 0; overflow-wrap: anywhere; }
.trade-row h3 { margin: 0; font-size: 1rem; }
.trade-row h3 small { display: inline; }
.trade-row p { margin: 2px 0 5px; }
.trade-totals { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 5px 0 0; }
.trade-totals dt { color: var(--muted); font-size: .78rem; }
.trade-totals dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 800px) {
  .stock-table, .stock-table tbody { display: block; }
  .stock-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .stock-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; border-top: 1px solid var(--border); padding: 9px 0; }
  .stock-table th[scope="row"] { width: auto; grid-column: 1 / -1; }
  .stock-table th, .stock-table td { border: 0; text-align: left; padding: 2px 0; }
  .stock-table td[data-label]::before { display: block; content: attr(data-label); font-size: .75rem; color: var(--muted); }
  .stock-table td:last-child { grid-column: 1 / -1; }
  .stock-table button { width: auto; }
}

.party-role-label { color: var(--accent); margin-top: 2px; }
.role-hint { margin: -5px 0 0; }

.catalog-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid var(--border); }
.catalog-row strong { overflow-wrap: anywhere; }

.ledger-balance-value { color: #202938; }
.ledger-balance-value.negative { color: #a81d1d; }
.overview-banner .party-metric { background: #fff; }
.overview-banner .party-metric > span { color: #465164; }
.statement-balances .ledger-balance-value { font-size: inherit; color: #202938; }
.statement-balances .ledger-balance-value.negative { color: #a81d1d; }

.removal-warning { padding: 9px 12px; margin-bottom: 12px; border-radius: var(--control-radius); background: #fff1f1; color: #722222; }
form:is([data-form="remove-account"], [data-form="remove-item"]) .primary { background: #a81d1d; }
form:is([data-form="remove-account"], [data-form="remove-item"]) .primary:hover { background: #7e1515; }

.settings-trigger { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; flex: none; }
.settings-trigger[data-current] { color: var(--accent); background: #eae3ff; }
.settings-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.settings-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 94px; padding: 14px; text-align: left; color: var(--ink);
}
.settings-card:hover { border-color: #aa96ef; background: #faf8ff; }
.settings-card small { margin-top: 4px; }
.settings-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: #eee8ff; color: var(--accent); }
.settings-arrow { display: grid; color: var(--accent); transform: rotate(-90deg); }
.person-form-fields, .person-memberships { display: grid; gap: 8px; margin-top: 9px; }
.person-memberships { max-height: 210px; overflow: auto; padding: 3px; }
.person-memberships label { overflow-wrap: anywhere; }
.person-form-fields textarea {
  width: 100%; padding: 7px var(--control-padding); border: 1px solid #cfcae4;
  border-radius: var(--control-radius); color: var(--ink); font: inherit; font-weight: 400; resize: vertical;
}
@media (pointer: coarse) {
  .person-form-fields textarea { font-size: 16px; }
  .person-memberships label { min-height: 35px; }
}

.profit-actions { margin: 8px 0 12px; }

.drag-handle { cursor: grab; touch-action: none; }
.tree-dragging, .tree-dragging .drag-handle { cursor: grabbing; user-select: none; }
[data-drag-source] { opacity: .55; }
.tree-root-drop {
  border: 1px dashed #aa96ef; border-radius: var(--control-radius); color: var(--muted);
  padding: 8px 10px; margin-bottom: 8px; font-size: .85rem;
}
[data-drop-position="before"] { box-shadow: inset 0 3px var(--accent); }
[data-drop-position="after"] { box-shadow: inset 0 -3px var(--accent); }
[data-drop-position="inside"], [data-drop-position="root"] { background: #eee8ff; outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }

.heads-panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.heads-panel-title h2 { margin: 0; }
.head-sidebar .heads-panel-title .primary { padding-inline: 8px; font-size: .8rem; }
.reorder-toggle { display: grid; place-items: center; width: var(--control-height); padding: 0; flex: none; }
.tree { container-type: inline-size; }
.tree .account-row .amount { min-width: 0; overflow-wrap: anywhere; }
@container (max-width: 680px) {
  .tree .account-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 44%);
    align-items: start; column-gap: 10px; row-gap: 5px;
  }
  .tree .account-row .row-actions { grid-column: 1 / -1; }
}
@media (max-width: 360px) {
  .view-switch .view-option svg { display: none; }
}

.catalog-category-items { margin-inline-start: .75rem; padding-inline-start: .75rem; border-inline-start: 1px solid var(--border); }
.linked-category { margin: 7px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--control-radius); }
.linked-category summary { cursor: pointer; color: var(--accent); overflow-wrap: anywhere; }
.linked-category summary small { display: inline; margin-inline-start: 6px; }
.linked-category ul { margin-block: 8px; padding-inline-start: 20px; }
.linked-category li { overflow-wrap: anywhere; }
.linked-category li small { display: inline; margin-inline-start: 4px; }

.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin-top: 18px; font-size: .9rem; }
.auth-links a { color: var(--accent); font-weight: 600; }
a.link-button { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-height);
  margin-top: 16px; padding: 0 18px; border-radius: var(--control-radius); text-decoration: none; font-weight: 600; }
.login a.link-button { width: 100%; }
.dev-link { margin: 14px 0; padding: 12px; border: 1px dashed var(--border); border-radius: var(--control-radius); overflow-wrap: anywhere; font-size: .85rem; }
.dev-link a { color: var(--accent); }
.auth-resend { margin-top: 10px; }

/* Phase 2B */
.negative { color: #a81d1d; }
.archived { opacity: .62; }
.archived-label { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 99px; background: #eee9fb; font-size: .72rem; }
.inactive { opacity: .6; }
fieldset.bare { border: 0; padding: 0; margin: 0; min-width: 0; }
.metric small { margin-top: 4px; }
.period-panel { margin-top: 18px; }
.period-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; }
.period-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.period-figures > div { padding: 12px; border: 1px solid var(--border); border-radius: var(--control-radius); }
.period-figures span, .profit-available span, .statement-summary span { display: block; color: var(--muted); font-size: .85rem; }
.period-figures strong { display: block; font-size: 1.25rem; }
.profit-available { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--border); }
.profit-available strong { font-size: 1.15rem; }
.statement-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.statement-summary > div { padding: 10px; border: 1px solid var(--border); border-radius: var(--control-radius); }
.statement-opening td, .statement-totals td { background: #faf9fe; }
.statement-totals td { font-weight: 700; }
.statement-generated { margin-top: 12px; color: var(--muted); font-size: .8rem; }
.print-frame-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 6px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: .72rem; }
.date-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.changed-badge { margin-left: 6px; padding: 0 7px; border: 1px solid var(--border); border-radius: 99px; background: #f5f2ff;
  font-size: .72rem; color: var(--accent); }
.quick-search { flex: 1 1 180px; max-width: 320px; margin: 0; }
.quick-search input { width: 100%; min-height: var(--control-height); }
.quick-search .form-error { position: absolute; }
.search-section { margin: 16px 0 4px; font-size: .9rem; color: var(--muted); }
.choice-list { display: grid; gap: 10px; border: 0; padding: 0; margin: 0 0 12px; }
.choice-list .check { align-items: flex-start; }
.stock-actions { white-space: nowrap; text-align: right; }
.trade-row-status { display: grid; justify-items: end; gap: 4px; }
@media print {
  .page-count { visibility: hidden; }
}
@page { @bottom-center { content: "Page " counter(page) " of " counter(pages); font: 9px system-ui, sans-serif; color: #66647b; } }
.overview-banner .metric:not(.party-metric) small { color: inherit; opacity: .85; }

/* Phase 2C */
.import-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.import-summary > div { padding: 10px; border: 1px solid var(--border); border-radius: var(--control-radius); }
.import-summary span { display: block; color: var(--muted); font-size: .85rem; }
.table-scroll { overflow-x: auto; }
.import-table tr.import-problem td { background: #fdf0f0; }
.import-table tr.import-exists td { color: var(--muted); }

/* Phase 2: phone layout */
.mobile-nav { display: none; }
@media (max-width: 640px) {
  .workspace-nav .workspace-links, .workspace-nav .entry-actions { display: none; }
  .workspace-nav { padding-block: 12px 4px; }
  .quick-search { max-width: none; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 20;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px #2a1f5a12; }
  .mobile-nav button { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 52px; padding: 0;
    border: 0; background: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
  .mobile-nav button[aria-current="page"] { color: var(--accent); }
  .mobile-nav .mobile-entry svg { width: 44px; height: 44px; padding: 11px; margin-top: -18px; border-radius: 50%;
    background: var(--accent); color: #fff; box-shadow: 0 6px 16px #5033c555; }
  #app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  #notice { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .overview-banner .metric strong, .metric strong { font-size: clamp(.92rem, 4.3vw, 1.3rem); overflow-wrap: normal; white-space: nowrap; letter-spacing: -.01em; }
  .metric { padding: 14px; }
  .period-figures { grid-template-columns: 1fr 1fr; }
  .period-figures strong { font-size: clamp(.92rem, 4.2vw, 1.05rem); white-space: nowrap; }
  .period-figures > div { padding: 10px; min-width: 0; }
  dialog { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
}
@media (max-width: 650px) {
  .statement-screen tfoot tr { background: #faf9fe; padding-inline: 8px; border-radius: 8px; margin-top: 6px; }
  .statement-screen tfoot td { background: none; }
}
.outbox-banner { min-height: 32px; padding: 0 12px; border: 1px solid #e6c46b; border-radius: 99px; background: #fff6dc; color: #6b4e00; font-weight: 600; }
.outbox-banner.failed { border-color: #e0a4a4; background: #fdf0f0; color: #a81d1d; }
.inout-table th, .inout-table td { white-space: nowrap; }
.inout-table tfoot th, .inout-table tfoot td { font-weight: 700; background: #faf9fe; }
.export-links { display: grid; gap: 8px; }
.export-links .link-button { margin-top: 0; width: 100%; }
.restore-preview { padding: 12px; border: 1px solid var(--border); border-radius: var(--control-radius); background: #faf9fe; }

/* Phase 4: platform console */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.admin-metrics { margin-bottom: 16px; }
.admin-users th small { display: block; }
.admin-users td.row-actions { flex-wrap: wrap; justify-content: flex-end; }
.status-pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: #eee9fb; color: var(--accent); }
.status-active { background: #e4f6ea; color: #1d6b3a; }
.status-disabled { background: #fdf0f0; color: #a81d1d; }
.status-invited, .status-email { background: #fff6dc; color: #6b4e00; }
.mini-bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin-top: 10px; }
.mini-bars span { flex: 1; min-width: 2px; height: max(2px, var(--h)); background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; }
.narrow-panel { max-width: 520px; }
