:root {
    --ink: #0b2e6b;
    --muted: #3d5278;
    --line: #c5d0e0;
    --bg: #f7f8fa;
    --card: #ffffff;
    --nav: #0b2e6b;
    --nav-text: #ffffff;
    --accent: #0b2e6b;
    --yellow: #e0a800;
    --pos: #166534;
    --neg: #c40000;
    --danger: #b91c1c;
    --shadow: 0 10px 28px rgba(11, 46, 107, 0.06);
    --sans: "Segoe UI", "Myanmar Text", "Noto Sans Myanmar", "Pyidaungsu", "Myanmar MN", "Padauk", "Helvetica Neue", Arial, sans-serif;
    --mono: "Segoe UI", "Myanmar Text", "Noto Sans Myanmar", "Pyidaungsu", "Myanmar MN", "Padauk", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.45;
}
body:not(.auth-body) {
    height: 100vh;
    overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }

.skip {
    position: absolute;
    left: 12px;
    top: -40px;
    background: #fff;
    padding: 8px 12px;
    z-index: 20;
}
.skip:focus { top: 12px; }

.app { display: flex; height: 100vh; min-height: 0; overflow: hidden; }
.sidebar {
    width: 210px;
    flex: 0 0 210px;
    height: 100vh;
    overflow: auto;
    background: var(--nav);
    color: var(--nav-text);
    display: flex;
    flex-direction: column;
    padding: 22px 14px 16px;
    transition: width 0.16s ease, flex-basis 0.16s ease, padding 0.16s ease;
}
body.nav-hidden .sidebar {
    width: 0;
    flex: 0 0 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    border: 0;
}
.brand {
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 10px 16px;
    text-decoration: none;
    border-bottom: 2px solid var(--yellow);
    margin-bottom: 14px;
}
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .user-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--nav-text);
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 8px;
}
.icon {
    width: 1.1em;
    font-size: 14px;
    line-height: 1;
    text-align: center;
    flex: 0 0 auto;
}
.nav a:hover, .user-link:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.nav a.active, .user-link.active { background: var(--yellow); color: #0b2e6b; }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.12); }
.logout {
    margin-top: 8px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    border-radius: 6px;
    min-height: 36px;
    padding: 0 10px;
    cursor: pointer;
}
.logout:hover { background: rgba(255,255,255,0.08); color: #fff; }

.main { flex: 1; min-width: 0; min-height: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 28px 12px;
    background: #fff;
    border-bottom: 2px solid var(--yellow);
}
.topbar-title p { color: var(--muted); margin-top: 2px; font-size: 13px; }
.today { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.nav-toggle {
    display: inline-flex;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    flex: 0 0 auto;
}
.nav-toggle:hover { background: #fafaf9; }
.nav-backdrop { display: none; }
.content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    padding: 16px 28px 18px;
}
body.page-account .content,
body.page-statement .content,
body.page-dashboard .content { overflow: auto; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.panel-head p { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    box-shadow: 0 1px 0 rgba(28, 25, 23, 0.04);
}
.btn:hover { text-decoration: none; background: #eff6ff; border-color: #93c5fd; }
.btn:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn .icon { font-size: 13px; width: 1em; }
.btn-primary {
    background: var(--accent);
    border-color: #071f4d;
    color: #fff;
    box-shadow: 0 1px 1px rgba(29, 78, 216, 0.28);
}
.btn-primary:hover { background: #071f4d; border-color: #0b2e6b; color: #fff; }
.btn-ghost { background: #fff; color: #0b2e6b; border-color: #93c5fd; }
.btn-danger { background: #fff; color: var(--danger); border-color: #f3c0c0; }
.btn-danger:hover { background: #fef2f2; border-color: #e11d48; color: #9f1239; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 5px; }
.btn-block { width: 100%; min-height: 42px; }
.btn:disabled, .btn:disabled:hover {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; }
.filters-card { flex: 0 0 auto; margin-bottom: 12px; }
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.filters-card.is-collapsed .filter-body { display: none; }
.filters-card.is-collapsed .filter-bar { margin-bottom: 0; }
.filters-card .actions-field { grid-column: 1 / -1; }
.filters-card .actions { flex-wrap: wrap; justify-content: flex-start; }
.range-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.toolbar { flex: 0 0 auto; }
body.page-banks .content > .panel:not(.form-sheet) {
    flex: 0 0 auto;
    overflow: visible;
    display: block;
    margin-bottom: 0;
    padding: 0;
}
body.page-banks .content > .panel.form-sheet {
    flex: 0 0 auto;
    align-self: flex-start;
    width: min(640px, 100%);
    overflow: visible;
    margin-bottom: 0;
    padding: 14px 16px 12px;
}
body.page-banks .content > .panel.form-sheet.is-chain {
    width: min(960px, 100%);
}
body.page-banks .content > .panel > .table-wrap,
body.page-history .content > .table-wrap {
    flex: 0 0 auto;
    min-height: 0;
    overflow: auto;
    margin-bottom: 0;
}
body.page-history .toolbar,
body.page-history .count-line,
body.page-history .pager { flex: 0 0 auto; }
table.grid.ledger {
    width: 100%;
    table-layout: fixed;
    border: 1px solid #0b2e6b;
}
table.ledger.customers th:nth-child(1) { width: 22%; }
table.ledger.customers th:nth-child(2) { width: 16%; }
table.ledger.customers th:nth-child(6) { width: 22%; }
table.ledger.lines th:nth-child(1) { width: 16%; }
table.ledger.lines th:nth-child(4) { width: 28%; }
table.ledger.lines th:nth-child(6) { width: 16%; }
table.ledger.daybook th:nth-child(1) { width: 12%; }
table.ledger.daybook th:nth-child(5) { width: 72px; }
table.ledger td { overflow: hidden; text-overflow: ellipsis; }
table.ledger td.row-actions,
table.ledger td.num,
table.ledger td.when { overflow: visible; }
body.page-transactions .cash-split {
    flex: 0 0 auto;
    align-items: start;
}
body.page-transactions .cash-split > section {
    min-height: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
}
body.page-transactions .cash-split > section:first-child {
    height: auto;
    overflow: visible;
}
body.page-transactions .cash-split > section:first-child > form.cash-box {
    flex: 0 0 auto;
    max-height: none;
    height: auto;
    overflow: visible;
}
body.page-transactions .cash-split > section:first-child > .panel:not(.cash-box) {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
    display: block;
}
body.page-transactions .cash-split > section:first-child > .panel .table-wrap {
    overflow: auto;
}
body.page-transactions table.balance th,
body.page-transactions table.balance td {
    padding: 8px 10px;
    font-size: 15px;
}
body.page-transactions .cash-split > section:last-child .balance-sheet {
    flex: 0 0 auto;
    display: block;
}
body.page-transactions .cash-split .balance-sheet .table-wrap {
    overflow: auto;
    background: #fff;
    border: 1px solid #1c1917;
}
.chip {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 999px;
    min-height: 32px;
    padding: 0 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.chip:hover { border-color: #93c5fd; background: #eff6ff; }
.chip:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.chip.is-on, .chip.is-on:hover { background: var(--yellow); border-color: #b8860b; color: #0b2e6b; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span, .check { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    min-height: 36px;
    font-size: 16px;
}
.field textarea { min-height: 72px; resize: vertical; }
input[type="color"] { width: 42px; min-height: 32px; padding: 2px; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid #bfdbfe;
    border-color: var(--accent);
}
.actions { display: flex; gap: 8px; }
.stack-fields { display: flex; flex-direction: column; gap: 8px; }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; }

table.grid {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-variant-numeric: tabular-nums;
}
table.grid th, table.grid td {
    border: 1px solid var(--line);
    padding: 7px 9px;
    vertical-align: top;
    font-size: 14px;
}
table.grid th {
    background: #0b2e6b;
    color: #fff;
    border-color: #071f4d;
    font-weight: 650;
    text-align: center;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 12px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
table.grid td { vertical-align: middle; }
table.grid td.num, table.grid th.num { text-align: right; white-space: nowrap; }
table.grid td.when { white-space: nowrap; }
table.grid tfoot td { font-weight: 650; background: #eff6ff; }
table.grid tr.opening td { background: #eff6ff; }
table.grid a { color: inherit; }
table.grid a:hover { color: var(--accent); }
.pos { color: var(--ink); }
.neg { color: var(--neg); }
.empty { color: var(--muted); padding: 18px 4px; }
.table-wrap { overflow: auto; min-width: 0; }
.bank-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bank-cell span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.logo-sm { width: 22px; height: 22px; object-fit: contain; border: 1px solid var(--line); background: #fff; flex: 0 0 auto; }
td.row-actions { white-space: nowrap; text-align: right; }
td.row-actions .btn { margin-left: 6px; }
td.row-actions .inline-form { display: inline-flex; vertical-align: middle; }
.inline-form { display: inline-flex; margin: 0; }
.count-line { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.history-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex: 0 0 auto;
}
.history-bar .count-line { margin: 0; }
.history-bar .toolbar { margin-left: auto; }
.history-note { background: #fff; border: 1px solid #d7deea; border-radius: 8px; padding: 16px 18px; }
.history-note h2 { margin: 0 0 14px; color: #0b2e6b; font-size: 1.15rem; }
.history-group { margin: 0 0 16px; }
.history-group h3 { margin: 0 0 4px; font-size: 1rem; }
.history-lines { list-style: none; margin: 0; padding: 0; }
.history-lines li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; }
.history-lines .line-text { font-variant-numeric: tabular-nums; }
.history-total { margin: 4px 0 0; font-weight: 700; font-size: 1.05rem; }
.history-sheet {
    flex: 0 0 auto;
    min-height: 0;
    overflow: auto;
    margin: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 3px solid var(--yellow);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.filters-fit .filters {
    grid-template-columns: 148px 148px minmax(140px, 1fr) 132px minmax(150px, 1.1fr) auto;
}
.filters-fit .actions-field { grid-column: auto; }
.filters-fit .actions-field > span { display: none; }
.type-pill {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.type-pill.pos { background: #e8eef8; color: #0b2e6b; }
.type-pill.neg { background: #fde8e8; color: #c40000; }
table.ledger.lines td:nth-child(4) {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
}

.sheet { background: #fff; border: 1px solid var(--line); margin: 0 0 18px; }
.sheet-head { padding: 14px 14px 8px; }
.sheet-head h2 { font-size: 18px; }
.sheet-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.sheet table.grid { border: 0; }
.sheet table.grid th, .sheet table.grid td { border-color: #a8a29e; }
.summary-line { margin: 0 0 14px; color: var(--muted); }

.alert { border: 1px solid; border-radius: 4px; padding: 10px 12px; margin-bottom: 12px; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert ul { margin: 0; padding-left: 18px; }

.pager { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pager a, .pager .current {
    min-width: 32px;
    text-align: center;
    border: 1px solid var(--line);
    background: #fff;
    padding: 5px 8px;
    border-radius: 4px;
    color: var(--ink);
    text-decoration: none;
}
.pager .current { background: #0b2e6b; color: #fff; border-color: #0b2e6b; }

.print-head, .signatures { display: none; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; padding: 0; }
.swatch.active { outline: 2px solid var(--ink); outline-offset: 2px; }
.logo-preview, .current-logo { max-width: 72px; max-height: 36px; object-fit: contain; }
.mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
    font-weight: 650;
    overflow: hidden;
    object-fit: contain;
    background: #e7e5e4;
    flex: 0 0 auto;
}
.mark-sm { width: 20px; height: 20px; font-size: 11px; }
.mark-lg { width: 40px; height: 40px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.cash-box {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    min-height: 0;
}
.cash-box > h2 { padding: 14px 14px 0; flex: 0 0 auto; }
.cash-box > .alert { margin: 10px 14px 0; flex: 0 0 auto; }
.cash-box-scroll {
    overflow: visible;
    padding: 12px 14px 0;
    flex: 0 0 auto;
}
.cash-box .form-actions {
    margin: 0;
    padding: 12px 14px 14px;
    background: #fff;
    flex: 0 0 auto;
}
.type-row { display: flex; gap: 16px; min-height: 36px; align-items: center; }
.type-row label { display: flex; align-items: center; gap: 6px; }
.logo-row { display: flex; align-items: center; gap: 12px; }
.narrow { max-width: 480px; }
.form-sheet { max-width: 640px; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.photo-upload {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px dashed #a8a29e;
    border-radius: 8px;
    background: #fafaf9;
    padding: 12px;
    cursor: pointer;
}
.photo-upload:hover { border-color: var(--accent); background: #f8fafc; }
.photo-upload:focus-within { border-color: var(--accent); outline: 2px solid #93c5fd; outline-offset: 2px; }
.photo-frame {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.photo-frame .mark,
.photo-preview {
    width: 72px;
    height: 72px;
    border-radius: 0;
    object-fit: contain;
}
.photo-icon {
    color: #5c6f8f;
    font-size: 22px;
    line-height: 1;
}
.photo-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.photo-copy strong { font-size: 15px; }
.photo-copy small { color: var(--muted); font-size: 13px; word-break: break-word; }
.entry-form .bank-transfer { display: none; }
.entry-form.is-transfer .bank-single { display: none; }
.entry-form.is-transfer .bank-transfer { display: block; }
.bank-transfer .hint { margin: 6px 0 0; }

.page-split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; }
.cash-split { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 14px; align-items: start; }
.cash-split > section { min-width: 0; }
.day-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.day-nav .field { margin: 0; min-width: 150px; }
.sheet-meta { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.picker { position: relative; }
.picker-menu {
    position: absolute;
    z-index: 8;
    left: 0;
    right: 0;
    top: 100%;
    max-height: 220px;
    overflow: auto;
    margin: 2px 0 0;
    padding: 4px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.picker-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-radius: 4px;
    padding: 8px 10px;
    cursor: pointer;
}
.picker-menu button:hover,
.picker-menu button.is-active { background: var(--yellow); color: #0b2e6b; }
.balance-sheet { width: 100%; min-width: 0; }
.balance-sheet.is-screen {
    flex: 0 0 auto;
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 16px 12px;
    overflow: visible;
    box-shadow: var(--shadow);
}
.balance-sheet.is-screen .table-wrap {
    overflow: auto;
    background: #fff;
    border: 1px solid #0b2e6b;
}
.balance-sheet.is-screen table.balance { height: auto; }
.balance-sheet h2 { color: #0b2e6b; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
table.grid.balance { width: 100%; table-layout: fixed; }
table.balance { border: 1px solid #0b2e6b; }
table.balance th:nth-child(1) { width: 22%; }
table.balance th:nth-child(6) { width: 14%; }
table.balance th,
table.balance td { border-color: #d5deea; padding: 12px 16px; font-size: 16px; line-height: 1.4; }
table.balance thead th {
    background: #0b2e6b;
    color: #fff;
    border-color: #071f4d;
    text-align: center;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
    position: sticky;
    top: 0;
    z-index: 2;
}
table.balance td.name {
    background: #fff;
    color: #10233f;
    font-weight: 650;
}
table.balance td.name .name-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
table.balance td.date { white-space: nowrap; text-align: center; }
table.balance tr.day-row td {
    background: #4caf50;
    color: #fff;
    font-weight: 700;
    text-align: center;
    font-size: 17px;
}
table.balance tr.day-row td.num { text-align: right; }
table.balance tr.day-row td.date { text-align: center; }
table.balance tr.day-row td.neg { color: #ffe4e4; }
table.balance tfoot tr.totals td { background: #dbeafe; font-weight: 650; }
table.balance tfoot tr.summary-row td { background: var(--yellow); font-weight: 700; }
table.balance tfoot td.summary-label { text-align: center; }
.color-row { display: flex; align-items: center; gap: 10px; }
.category-field { border: 0; margin: 0; padding: 0; }
.category-field legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.category-field legend.category-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    float: none;
    padding: 0;
    margin: 0 0 8px;
    color: var(--muted);
}
.category-head .btn { min-height: 32px; padding: 0 12px; flex: 0 0 auto; }
.form-sheet .category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.new-category { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 8px; }
.new-category > .field:first-child { flex: 1 1 220px; }
.new-category input[type="text"] {
    min-width: 0;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 16px;
}
.color-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.color-picks label { position: relative; width: 22px; height: 22px; cursor: pointer; }
.color-picks input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}
.color-picks span {
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(11, 46, 107, 0.25);
}
.color-picks input:checked + span { box-shadow: 0 0 0 2px #0b2e6b; }
.color-picks input:focus-visible + span { outline: 2px solid #93c5fd; outline-offset: 2px; }
.color-wheel {
    position: relative;
    opacity: 1;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    padding: 0;
    border: 1px solid #0b2e6b;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}
.color-wheel::-webkit-color-swatch-wrapper { padding: 2px; }
.color-wheel::-webkit-color-swatch { border: 0; border-radius: 50%; }
.icon-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 4px;
    padding: 10px 12px;
    border: 1px dashed #8ea2c4;
    border-radius: 12px;
    background: #f7f9fd;
    cursor: pointer;
}
.icon-picker:hover { border-color: #0b2e6b; background: #fff; }
.icon-picker:focus-within { border-color: #0b2e6b; outline: 2px solid #93c5fd; outline-offset: 2px; }
.icon-picker-frame {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 6px 16px rgba(11, 46, 107, 0.12);
}
.icon-picker-frame .icon { font-size: 22px; color: #fff; }
.icon-picker-frame img { width: 100%; height: 100%; object-fit: cover; }
.icon-picker-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.icon-picker-copy strong { color: #0b2e6b; font-size: 14px; }
.icon-picker-copy small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-badge img.cat-icon { width: 16px; height: 16px; object-fit: cover; border-radius: 3px; }
.category-choice {
    position: relative;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 5px 8px;
    min-height: 36px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.category-choice:hover { border-color: #8ea2c4; }
.category-choice:focus-within,
.category-choice:has(input:checked) {
    border-color: #0b2e6b;
    box-shadow: 0 0 0 2px rgba(11, 46, 107, 0.14);
    background: #f4f7fc;
}
.cat-badge {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex: 0 0 auto;
}
.cat-badge .icon { font-size: 12px; width: auto; color: #fff; }
table.balance td.name .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
table.balance td.name .who > span:last-child { overflow: hidden; text-overflow: ellipsis; }
table.balance tr.remainder-row td,
table.ledger tr.remainder-row td { background: #e8eef8; font-weight: 700; }
.ledger-sheet {
    background: #fff;
    border: 1px solid #0b2e6b;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0 0 16px;
    max-width: none;
}
.ledger-sheet.is-summary { max-width: 560px; }
.sheet-link { margin: 0; padding: 8px 10px 0; text-align: right; }
.sheet-link a { color: #0b2e6b; font-weight: 650; }
.ledger-sheet .empty { padding: 14px 10px; }
table.home { width: 100%; }
table.home th { letter-spacing: 0; text-transform: none; font-size: 14px; text-align: left; position: static; }
table.home th.num { text-align: right; }
table.home td { background: #fff; }
table.home tr.home-balance td { background: var(--yellow); color: #0b2e6b; font-weight: 700; }
table.home tr.home-balance td.neg { color: var(--neg); }
table.home .who {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: inherit;
    font-weight: 650;
}
table.home .who:hover { color: var(--accent); text-decoration: none; }
body.page-report .content > .panel { flex: 0 0 auto; overflow: visible; height: auto; }
.report-bar { margin-bottom: 14px; }
.report-pick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.report-pick .field { min-width: min(320px, 100%); margin: 0; }
.report-sheet { padding: 0; overflow: visible; }
.report-sheet .table-wrap { overflow: auto; }
table.report tr.report-group td { background: #e8eef8; color: #0b2e6b; font-weight: 700; }
table.report { width: 1680px; min-width: 1680px; table-layout: fixed; }
table.report .c-date { width: 7%; }
table.report .c-name { width: 8%; }
table.report .c-user { width: 9%; }
table.report td.col-user { color: #1d4e89; }
table.report .c-unit, table.report .c-com, table.report .c-price, table.report .c-rate, table.report .c-co { width: 5.2%; }
table.report .c-cus, table.report .c-agent, table.report .c-own { width: 5.4%; }
table.report th { letter-spacing: 0; text-transform: none; font-size: 12px; background: #0b2e6b; border-color: #071f4d; white-space: normal; }
table.report td { overflow: hidden; text-overflow: ellipsis; background: #fff; }
table.report tr.report-total td { background: var(--yellow); color: #0b2e6b; font-weight: 700; }
table.report tr.report-total td.neg { color: var(--neg); }
.report-share { max-width: 520px; }
table.report-names { width: 100%; }
table.report-names th { letter-spacing: 0; text-transform: none; font-size: 14px; text-align: left; }
table.report-names th.num { text-align: right; }
table.report-names tr.report-total td { background: var(--yellow); color: #0b2e6b; font-weight: 700; }
table.report-names tr.report-total td.neg { color: var(--neg); }

@media (max-width: 1180px) {
    .filters, .filters-fit .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters-fit .actions-field { grid-column: 1 / -1; }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
    table.ledger.lines { min-width: 720px; }
    .history-bar { flex-wrap: wrap; }
}
@media (max-width: 960px) {
    .page-split, .cash-split { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .form-grid, .form-pair { grid-template-columns: 1fr; }
    .form-sheet .category-grid { grid-template-columns: 1fr 1fr; }
}

.auth-body { background: #dbeafe; }
.auth-box {
    width: min(420px, calc(100% - 32px));
    margin: 10vh auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 22px;
}
.auth-box h1 { margin-bottom: 4px; }
.auth-box .lede { color: var(--muted); margin-bottom: 16px; }
.setup-note { margin-top: 16px; color: var(--muted); font-size: 13px; }
.setup-note ol { padding-left: 18px; }
.setup-note code { color: var(--ink); }

@media (max-width: 860px) {
    table.grid.ledger,
    table.grid.balance { min-width: 640px; }
    h1 { font-size: 20px; }
    .balance-sheet h2 { font-size: 20px; }
    .btn { min-height: 44px; }
    .form-actions .btn { flex: 1 1 120px; }
    .filters, .filters-fit .filters { grid-template-columns: 1fr; }
    .filters-fit .actions-field { grid-column: auto; }
    .cash-split { gap: 10px; }
    #cash-form {
        max-height: none;
        height: auto;
        min-height: 0;
    }
    body.page-transactions .cash-split > section:last-child {
        max-height: none;
        overflow: visible;
    }
    table.balance th,
    table.balance td { font-size: 15px; padding: 8px 10px; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        width: 210px;
        flex-basis: 210px;
        padding: 22px 14px 16px;
        transform: translateX(-105%);
        transition: transform 0.15s ease;
    }
    body.nav-hidden .sidebar { width: 210px; flex-basis: 210px; padding: 22px 14px 16px; }
    .sidebar.open { transform: none; }
    .nav-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 25; }
    .today { display: none; }
    .content, .topbar { padding-left: 14px; padding-right: 14px; }
    body:not(.auth-body),
    body:not(.auth-body) .app,
    body:not(.auth-body) .main {
        height: auto;
        overflow: visible;
    }
    body:not(.auth-body) .content {
        overflow: visible;
        display: block;
    }
    .sidebar { height: 100vh; overflow: auto; }
}

@media print {
    body, body:not(.auth-body),
    body:not(.auth-body) .app,
    body:not(.auth-body) .main,
    body:not(.auth-body) .content { background: #fff; height: auto; overflow: visible; display: block; }
    .sidebar, .topbar, .no-print, .nav-backdrop, .skip { display: none !important; }
    .app, .main, .content { display: block; padding: 0; height: auto; overflow: visible; }
    .sheet, .panel { border: 0; box-shadow: none; margin: 0 0 16px; break-inside: avoid; }
    .print-head { display: block; margin-bottom: 12px; }
    .signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 36px; }
    .sign-line { border-top: 1px solid #000; margin-top: 36px; padding-top: 6px; font-size: 12px; }
    a { color: inherit; text-decoration: none; }
}

.form-sheet.is-chain { max-width: 1080px; }
.chain-picks, .report-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.chain-picks .btn, .report-tabs .btn { width: 100%; min-height: 40px; }
.report-tabs { margin: 0 0 12px; }
table.report tr[hidden] { display: none; }
.chain-picks[hidden] { display: none; }
.entry-bar, .file-page-bar, .entry-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.entry-bar > .btn, .file-page-bar > .btn, .entry-actions > .btn, .entry-actions form .btn, .file-list .btn {
    min-height: 40px;
    min-width: 96px;
}
.entry-file-name { color: #0b2e6b; font-size: 16px; min-width: 120px; }
.entry-actions { margin-left: auto; }
.entry-actions form { display: flex; align-items: center; gap: 8px; margin: 0; }
.entry-save-status { min-width: 72px; color: var(--muted); font-size: 13px; }
.file-page-bar { margin-bottom: 12px; }
.file-search { flex: 1 1 220px; max-width: 360px; margin: 0; }
.file-search input { width: 100%; min-height: 40px; }
table.file-list { width: 100%; }
table.file-list th:nth-child(1), table.file-list td:nth-child(1) { width: 46%; }
table.file-list th:nth-child(2), table.file-list td:nth-child(2) { width: 28%; }
table.file-list th:nth-child(3), table.file-list td:nth-child(3) { width: 26%; text-align: right; }
table.file-list tr[hidden] { display: none; }
td.edit-cell.is-dirty { box-shadow: inset 0 0 0 2px #1f4e79; }
.jpg-choice { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(11, 46, 107, 0.35); padding: 16px; }
.jpg-choice[hidden] { display: none; }
.jpg-choice-card { width: min(420px, 100%); background: #fff; border: 1px solid #d6deea; padding: 18px; }
.jpg-choice-card h2 { margin: 0 0 6px; color: #0b2e6b; font-size: 18px; }
.jpg-choice-card p { margin: 0 0 14px; color: var(--muted); }
.jpg-choice-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.jpg-choice-actions .btn { width: 100%; min-height: 40px; }
.jpg-quality { display: flex; align-items: center; gap: 6px; margin: 0; }
.jpg-quality span { color: var(--muted); font-size: 13px; }
.jpg-quality input { width: 72px; min-height: 40px; text-align: center; }
.chain-user { background: #e8f6ee; border: 1px solid #4caf50; border-radius: 8px; padding: 8px; }
.chain-user .chain-section-head strong { color: #0f7a56; }
.flow-card[hidden] { display: none; }
td.edit-cell { cursor: pointer; }
td.edit-cell input { width: 100%; min-width: 0; border: 0; box-shadow: inset 0 0 0 1px #1f4e79; background: transparent; color: inherit; text-align: right; font: inherit; font-size: 16px; padding: 0 4px; }
td.edit-cell[data-format="text"] input { text-align: left; }
.report-export { margin-top: 12px; }
@media (max-width: 860px) {
    .chain-picks, .report-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .entry-actions { margin-left: 0; width: 100%; }
    .entry-bar { align-items: stretch; }
    .entry-file-name { flex: 1 1 100%; min-width: 0; }
    .entry-actions form { flex: 1 1 100%; flex-wrap: wrap; }
    #entry-save { flex: 1 1 140px; }
    .report-tabs .btn, .entry-bar .btn, .file-page .btn, .file-search input { min-height: 44px; }
    .page-report input, .page-report select, .page-report textarea { font-size: 16px; }
    .report-sheet .table-wrap { -webkit-overflow-scrolling: touch; }
    table.report th, table.report td { padding: 12px 8px; }
}
.chain-flow { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.flow-card { border: 1px solid #d6deea; border-radius: 12px; padding: 12px; background: #f8fafc; display: flex; flex-direction: column; gap: 8px; }
.flow-card h3 { margin: 0; color: #0b2e6b; font-size: 16px; }
.chain-flow[hidden] { display: none; }
.chain-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.chain-section-head strong { color: #0b2e6b; }
.chain-row,
.chain-labels.is-user {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) repeat(3, minmax(80px, 0.7fr)) auto;
    gap: 6px;
    align-items: center;
}
.chain-row.is-agent,
.chain-labels.is-agent {
    grid-template-columns: minmax(140px, 1.4fr) repeat(2, minmax(90px, 0.8fr)) auto;
}
.chain-row.is-owner,
.chain-row.is-company,
.chain-labels.is-owner,
.chain-labels.is-company {
    grid-template-columns: minmax(140px, 1.4fr) repeat(2, minmax(90px, 0.8fr));
}
.chain-labels { color: var(--muted); font-size: 13px; }
.chain-flow input {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 8px 10px;
    min-height: 36px;
    font-size: 16px;
}
.chain-remove { min-height: 36px; padding: 0 10px; }
.entry-toolbar { margin-bottom: 12px; }
.entry-switch { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.entry-switch .field { min-width: min(280px, 100%); flex: 1 1 220px; }
.btn.is-disabled { opacity: 0.45; pointer-events: none; }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.entry-head h2 { margin: 0; color: #0b2e6b; font-size: 20px; }
.entry-head p { margin: 0; color: var(--muted); }
.entry-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 8px; }
.flow-name-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.flow-name-list li { background: #0b2e6b; color: #fff; border-radius: 8px; padding: 8px 12px; font-weight: 700; }
.entry-grid { width: 100%; border-collapse: collapse; min-width: 720px; }
.entry-summary.entry-grid { min-width: 520px; }
.entry-grid th {
    background: #0b2e6b;
    color: #fff;
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    white-space: nowrap;
}
.entry-grid td { border: 1px solid #d6deea; padding: 0; background: #fff; }
.entry-grid input {
    width: 100%;
    border: 0;
    background: transparent;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 16px;
    font-family: inherit;
}
.entry-grid input:focus { outline: 2px solid #e0a800; outline-offset: -2px; }
.entry-grid td:nth-child(n+3) input,
.entry-grid .calc { text-align: right; font-variant-numeric: tabular-nums; }
.entry-grid td:nth-child(1) input,
.entry-grid td:nth-child(2) input { text-align: left; }
.entry-grid td.calc { background: #fff; }
.entry-grid tr.entry-total td.calc { background: #e0a800; padding: 8px 10px; }
.entry-grid tr.entry-section td { background: #e8eef8; color: #0b2e6b; font-weight: 700; padding: 8px 10px; }
.entry-grid tr.entry-total td { background: #e0a800; color: #0b2e6b; font-weight: 700; padding: 8px 10px; }
.entry-grid tr.entry-total td.calc { background: #e0a800; }
.entry-sheet .form-actions { align-items: center; }
.entry-sheet .form-actions .hint { margin: 0; }
