/* ====================================================================
   ລະບົບບັນຊີຄູ່ — ຮູບແບບໃໝ່ (desktop + ມືຖື)
   ==================================================================== */
:root {
    --primary: #1D4E89;
    --primary-dark: #163D6C;
    --primary-soft: #E8F0FA;
    --bg: #F3F5F8;
    --surface: #FFFFFF;
    --border: #E3E8EF;
    --border-strong: #D5DCE6;
    --ink: #16202E;
    --muted: #5B6779;
    --success: #1F7A4D;
    --success-soft: #E7F4EC;
    --warning: #8A4A07;
    --warning-soft: #FDF4E7;
    --danger: #B42318;
    --danger-soft: #FDECEA;
    --radius: 12px;
    --header-h: 60px;
    --sidebar-w: 256px;
    --bottom-h: 64px;
}

html, body {
    font-family: "Noto Sans Lao", "Phetsarath OT", sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); }
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.small { font-size: .8125rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-l { font-variant-numeric: tabular-nums; white-space: nowrap; }
.code { font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
.code-strong { font-weight: 700; color: var(--primary); }
.warn-text { color: var(--warning); font-weight: 700; }

.only-mobile { display: none !important; }
@media (max-width: 959.98px) {
    .only-desktop { display: none !important; }
    .only-mobile { display: revert !important; }
    nav.only-mobile, .card-list.only-mobile { display: flex !important; }
    button.only-mobile { display: flex !important; }
}

/* ---------- shell ---------- */
.app-shell { min-height: 100vh; }

.app-header {
    position: sticky; top: 0; z-index: 1200;
    height: var(--header-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: calc(var(--sidebar-w) - 36px); }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--primary); color: #fff; font-weight: 700; font-size: .85rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: .95rem; }
.brand-text small { color: var(--muted); font-size: .75rem; }

.header-chips { display: flex; gap: 8px; min-width: 0; }
.hchip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 38px; padding: 0 12px; max-width: 360px;
    border: 1px solid var(--border-strong); border-radius: 999px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: .875rem; cursor: pointer;
}
.hchip:hover { background: var(--primary-soft); border-color: #bcd0ea; }
.hchip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-menu .mud-list { max-height: 60vh; overflow-y: auto; }
.menu-active { background: var(--primary-soft); font-weight: 600; }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-link {
    position: relative; width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; color: var(--muted);
}
.icon-link:hover { background: var(--bg); }
.dot-badge {
    position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700;
    display: grid; place-items: center; border: 2px solid var(--surface);
}
.avatar {
    width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
    background: var(--primary-soft); color: var(--primary); font: inherit; font-weight: 700;
    display: inline-grid; place-items: center;
}
.menu-user { padding: 10px 16px 6px; font-size: .875rem; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-form { margin: 0; }
.menu-logout {
    width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 16px;
    border: 0; background: none; font: inherit; color: var(--danger); cursor: pointer; text-align: left;
}
.menu-logout:hover { background: var(--danger-soft); }

.app-sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0; width: var(--sidebar-w);
    overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border);
    padding: 12px 10px 24px;
}
.app-main { margin-left: var(--sidebar-w); padding: 24px 28px 40px; max-width: 1480px; }

/* ---------- nav ---------- */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group {
    margin: 16px 12px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
    color: #8792A2; text-transform: uppercase;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    min-height: 42px; padding: 0 12px; border-radius: 10px;
    color: #344054; text-decoration: none; font: inherit; font-size: .9rem;
    border: 0; background: none; cursor: pointer; text-align: left; width: 100%; justify-content: flex-start;
}
.nav-item .mud-icon-root { color: #7A8597; font-size: 1.25rem; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.active .mud-icon-root { color: var(--primary); }
.nav-badge {
    margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
    background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}

/* ---------- mobile ---------- */
@media (max-width: 959.98px) {
    .app-header { background: var(--primary); color: #fff; border-bottom: 0; padding: 0 12px 0 16px; }
    .brand { min-width: 0; }
    .brand-mark { background: rgba(255,255,255,.16); }
    .icon-link { color: #fff; }
    .icon-link:hover { background: rgba(255,255,255,.12); }
    .dot-badge { border-color: var(--primary); }

    .mobile-context {
        width: 100%; align-items: center; gap: 8px; padding: 0 16px 12px; border: 0;
        background: var(--primary); color: #DCE7F5; font: inherit; font-size: .85rem; text-align: left; cursor: pointer;
    }
    .mobile-context .hchip-text { flex: 1; }

    .app-main { margin-left: 0; padding: 16px 16px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); }

    .bottom-nav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1250;
        height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface); border-top: 1px solid var(--border);
        align-items: center; justify-content: space-around;
        box-shadow: 0 -4px 16px rgba(16, 32, 60, .06);
    }
    .bn-item {
        position: relative; flex: 1; height: 100%;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        color: #7A8597; text-decoration: none; font: inherit; font-size: .7rem;
        border: 0; background: none; cursor: pointer;
    }
    .bn-item.active { color: var(--primary); font-weight: 600; }
    .bn-badge {
        position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
        border-radius: 9px; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700;
        display: grid; place-items: center;
    }
    .bn-fab {
        width: 56px; height: 56px; margin-top: -26px; border-radius: 18px; border: 0;
        background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer;
        box-shadow: 0 8px 20px rgba(29, 78, 137, .35);
    }
    .bn-fab .mud-icon-root { font-size: 1.8rem; }
}

.sheet-backdrop { position: fixed; inset: 0; z-index: 1300; background: rgba(16, 24, 40, .45); animation: fade .15s ease-out; }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1301;
    max-height: 88vh; overflow-y: auto;
    background: var(--surface); border-radius: 20px 20px 0 0;
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
    animation: slide-up .2s ease-out;
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 4px auto 12px; }
.sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 8px 12px; }
.sheet-selects { display: grid; gap: 10px; padding: 0 4px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.sheet-foot { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; display: grid; gap: 2px; }
.sheet-foot form { margin: 0; }
.sheet-link {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; width: 100%;
    color: #344054; text-decoration: none; border: 0; background: none; font: inherit; cursor: pointer; border-radius: 10px;
}
.sheet-link.danger { color: var(--danger); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }

/* ---------- page / cards ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
h1:focus, h1:focus-visible { outline: none; }
.page-head h1 { margin: 0; font-size: 1.4rem; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: .875rem; margin-top: 2px; }

.card, .mud-paper:not(.mud-popover):not(.mud-dialog):not(.mud-snackbar):not(.mud-appbar):not(.mud-picker-paper) {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: none !important;
}
.card { padding: 18px; margin-bottom: 16px; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card.narrow { max-width: 480px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title { margin: 0; font-size: 1rem; font-weight: 700; }
.link { font-size: .85rem; font-weight: 600; text-decoration: none; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 16px; }
.filter-bar > .mud-input-control { flex: 1 1 180px; max-width: 260px; margin: 0; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi-label { color: var(--muted); font-size: .82rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; margin: 4px 0 6px; }
.kpi-value.num { text-align: left !important; }
.kpi-value small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.kpi-foot { color: var(--muted); font-size: .78rem; }
.kpi.hero { background: var(--primary); border-color: var(--primary); color: #fff; }
.kpi.hero .kpi-label, .kpi.hero .kpi-foot, .kpi.hero .kpi-value.num { text-align: left !important; }
.kpi-value small { color: #C9D8EC; }
.kpi.hero .bar { background: rgba(255,255,255,.2); }
.kpi.hero .bar span { background: #fff; }
.kpi.warn { background: var(--warning-soft); border-color: #F3D9B5; }
.kpi.warn .kpi-value { color: var(--warning); }
@media (max-width: 959.98px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi.hero, .kpi:last-child { grid-column: 1 / -1; }
    .kpi-value { font-size: 1.3rem; }
}

.bar { height: 8px; border-radius: 4px; background: #EDF1F6; overflow: hidden; margin: 6px 0; }
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--primary); transition: width .3s; }
.bar.warn span { background: #D9822B; }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.qa {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 48px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
    font: inherit; font-size: .875rem; cursor: pointer; color: var(--ink);
}
.qa:hover { border-color: #bcd0ea; background: var(--primary-soft); }
@media (max-width: 959.98px) {
    .quick-actions { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px; scrollbar-width: none; }
    .qa { flex: 0 0 auto; }
}

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.dash-grid > .card { margin-bottom: 16px; }
@media (max-width: 959.98px) { .dash-grid { grid-template-columns: 1fr; gap: 0; } }

.usage { padding: 8px 0; border-bottom: 1px solid var(--border); }
.usage:last-child { border-bottom: 0; }
.usage-top { display: flex; justify-content: space-between; gap: 8px; font-size: .875rem; }
.usage-foot { text-align: left !important; color: var(--muted); font-size: .75rem; }

/* list rows */
.card-list { flex-direction: column; }
.list-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px 4px; border: 0; border-bottom: 1px solid var(--border);
    background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.card-list .list-item { padding: 12px 16px; }
.list-item:last-child { border-bottom: 0; }
.list-item:not(.static):hover { background: #F8FAFC; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.li-main b { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-main small { color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-main.as-link { border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; padding: 0; }
.li-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.approve-btn { width: 40px; height: 40px; border-radius: 12px !important; }

.empty { padding: 32px 16px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 6px; }
.empty.small { padding: 18px 8px; display: flex; justify-content: center; align-items: center; gap: 8px; }

/* badges */
.book-badge {
    flex: 0 0 auto; display: inline-grid; place-items: center;
    min-width: 38px; height: 38px; padding: 0 6px; border-radius: 10px;
    font-size: .75rem; font-weight: 700; background: var(--primary-soft); color: var(--primary);
}
.book-badge.sm { min-width: 30px; height: 24px; border-radius: 6px; font-size: .68rem; }
.book-p { background: #EEE9FB; color: #5B3CC4; }
.book-r { background: var(--success-soft); color: var(--success); }
.book-rv { background: #E6F5F7; color: #0E7490; }
.book-adg { background: #F1F3F6; color: #475467; }

.status-pill {
    display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px;
    font-size: .74rem; font-weight: 600; white-space: nowrap;
}
.st-draft { background: #F1F3F6; color: #475467; }
.st-pending { background: var(--warning-soft); color: var(--warning); }
.st-posted { background: var(--success-soft); color: var(--success); }
.st-reversed { background: var(--danger-soft); color: var(--danger); }
.kind-tag { margin-left: 6px; font-size: .72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }

/* chips */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chip-row.tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-top: 0; }
.chip {
    flex: 0 0 auto; height: 34px; padding: 0 14px; border-radius: 17px;
    border: 1px solid var(--border-strong); background: var(--surface);
    font: inherit; font-size: .82rem; color: #344054; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* tables */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
    text-align: left; font-weight: 600; font-size: .78rem; color: var(--muted);
    background: #F8FAFC; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: #F8FAFC; }

.mud-table-root th, .mud-simple-table th { font-weight: 600 !important; color: var(--muted); background: #F8FAFC; }
.total-row td { font-weight: 700; background: #F3F6FA; }
.level-1 td { font-weight: 700; background: #F6F8FB; }
.level-2 td { font-weight: 600; }

/* ຕາຕະລາງກວ້າງ (ເລກບັນຊີເປັນຖັນ): ຕຶງຖັນທຳອິດ ເລື່ອນແນວນອນ */
.wide-table { overflow-x: auto; max-width: 100%; }
.wide-table table { border-collapse: separate; border-spacing: 0; }
.wide-table th, .wide-table td { min-width: 120px; }
.wide-table th:first-child, .wide-table td:first-child {
    position: sticky; left: 0; z-index: 1; background: #fff; min-width: 320px; max-width: 420px;
    box-shadow: 1px 0 0 var(--border);
}
.wide-table thead th { position: sticky; top: 0; background: #F3F6FA; z-index: 2; }
.wide-table thead th:first-child { z-index: 3; }
@media (max-width: 959.98px) {
    .wide-table th:first-child, .wide-table td:first-child { min-width: 180px; max-width: 220px; }
}

.account-table { max-height: 70vh; overflow-y: auto; }
.import-list { margin: 4px 0 8px 20px; font-size: .875rem; max-height: 260px; overflow-y: auto; }
.line-input { width: 100%; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 6px; font: inherit; }
.balance-ok { color: var(--success); font-weight: 600; }
.balance-bad { color: var(--danger); font-weight: 600; }

/* buttons */
.btn-lg { min-height: 44px; padding-left: 18px !important; padding-right: 18px !important; border-radius: 10px !important; }
.icon-btn { color: var(--muted) !important; }
.mud-button-root { letter-spacing: 0; }

/* ---------- dialogs ---------- */
.mud-dialog.lga-dialog { border-radius: 18px; overflow: hidden; }
.lga-dialog .mud-dialog-content { padding: 20px 22px 8px; }
.lga-dialog .mud-dialog-actions { padding: 8px 22px 20px; }
.lga-dialog-sm { max-width: 440px !important; }
.dialog-actions { display: flex; gap: 10px; width: 100%; }
.dialog-actions .grow { flex: 1; }
.dialog-actions .grow-2 { flex: 2; }
.dialog-title-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dialog-title-bar h2 { margin: 0; font-size: 1.1rem; }
.dialog-head-row { display: flex; gap: 14px; align-items: flex-start; }

.confirm-head { text-align: center; display: grid; justify-items: center; gap: 6px; padding-top: 6px; }
.confirm-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.confirm-icon.small { width: 44px; height: 44px; }
.confirm-icon .mud-icon-root { font-size: 1.8rem; }
.confirm-icon.small .mud-icon-root { font-size: 1.4rem; }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-primary { background: var(--primary-soft); color: var(--primary); }
.confirm-title { margin: 4px 0 0; font-size: 1.15rem; font-weight: 700; }
.confirm-msg { margin: 0; color: var(--muted); font-size: .9rem; }
.detail-box { margin-top: 14px; background: #F8FAFC; border: 1px solid var(--border); border-radius: 12px; padding: 4px 14px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: .875rem; }
.detail-row:last-child { border-bottom: 0; }
.detail-row span { color: var(--muted); }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; font-size: .85rem; }
.note .mud-icon-root { flex: 0 0 auto; }
.note.success { background: var(--success-soft); color: var(--success); }
.note.warning { background: var(--warning-soft); color: var(--warning); }
.note.danger { background: var(--danger-soft); color: var(--danger); }

/* account picker */
.picker .mud-dialog-content { padding-bottom: 14px; }
.picker-search { margin: 0 !important; }
.picker-list { max-height: 52vh; overflow-y: auto; margin: 0 -8px; }
.picker-item {
    display: flex; flex-direction: column; gap: 2px; width: 100%;
    padding: 10px 12px; border: 0; border-radius: 10px; background: none;
    font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.picker-item:hover, .picker-item:focus-visible { background: var(--primary-soft); outline: none; }
.picker-main { font-size: .9rem; }
.picker-path { font-size: .74rem; color: var(--muted); }
.picker-foot { margin-top: 8px; font-size: .75rem; color: var(--muted); }

/* ---------- journal form ---------- */
.journal-dialog .mud-dialog-content { padding: 0 !important; }
.jf { display: flex; flex-direction: column; }
.jf-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.jf-title { flex: 1; min-width: 0; }
.jf-title h2 { margin: 0; font-size: 1.1rem; }
.jf-title .sub { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jf-body { padding: 18px 20px; }
.jf.in-dialog .jf-body { max-height: calc(100vh - 230px); overflow-y: auto; }
.jf-foot {
    display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
    padding: 14px 20px; border-top: 1px solid var(--border); background: #FBFCFD;
}
.foot-left, .foot-right { display: flex; gap: 10px; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.form-grid > * { margin: 0 !important; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-grid .span-3 { grid-column: span 3; }

.lines { display: flex; flex-direction: column; gap: 8px; }
.line-row { display: grid; grid-template-columns: minmax(0, 1fr) 170px 170px 40px; gap: 10px; align-items: center; }
.line-row > .mud-input-control { margin: 0 !important; }
.line-head { font-size: .78rem; color: var(--muted); font-weight: 600; padding: 0 4px; }
.line-head .num-col { text-align: right; padding-right: 12px; }
.line-row.auto { background: #FAFBFD; border-radius: 12px; }

.acct-field {
    display: flex; align-items: center; gap: 8px; min-height: 42px;
    border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 4px 0 10px; background: var(--surface);
}
.acct-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 137, .12); }
.acct-field.dashed { border-style: dashed; background: transparent; }
.code-input {
    width: 96px; flex: 0 0 auto; border: 0; outline: 0; background: transparent;
    font: inherit; font-weight: 700; color: var(--primary); text-align: left; font-variant-numeric: tabular-nums;
}
.acct-name { flex: 1; min-width: 0; font-size: .85rem; color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-badge { flex: 0 0 auto; font-size: .68rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 2px 8px; border-radius: 8px; }
.acct-search {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; border: 0; cursor: pointer;
    background: var(--bg); color: var(--muted); display: grid; place-items: center;
}
.acct-search:hover { background: var(--primary-soft); color: var(--primary); }
.amount input { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.line-tools { display: flex; gap: 6px; flex-wrap: wrap; }

.hint-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 16px; }

@media (max-width: 959.98px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .form-grid .span-3 { grid-column: 1 / -1; }
}

/* ---------- mobile dialogs: ເຕັມຈໍ ---------- */
@media (max-width: 599.98px) {
    .mud-dialog-container .mud-dialog.lga-dialog:not(.lga-dialog-sm) {
        margin: 0 !important; width: 100vw !important; max-width: 100vw !important;
        height: 100dvh; max-height: 100dvh !important; border-radius: 0;
    }
    .mud-dialog.lga-dialog-sm { margin: 0 12px !important; width: calc(100vw - 24px); }
    .mud-dialog.picker { display: flex; flex-direction: column; }
    .picker .mud-dialog-content { flex: 1; display: flex; flex-direction: column; }
    .picker-list { max-height: none; flex: 1; }

    .journal-dialog .mud-dialog-content { height: 100%; }
    .jf.in-dialog { height: 100dvh; }
    .jf.in-dialog .jf-body { flex: 1; max-height: none; }
    .jf-head { padding: 12px 14px; }
    .jf-body { padding: 14px; }
    .jf-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
    .jf-foot .foot-left:not(:has(.mud-button-root:not(.only-desktop))) { display: none; }
    .jf-foot .foot-right { flex: 1; display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
    .jf-foot .foot-right > .mud-button-root:nth-child(3) { grid-column: 1 / -1; }
    .jf-foot .foot-right > .mud-button-root:only-child { grid-column: 1 / -1; }

    .form-grid { grid-template-columns: 1fr; }
    .line-head { display: none; }
    .line-row {
        grid-template-columns: 1fr 1fr 40px;
        padding: 10px; border: 1px solid var(--border); border-radius: 14px;
    }
    .line-row .acct-field { grid-column: 1 / -1; }
    .line-row.auto { border-style: dashed; }
}


/* ====================================================================
   ຟອມ popup ແລະ ໜ້າອື່ນໆ
   ==================================================================== */
.form-dialog { display: flex; flex-direction: column; }
.form-dialog .mud-dialog-content { flex: 1; overflow-y: auto; }
.dialog-title-bar .dt-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dialog-title-bar .sub { color: var(--muted); font-size: .8rem; }
.form-stack { display: flex; flex-direction: column; gap: 12px; padding-bottom: 4px; }
.form-stack > .mud-input-control, .form-grid-2 > .mud-input-control { margin: 0 !important; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: center; }
@media (max-width: 599.98px) { .form-grid-2 { grid-template-columns: 1fr; } }
.section-label { font-size: .78rem; font-weight: 700; color: var(--muted); margin-top: 6px; letter-spacing: .02em; }
.amount-line { display: grid; grid-template-columns: minmax(0, 1fr) 160px 40px; gap: 8px; align-items: center; }
.amount-line.fixed { grid-template-columns: 120px minmax(0, 1fr); }
.amount-line > .mud-input-control { margin: 0 !important; }
@media (max-width: 599.98px) {
    .amount-line { grid-template-columns: 1fr 40px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
    .amount-line .acct-wrap { grid-column: 1 / -1; }
}
.total-chip { margin-left: auto; font-size: .85rem; color: var(--muted); }
.total-chip b { color: var(--ink); font-size: 1rem; }
.sub-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #FBFCFD; }
.hint { font-size: .78rem; color: var(--muted); }
.inline-form { display: flex; gap: 10px; align-items: center; }
.inline-form > .mud-input-control { margin: 0 !important; flex: 1; }
.field-label { display: block; font-size: .78rem; color: var(--muted); margin: 0 0 4px 2px; }
.acct-field.disabled { background: #F6F8FA; }

.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.status-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.sb-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sb-main .status-pill { align-self: center; margin-right: 6px; }
.sb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.big { font-size: 1.35rem; font-weight: 700; }
.split { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.split > .card { margin-bottom: 0; }
@media (max-width: 1199.98px) { .split { grid-template-columns: 1fr; } }
.card-head.padded { padding: 14px 16px 4px; margin: 0; }
.list-item.padded { padding: 12px 16px; }
.pad-s { padding: 8px 14px; }

.kpi-grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 959.98px) { .kpi-grid.three { grid-template-columns: 1fr 1fr; } .kpi-grid.three .kpi:first-child { grid-column: 1 / -1; } .kpi-grid.three .kpi:last-child { grid-column: auto; } }

.note.info { background: var(--primary-soft); color: var(--primary); }
.row-muted td, .row-muted.tree-row { opacity: .55; }
.data-table td.actions { text-align: right; white-space: nowrap; }
.data-table td.center, .data-table th.center { text-align: center; }
.data-table.bordered th, .data-table.bordered td { border-right: 1px solid var(--border); }
.data-table.bordered th:last-child, .data-table.bordered td:last-child { border-right: 0; }
.data-table .neg { color: var(--danger); font-weight: 700; }
.data-table.tree tr.level-1 td { background: #F3F6FA; font-weight: 700; }
.data-table.tree tr.level-2 td { font-weight: 600; }
.data-table.report tr.level-1 td { background: #F3F6FA; font-weight: 700; }
.data-table.report tr.level-2 td { font-weight: 600; }
.data-table.report td, .data-table.report th { padding: 9px 12px; }
.col-name { display: block; max-width: 160px; white-space: normal; font-weight: 400; line-height: 1.25; text-align: right; }
.pct-cell { min-width: 130px; }
.pct-wrap { display: flex; align-items: center; gap: 8px; }
.bar.mini { flex: 1; height: 6px; margin: 0; }
.acct-cell { display: inline-flex; gap: 10px; align-items: baseline; }
.data-table td.tags { text-align: right; white-space: nowrap; }
.kind-tag.ok { color: var(--success); border-color: #BFE3CD; background: var(--success-soft); }

.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll.sticky-first th:first-child, .table-scroll.sticky-first td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 260px; box-shadow: 1px 0 0 var(--border);
}
.table-scroll.sticky-first thead th:first-child { background: #F8FAFC; z-index: 2; }
.table-scroll.sticky-first tr.level-1 td:first-child, .table-scroll.sticky-first .total-row td:first-child { background: #F3F6FA; }
@media (max-width: 959.98px) {
    .table-scroll.sticky-first th:first-child, .table-scroll.sticky-first td:first-child { min-width: 180px; max-width: 220px; }
    .data-table.report { font-size: .8rem; }
}

/* ຕາຕະລາງທີ່ກາຍເປັນບັດໃນມືຖື (ໃສ່ data-label ໃຫ້ td) */
@media (max-width: 959.98px) {
    .rtable thead { display: none; }
    .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
    .rtable tr { padding: 10px 16px; border-bottom: 1px solid var(--border); }
    .rtable tr:last-child { border-bottom: 0; }
    .rtable td { border: 0 !important; padding: 3px 0 !important; text-align: right !important; min-height: 26px; }
    .rtable td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--muted); font-size: .78rem; line-height: 1.9; }
    .rtable td:not([data-label])::before { content: none; }
    .rtable td.actions { padding-top: 6px !important; }
    .rtable td.actions:empty { display: none; }
    .rtable td:first-child { font-size: .95rem; }
}

/* ໂຄງສ້າງໜ່ວຍງານ */
.tree-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    padding-left: calc(16px + var(--depth, 0) * 22px); border-bottom: 1px solid var(--border);
}
.tree-row:last-child { border-bottom: 0; }
.tree-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto; }
.access-tag { font-size: .72rem; padding: 2px 8px; border-radius: 8px; background: #F1F3F6; color: #475467; white-space: nowrap; }
.access-tag.lv-3, .access-tag.lv-4 { background: var(--success-soft); color: var(--success); }
.access-tag.lv-2 { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 599.98px) {
    .tree-row { padding-left: calc(12px + var(--depth, 0) * 12px); }
    .access-tag { display: none; }
}

/* ງວດ */
.period-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.period { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.period.closed { background: #F6F8FA; }
.period-no { font-size: 1.3rem; font-weight: 700; }
.period-range { font-size: .8rem; color: var(--muted); }
.period-status { display: flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--success); margin-bottom: 4px; }
.period.closed .period-status { color: var(--muted); }
@media (max-width: 599.98px) { .period-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; } .period { padding: 10px; } }
.steps { margin: 0 0 14px; padding-left: 20px; color: #344054; font-size: .9rem; display: grid; gap: 4px; }

/* ນຳເຂົ້າ */
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; min-width: 110px; display: flex; flex-direction: column; }
.stat span { font-size: .75rem; color: var(--muted); }
.stat b { font-size: 1.2rem; }
.stat.ok b { color: var(--success); }
.stat.warn b { color: var(--warning); }
.disclosure { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.disclosure summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.disclosure[open] summary { margin-bottom: 8px; }
details.card.disclosure { padding: 14px 18px; }
.import-list { margin: 6px 0 0 18px; padding: 0; font-size: .85rem; max-height: 260px; overflow-y: auto; }

/* ---------- login ---------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: radial-gradient(circle at 20% 0%, #2B66AB 0, var(--primary) 45%, #10335E 100%);
}
.login-card {
    background: #fff; width: 100%; max-width: 400px; padding: 34px 28px 28px;
    border-radius: 20px; box-shadow: 0 24px 60px rgba(8, 24, 50, .35);
}
.login-card h1 { margin: 0; font-size: 1.45rem; color: var(--ink); }
.login-sub { margin: 4px 0 22px; color: var(--muted); font-size: .9rem; }
.login-card label { display: block; margin: 14px 0 6px; font-size: .875rem; color: #344054; font-weight: 600; }
.login-card input {
    width: 100%; box-sizing: border-box; height: 46px; padding: 0 14px;
    border: 1px solid var(--border-strong); border-radius: 10px; font: inherit; font-size: 1rem;
}
.login-card input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 137, .15); }
.login-card button {
    margin-top: 22px; width: 100%; height: 48px; border: 0; border-radius: 12px;
    background: var(--primary); color: #fff; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.login-card button:hover { background: var(--primary-dark); }
.login-error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: .875rem; }
.validation-message { color: var(--danger); font-size: .8rem; }

/* snackbar */
.mud-snackbar { border-radius: 12px !important; font-family: inherit; }
@media (max-width: 959.98px) {
    .mud-snackbar-location-bottom-center { bottom: calc(var(--bottom-h) + 12px + env(safe-area-inset-bottom)) !important; }
}

@media print {
    .app-header, .app-sidebar, .bottom-nav, .mobile-context, .no-print { display: none !important; }
    .app-main { margin: 0 !important; padding: 0 !important; }
    .card { border: 0; }
}
