@font-face {
    font-family: Vazirmatn;
    src: url("fonts/Vazirmatn-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: Vazirmatn;
    src: url("fonts/Vazirmatn-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: Vazirmatn;
    src: url("fonts/Vazirmatn-ExtraBold.ttf") format("truetype");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
    color: #16325c;
    background-color: #6a4324;
    background-image:
        repeating-linear-gradient(90deg, rgba(0, 0, 0, .055) 0 2px, transparent 2px 18px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 11px),
        linear-gradient(165deg, #8a5a32 0%, #5b391f 48%, #3d2614 100%);
}

button, input, select { font-family: inherit; }

button { cursor: pointer; }

#app { min-height: 100vh; }

.home {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px 40px;
    background:
        linear-gradient(180deg, rgba(16, 12, 8, .62) 0%, rgba(16, 12, 8, .28) 32%, rgba(16, 12, 8, .38) 68%, rgba(16, 12, 8, .72) 100%),
        url("doors-bg.png") center 42% / cover no-repeat;
}

.brand {
    text-align: center;
    color: #fff;
    margin-bottom: 28px;
}

.brand h1 {
    margin: 0;
    font-size: 46px;
    font-weight: 800;
    letter-spacing: 0;
    text-shadow: 0 2px 16px rgba(0, 0, 0, .45);
}

.brand p {
    display: inline-block;
    margin: 10px 0 0;
    padding: 4px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    font-size: 16px;
    letter-spacing: 0;
}

.now {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.brand .now {
    display: block;
    margin-top: 12px;
    font-size: 22px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .55);
}

.toolbar .now {
    background: rgba(255, 255, 255, .16);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 14px;
}

.covers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 300px));
    justify-content: center;
    gap: 18px;
    width: min(980px, 100%);
    align-items: stretch;
}

.cover {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: right;
    background: rgba(255, 255, 255, .96);
    color: #1a4a96;
    border: 0;
    border-radius: 16px;
    padding: 18px 18px 16px;
    min-height: 228px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
    transition: transform .18s ease, box-shadow .18s ease;
}

.cover:hover {
    transform: translateY(-6px);
    box-shadow: 0 24px 46px rgba(0, 0, 0, .34);
}

.cover .kicker {
    align-self: flex-start;
    color: #fff;
    background: #c62828;
    border-radius: 999px;
    padding: 3px 10px;
    font-weight: 800;
    font-size: 12px;
}

.cover strong {
    display: block;
    margin-top: 12px;
    font-size: 28px;
    line-height: 1.25;
    color: #1a4a96;
}

.cover .sub {
    color: #5d7194;
    margin-top: 4px;
    min-height: 22px;
}

.cols {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 16px 0 12px;
}

.cols span {
    border: 1px solid #d5e3f8;
    color: #1a4a96;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    background: #f4f8ff;
    border-radius: 8px;
}

.cover em {
    margin-top: auto;
    font-style: normal;
    color: #1a4a96;
    font-size: 13px;
    font-weight: 700;
    border-top: 1px solid #e6eef8;
    padding-top: 10px;
}

.home-note {
    margin-top: 22px;
    color: #fff;
    font-size: 15px;
    text-align: center;
    max-width: 680px;
    line-height: 1.8;
    text-shadow: 0 1px 8px rgba(0, 0, 0, .45);
}

.toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    color: #fff;
    background: rgba(42, 24, 12, .9);
}

.toolbar h2 {
    margin: 0 8px 0 0;
    font-size: 18px;
    font-weight: 800;
}

.toolbar .hint {
    margin-right: auto;
    font-size: 12px;
    opacity: .88;
    line-height: 1.5;
}

.toolbar button,
.toolbar select {
    background: #fff;
    color: #1a4a96;
    border: 0;
    border-radius: 6px;
    padding: 7px 12px;
    font-weight: 700;
    font-size: 14px;
}

.toolbar button:disabled {
    opacity: .45;
    cursor: default;
}

.toolbar button.primary { background: #1a4a96; color: #fff; }

.report-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.report-tabs button {
    border: 1px solid #245fbe;
    background: #fff;
    color: #1a4a96;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 800;
}

.report-tabs button.on {
    background: #1a4a96;
    color: #fff;
}

.report-sum {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}

.report-sum span {
    background: #f4f8ff;
    border: 1px solid #d5e3f8;
    border-radius: 8px;
    padding: 6px 10px;
    color: #1a4a96;
    font-weight: 700;
}

.report-block { margin-top: 16px; }

.report-block h3 {
    margin: 0 0 8px;
    color: #1a4a96;
    font-size: 18px;
}

.sheet .title { text-align: center; color: #1a4a96; font-size: 26px; margin: 0 0 12px; }

.report-block .badge { margin-right: 8px; }

.inv-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 14px;
    color: #1a4a96;
    font-weight: 800;
}
.inv-filter .datebox {
    background: #fff;
    border: 1px solid #c5d4ea;
    border-radius: 8px;
    padding: 4px 8px;
}
.inv-filter button {
    border: 1px solid #245fbe;
    background: #fff;
    color: #1a4a96;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 800;
}

.login-card {
    width: min(380px, 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, .96);
    color: #1a4a96;
    border-radius: 16px;
    padding: 22px 22px 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.login-card strong {
    font-size: 22px;
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 800;
}

.login-card input {
    border: 1px solid #c5d4ea;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 18px;
    color: #16325c;
}

.login-card button.primary {
    background: #1a4a96;
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 10px;
    font-weight: 800;
    font-size: 16px;
}

.login-card button[data-action="password-close"] {
    background: #eef3f8;
    color: #1a4a96;
    border: 0;
    border-radius: 8px;
    padding: 8px;
    font-weight: 700;
}

.login-error {
    margin: 0;
    min-height: 1.2em;
    color: #c62828;
    font-weight: 700;
}

.home-tools {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.home-tools button {
    background: rgba(255, 255, 255, .92);
    color: #1a4a96;
    border: 0;
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 800;
}

.pass-mask {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(16, 12, 8, .55);
}

.settings-card {
    width: min(480px, 100%);
    max-height: min(860px, calc(100vh - 40px));
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, .98);
    color: #1a4a96;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.settings-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-head strong {
    font-size: 22px;
}

.settings-head button,
.settings-card > button {
    background: #eef3f8;
    color: #1a4a96;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 800;
}

.settings-block {
    border: 1px solid #d5e3f8;
    border-radius: 12px;
    padding: 12px;
    background: #f7faff;
}

.settings-block h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.settings-block p,
.settings-card .warn {
    margin: 0;
    color: #5d7194;
    font-size: 13px;
    line-height: 1.7;
    font-weight: 700;
}

.settings-card .warn { color: #c62828; }

.settings-card form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.settings-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 800;
}

.settings-card input {
    width: 100%;
    border: 1px solid #c5d4ea;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 16px;
    color: #16325c;
    background: #fff;
}

.settings-card button.primary,
.settings-card button.danger {
    border: 0;
    border-radius: 8px;
    padding: 9px 12px;
    font-weight: 800;
    font-size: 15px;
}

.settings-card button.primary { background: #1a4a96; color: #fff; }
.settings-card button.danger { background: #c62828; color: #fff; }
.settings-card .login-error:empty { display: none; }
.logo-preview {
    display: block;
    max-width: 160px;
    max-height: 90px;
    object-fit: contain;
    background: #111;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
}
.sum-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 8px;
}
.sum-check {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    margin: 0;
    font-size: 14px;
}
.sum-check input {
    width: 16px !important;
    height: 16px;
    padding: 0 !important;
    accent-color: #1a4a96;
}

.ledger td.ref-cell {
    overflow: visible;
    vertical-align: middle;
    height: auto;
    min-height: 32px;
}

.ref-pick {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    min-width: 0;
    padding: 0 2px;
    box-sizing: border-box;
}

.ref-pick button {
    flex: 0 0 auto;
    min-width: 0;
    width: auto;
    border: 1px solid #c5d7f2;
    background: #f5f9ff;
    color: #1a4a96;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 5px;
    line-height: 1.3;
    white-space: nowrap;
}

.ref-pick button:disabled { opacity: .4; }

.ref-val {
    flex: 0 0 auto;
    padding: 0 2px;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: center;
    direction: ltr;
}

.ref-val:empty {
    display: none;
}

.ref-menu {
    position: fixed;
    z-index: 40;
    max-height: 320px;
    overflow: auto;
    background: #fff;
    border: 1px solid #3a78d8;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .22);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 220px;
}

.ref-menu.pages {
    display: grid;
    grid-template-columns: repeat(5, minmax(40px, 1fr));
    min-width: 240px;
}

.ref-menu button {
    border: 1px solid #d5e3f8;
    background: #f7faff;
    color: #1a4a96;
    border-radius: 6px;
    padding: 7px 8px;
    font-weight: 800;
    font-size: 13px;
}

.ref-menu button.on { background: #1a4a96; color: #fff; }

.ref-wait {
    margin: 0;
    padding: 8px;
    grid-column: 1 / -1;
    color: #5d7194;
    font-weight: 800;
    font-size: 13px;
}

.cash-card {
    width: min(760px, 100%);
    max-height: min(860px, calc(100vh - 40px));
}

.cash-sums {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.cash-line.cash-now strong { color: #1a4a96; }
.cash-in { color: #0b6b32; }
.cash-out { color: #a32020; }

.cash-list {
    overflow: auto;
    border: 1px solid #d5e3f8;
    border-radius: 12px;
}

.cash-list .ledger { min-width: 0; }
.cash-list .ledger td.details { text-align: right; padding: 4px 8px; font-size: 13px; }

.cash-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 4px;
    border-top: 1px solid #d5e3f8;
    font-weight: 800;
    font-size: 16px;
}

.cash-line:first-of-type { margin-top: 8px; }

.cash-line strong {
    font-size: 26px;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}

.save-state {
    min-width: 64px;
    font-size: 12px;
    color: #b7f0c8;
}

#app:has(.workspace) {
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace {
    display: flex;
    align-items: stretch;
    gap: 14px;
    padding: 14px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    flex: none;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    background: rgba(255, 255, 255, .96);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .28);
}

.sidebar h3 {
    margin: 0 0 8px;
    color: #1a4a96;
    font-size: 16px;
}

.filters { display: flex; gap: 6px; margin-bottom: 8px; }

.filters button {
    flex: 1;
    border: 1px solid #c5d7f5;
    background: #fff;
    color: #1a4a96;
    border-radius: 6px;
    padding: 5px 4px;
    font-weight: 700;
    font-size: 13px;
}

.filters button.on { background: #1a4a96; color: #fff; border-color: #1a4a96; }

.sidebar form { display: grid; gap: 6px; margin-bottom: 10px; }

.sidebar input[type="search"],
.sidebar input[type="text"],
.sidebar form input {
    width: 100%;
    border: 1px solid #c5d7f5;
    border-radius: 6px;
    padding: 8px;
    font-size: 14px;
}

.sidebar form button,
.add-row { display: flex; gap: 6px; }

.sidebar form button {
    border: 0;
    border-radius: 6px;
    padding: 8px;
    font-weight: 700;
    color: #fff;
    background: #1a4a96;
}

.sidebar form button.bedeh { background: #a32020; }

.acct {
    position: relative;
    border: 1px solid #e1eaf8;
    border-radius: 6px;
    padding: 8px 8px 8px 46px;
    margin-bottom: 6px;
    cursor: pointer;
}

.acct.active {
    background: #eaf2ff;
    border-color: #8eb4ef;
    box-shadow: inset -3px 0 0 #1a4a96;
}

.acct .top { display: flex; gap: 6px; align-items: center; }

.acct .nm { font-weight: 800; color: #16325c; }

.acct .mini { color: #5d7194; font-size: 12px; margin-top: 3px; }

.badge {
    font-size: 11px;
    font-weight: 800;
    border-radius: 99px;
    padding: 1px 7px;
}

.badge.talep { background: #e5f6ea; color: #0d7a3f; }
.badge.bedeh { background: #fdecec; color: #a32020; }

.acct .del {
    position: absolute;
    left: 6px;
    top: 8px;
    border: 0;
    background: transparent;
    color: #a32020;
    font-size: 12px;
    font-weight: 700;
}

.empty-list { color: #5d7194; font-size: 13px; padding: 8px 2px; }

#acct-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.stage {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.sheet {
    background: #fff;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 12px 12px 8px;
    box-shadow: 0 18px 46px rgba(0, 0, 0, .34);
    overflow-x: hidden;
}

.sheet.wide { min-width: 0; width: 100%; max-width: 100%; }

.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.table-wrap .ledger,
.sheet.wide .table-wrap .ledger {
    width: 100%;
    min-width: 0;
    height: auto;
}

.goods-page .page-mark input {
    font-size: 22px;
    width: 52px;
}

.head-line {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.sidebar input[type="search"] { margin: 8px 0; }

.title {
    margin: 0;
    text-align: center;
    color: #1a4a96;
    font-size: 30px;
    font-weight: 800;
    line-height: 1.2;
}

.specs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    justify-content: center;
    color: #1a4a96;
    font-weight: 700;
}

.paren { color: #1a4a96; font-weight: 800; }

.line-input {
    border: 0;
    border-bottom: 1px dotted #2f6ed6;
    background: transparent;
    min-width: 120px;
    padding: 2px 6px;
    font-size: 16px;
    font-weight: 700;
    color: #142033;
    text-align: center;
}

.line-input.wide { min-width: 220px; }

.line-input:focus { outline: none; background: #fff8dc; }

.page-mark {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-self: start;
    color: #1a4a96;
    font-weight: 800;
    font-size: 16px;
    white-space: nowrap;
}

.book-tag {
    background: #1a4a96;
    color: #fff;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
}

.page-mark.ltr-num { direction: ltr; }

.page-mark input {
    width: 72px;
    border: 0;
    background: transparent;
    color: #e10600;
    font-size: 28px;
    font-weight: 800;
    text-align: center;
    font-family: Vazirmatn, Tahoma, sans-serif;
}

.page-mark input:focus { outline: none; background: #fff4f4; }

.carried {
    color: #1a4a96;
    font-weight: 700;
    font-size: 13px;
    margin: 0 0 6px;
    min-height: 18px;
}

table.ledger {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #245fbe;
    table-layout: fixed;
}

.ledger th,
.ledger td {
    border: 1px solid #3a78d8;
    min-height: 32px;
    height: 32px;
    padding: 0 2px;
    text-align: center;
    color: #1a4a96;
    font-weight: 700;
    font-size: 13px;
    overflow-x: hidden;
    overflow-y: visible;
}

.ledger th {
    background: #f5f9ff;
    padding: 4px 2px;
    line-height: 1.35;
    height: auto;
    vertical-align: middle;
}

.goods-top {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 8px;
    color: #1a4a96;
}

.goods-brand {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.goods-spec {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    min-width: 0;
    padding-bottom: 2px;
}

.spec-label {
    font-weight: 800;
    white-space: nowrap;
}

.spec-field {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    font-weight: 800;
    min-width: 80px;
}

.spec-field .line-input {
    flex: 1;
    min-width: 0;
    width: auto;
}

.goods-page {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    font-weight: 800;
    white-space: nowrap;
}

.amount-head {
    font-size: 13px;
}

.ledger td:focus-within { background-color: #fff8dc; }

.ledger input {
    width: 100%;
    height: 30px;
    border: 0;
    background: transparent;
    color: #142033;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
    padding: 0 4px;
}

.ledger input:focus { outline: none; }

.ledger input[data-num],
.datebox input { direction: ltr; }

.ledger td.write-r input {
    text-align: right;
    direction: rtl;
}

.ledger td.write-l input {
    text-align: left;
    direction: ltr;
}

.details-wrap {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0 2px;
}

.ledger td.details {
    height: auto;
    min-height: 32px;
    min-width: 0;
    overflow: visible;
    vertical-align: middle;
}

.ledger textarea.grow {
    display: block;
    flex: 1;
    min-width: 0;
    width: auto;
    min-height: 30px;
    height: 30px;
    border: 0;
    resize: none;
    overflow: hidden;
    background: transparent;
    color: #142033;
    font: inherit;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.45;
    text-align: right;
    padding: 4px 4px;
}

.datebox {
    display: flex;
    align-items: center;
    justify-content: center;
    direction: rtl;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0 2px;
    color: #8eb6ee;
    font-weight: 700;
}

.ledger .datebox input {
    width: auto;
    flex: 1 1 0;
    min-width: 0;
    padding: 0;
    font-size: 13px;
}
.ledger .datebox input.y { flex: 1.7 1 0; }
.datebox span { flex: none; }

.date-static {
    color: #8eb6ee;
    letter-spacing: 6px;
    font-weight: 600;
}

td.money {
    background-image: repeating-linear-gradient(
        to left,
        transparent 0,
        transparent 16px,
        rgba(47, 110, 214, .25) 16px,
        rgba(47, 110, 214, .25) 17px
    );
}

.kind { display: flex; gap: 2px; flex: none; }

.kind button {
    border: 1px solid transparent;
    background: transparent;
    color: #8aa4c8;
    font-size: 11px;
    font-weight: 800;
    border-radius: 3px;
    padding: 2px 4px;
}

.kind button.on.in { color: #0d7a3f; background: #e7f6ec; border-color: #b7e0c2; }
.kind button.on.out { color: #a32020; background: #fdecec; border-color: #f3c0c0; }

tr.need-kind .kind button { border-color: #e0a0a0; color: #a32020; }

tr.in-row td.money input { color: #0b6b32; }
tr.out-row td.money input { color: #a32020; }

input.calc { color: #1a4a96; }

.num {
    font-variant-numeric: tabular-nums;
    padding: 0 3px;
    white-space: nowrap;
    font-size: 12px;
}

.neg { color: #c62828; }

tr.sum td { background: #f7fbff; }
tr.sum.balance td { background: #e7f0ff; }
tr.sum .label { text-align: right; padding-right: 10px; }

tr.carry td { background: #f7fbff; height: 34px; }
tr.carry .label { text-align: right; padding-right: 10px; font-size: 14px; }

.row-x {
    border: 0;
    background: transparent;
    color: #c0392b;
    font-size: 16px;
    line-height: 1;
    opacity: 0;
    padding: 0 2px;
}

tr:hover .row-x { opacity: 1; }

.blank-sheet {
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a4a96;
    font-size: 20px;
    font-weight: 800;
}

.toast {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: #143e22;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: .2s ease;
    z-index: 40;
    font-weight: 700;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: #8d1d1d; }

@media (max-width: 1100px) {
    .toolbar { gap: 6px; }
    .toolbar button,
    .toolbar select { padding: 6px 9px; font-size: 13px; }
    .goods-brand { font-size: 22px; }
    .title { font-size: 24px; }
    .ref-pick button { font-size: 10px; padding: 2px 4px; }
    .ledger th, .ledger td { font-size: 12px; }
}

@media (max-width: 980px) {
    .covers { grid-template-columns: 1fr; width: min(360px, 100%); }
    .brand h1 { font-size: 34px; }
    .workspace { flex-direction: column; padding: 10px; }
    .sidebar { width: 100%; max-height: 36vh; }
    .toolbar .hint { display: none; }
    .toolbar h2 { font-size: 15px; }
    .cash-sums { grid-template-columns: 1fr; }
    .goods-top { flex-wrap: wrap; gap: 8px; }
    .page-mark input { width: 52px; font-size: 22px; }
    .head-line { flex-wrap: wrap; }
}

@media (max-width: 640px) {
    .home { padding: 24px 12px; }
    .brand h1 { font-size: 28px; }
    .cover strong { font-size: 22px; }
    .toolbar { padding: 8px; }
    .toolbar .now { display: none; }
    .settings-card,
    .cash-card { width: 100%; }
    .table-wrap .ledger,
    .sheet.wide .table-wrap .ledger { min-width: 0; }
}

.invoice-mask {
    align-items: stretch;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

.invoice-box {
    width: min(210mm, 100%);
    max-height: calc(100vh - 20px);
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    color: #111;
    border-radius: 8px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .32);
}

.invoice-actions {
    flex: none;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 8px 10px;
    background: #111;
    color: #f3d37a;
}

.invoice-actions strong { margin-left: auto; }
.invoice-actions select {
    max-width: min(220px, 42vw);
    min-width: 0;
    border: 0;
    border-radius: 6px;
    padding: 6px 8px;
}
.invoice-actions button {
    border: 0;
    border-radius: 6px;
    padding: 6px 10px;
    font-weight: 800;
    background: #fff;
    color: #1a4a96;
}
.invoice-actions button.primary { background: #c9a227; color: #1a1204; }
.invoice-actions button.danger { background: #c62828; color: #fff; }

.invoice-stage {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: #fff;
}

.invoice-fit {
    width: 100%;
    height: auto;
    position: static;
}

.invoice-sheet {
    position: static;
    width: 100%;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: visible;
    transform: none;
    box-shadow: none;
    font-size: 3.1mm;
}

.inv-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 4mm;
    align-items: center;
    background: #111;
    color: #fff;
    padding: 6mm 5mm 7mm;
    position: relative;
    flex: none;
}
.inv-head::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 2mm;
    background: linear-gradient(90deg, #8a6a1a, #e0b44a, #8a6a1a);
}

.inv-brand, .inv-en, .inv-flags { min-width: 0; }
.inv-brand { text-align: center; }
.inv-brand h1 { margin: 0; font-size: 9.4mm; color: #f3d37a; line-height: 1.1; }
.inv-brand p { margin: 1.2mm 0 0; font-size: 2.8mm; font-weight: 700; }
.inv-brand strong { display: block; margin-top: 1.2mm; color: #f3d37a; letter-spacing: .08em; font-size: 3.6mm; }
.inv-brand span { display: block; margin-top: .8mm; font-weight: 800; font-size: 3.8mm; }
.inv-en {
    text-align: left;
    font-weight: 800;
    letter-spacing: .04em;
    direction: ltr;
    font-size: 3.8mm;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    align-self: stretch;
    gap: 1.4mm;
}
.inv-en small { display: block; font-size: 2.6mm; font-weight: 700; opacity: .85; }
.inv-logo {
    display: block;
    max-width: 42mm;
    max-height: 32mm;
    object-fit: contain;
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0 0 1.2mm;
}
.inv-flags { display: flex; flex-direction: column; gap: 1.8mm; font-size: 3.1mm; }

.inv-check {
    display: grid;
    grid-template-columns: 3.4mm minmax(0, 1fr);
    align-items: start;
    gap: 1.4mm;
    font-weight: 700;
    min-width: 0;
    max-width: 100%;
    text-align: right;
}
.inv-check input { width: 3.4mm; height: 3.4mm; accent-color: #c9a227; margin-top: .4mm; }

.inv-books {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2mm 4mm;
    border: .35mm solid #111;
    border-bottom: 0;
    padding: 3.4mm 3mm 2.4mm;
    flex: none;
    background: #fff;
}
.inv-books .inv-check {
    display: grid;
    grid-template-columns: auto minmax(8mm, 1fr);
    padding: 0;
    border: 0;
    font-size: 2.8mm;
    align-items: end;
    gap: 1mm;
}
.inv-books .inv-check label {
    display: inline-flex;
    align-items: center;
    gap: 1.2mm;
    white-space: nowrap;
    margin: 0;
}
.inv-books .inv-check::after { content: none; }
.inv-books .inv-flag-note {
    width: 100%;
    min-width: 0;
    border: 0;
    border-bottom: .35mm dotted #333;
    background: transparent;
    padding: .2mm .4mm;
    font-weight: 700;
    font-size: 2.8mm;
}

.inv-meta {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, .7fr);
    gap: 2mm 4mm;
    border: .35mm solid #111;
    border-bottom: 0;
    padding: 2mm 3mm 2.4mm;
    flex: none;
    background: #fff;
}
.inv-meta label {
    display: flex;
    align-items: center;
    gap: 1.5mm;
    font-weight: 800;
    padding: 0;
    border: 0;
    min-height: 7mm;
    min-width: 0;
    font-size: 3mm;
}
.inv-meta input {
    flex: 1;
    min-width: 0;
    border: 0;
    border-bottom: .35mm dotted #333;
    background: transparent;
    padding: .4mm 1mm;
    font-weight: 700;
}
.inv-meta [data-inv="invoice_no"] {
    color: #c62828;
    font-size: 4.2mm;
    font-weight: 800;
}

.inv-grid {
    flex: none;
    display: block;
}

.inv-table,
.inv-pay-table,
.inv-xfer,
.inv-notes {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
    empty-cells: show;
}
.inv-table {
    height: auto;
}
.inv-table th, .inv-table td,
.inv-pay-table th, .inv-pay-table td,
.inv-xfer td {
    border: .4mm solid #111;
    padding: 0;
    text-align: center;
    background: #fff;
    vertical-align: middle;
}
.inv-table th, .inv-pay-table th {
    background: #fff;
    font-size: 2.8mm;
    font-weight: 800;
    height: 7.5mm;
}
.inv-table thead th {
    background: linear-gradient(#3b2e12, #161208);
    color: #f3d37a;
    border-color: #111;
    font-size: 2.9mm;
    height: 8mm;
    text-shadow: 0 1px 0 #000;
}
.inv-table thead th.inv-h-no {
    background: #14100a;
    color: #f6e7a8;
}
.inv-table .c-no { width: 7%; }
.inv-table .c-details { width: 14%; }
.inv-table .c-d, .inv-table .c-form, .inv-table .c-sn, .inv-table .c-sc, .inv-table .c-right, .inv-table .c-left { width: 5.5%; }
.inv-table .c-model, .inv-table .c-qty, .inv-table .c-price, .inv-table .c-usd, .inv-table .c-afn { width: 6.5%; }
.inv-table .c-amount { width: 8%; }
.inv-table th { padding: 0 .6mm; overflow: hidden; white-space: nowrap; }
.inv-table tbody td { height: 9mm; }
.inv-table input,
.inv-pay-table input:not([type="checkbox"]),
.inv-xfer input:not([type="checkbox"]) {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    text-align: center;
    font-weight: 700;
    padding: .8mm .6mm;
    min-width: 0;
    font-size: 3mm;
}
.inv-table .inv-no {
    font-weight: 800;
    background: linear-gradient(#4a3a16, #1c160a);
    color: #ffe38a;
    font-size: 3.6mm;
    padding: 0;
    text-align: center;
}
.inv-table .inv-details {
    text-align: right;
    padding: 0 1.2mm;
    background: #fff;
    white-space: nowrap;
}
.inv-table .inv-door {
    display: inline;
    font-weight: 800;
    font-size: 2.7mm;
    color: #111;
    margin-left: 1mm;
}
.inv-table .inv-details input {
    width: 70%;
    display: inline-block;
    vertical-align: middle;
}
.inv-table tfoot td { background: #fff; font-weight: 800; height: 8mm; }
.inv-table tfoot .inv-no { background: linear-gradient(#4a3a16, #1c160a); }
.inv-table .inv-sum-label {
    text-align: right;
    padding: 0 2mm;
    font-size: 2.8mm;
}

.inv-pay-table { margin: 0; flex: none; table-layout: fixed; }
.inv-pay-table .c-pay-date { width: 22%; }
.inv-pay-table .c-pay-got { width: 28%; }
.inv-pay-table .c-pay-left { width: 32%; }
.inv-pay-table .c-pay-seal { width: 18%; }
.inv-pay-table th {
    font-size: 4.2mm;
    height: 13mm;
    background: #111;
    color: #f3d37a;
    font-weight: 800;
}
.inv-pay-table td,
.inv-xfer td {
    display: table-cell;
    height: 8.5mm;
    background: #fff;
    padding: 0 2mm;
    font-weight: 800;
    font-size: 2.8mm;
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}
.inv-pay-table .inv-date input {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: center;
    font-weight: 700;
}
.inv-pay-table .inv-lab { text-align: right; padding-right: 2mm; }
.inv-pay-table .inv-closed {
    text-align: right;
}
.inv-pay-table td input:not([type="checkbox"]) {
    width: 55%;
    border: 0;
    border-bottom: .35mm dotted #333;
    background: transparent;
    font-weight: 700;
    height: auto;
    min-height: 5mm;
    text-align: right;
    vertical-align: middle;
}
.inv-seal {
    font-weight: 800;
    font-size: 4.2mm;
    text-align: center !important;
    white-space: normal !important;
}

.inv-xfer { flex: none; table-layout: fixed; }
.inv-xfer td { font-size: 2.3mm; padding: 1mm 1.4mm; }
.inv-xfer td input:not([type="checkbox"]) {
    width: 18mm;
    border: 0;
    border-bottom: .35mm dotted #333;
    background: transparent;
    font-weight: 700;
    height: auto;
    min-height: 4.5mm;
    vertical-align: middle;
}
.inv-xfer input[type="checkbox"] {
    width: 3.4mm;
    height: 3.4mm;
    accent-color: #c62828;
    vertical-align: middle;
}
.inv-xfer .inv-check { display: inline-grid; grid-template-columns: 3.4mm auto; align-items: center; gap: 1mm; font-size: 2.3mm; }
.inv-xfer .inv-red,
.inv-xfer .inv-red .inv-check { color: #c62828; }

.inv-notes {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
    empty-cells: show;
    flex: none;
    background: #fff;
}
.inv-notes .c-sign { width: 34mm; }
.inv-notes td {
    border: .4mm solid #111;
    background: #fff;
    vertical-align: top;
}
.inv-notes ul {
    margin: 0;
    padding: 2.4mm 6mm 2.4mm 2mm;
    line-height: 1.7;
    font-weight: 700;
    list-style: none;
    font-size: 2.6mm;
}
.inv-notes li { position: relative; padding-right: 5mm; }
.inv-notes li::before {
    content: "✓";
    position: absolute;
    right: 0;
    color: #c62828;
    font-size: 3.2mm;
    font-weight: 800;
}
.inv-sign {
    width: 34mm;
    text-align: center;
    font-weight: 800;
    padding: 4mm 1mm 3mm;
    font-size: 4mm;
    background: #fff;
    vertical-align: top;
}

.inv-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55mm;
    text-align: center;
    background: #111;
    color: #f3d37a;
    padding: 3.2mm 3mm 3.6mm;
    font-weight: 800;
    position: relative;
    flex: none;
    font-size: 2.55mm;
    line-height: 1.4;
}
.inv-foot span { display: block; }
.inv-foot::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 1.4mm;
    background: linear-gradient(90deg, #8a6a1a, #e0b44a, #8a6a1a);
}

body.invoice-print .invoice-actions { display: none !important; }
body.invoice-print .pass-mask.invoice-mask {
    display: block !important;
    position: static;
    inset: auto;
    padding: 0;
    background: none;
    overflow: hidden;
    width: 210mm;
    height: 297mm;
    max-height: 297mm;
}
body.invoice-print .invoice-box,
body.invoice-print .invoice-stage,
body.invoice-print .invoice-fit,
body.invoice-print .invoice-sheet {
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    overflow: hidden !important;
    background: #fff;
    padding: 0;
    margin: 0;
    box-shadow: none !important;
    border-radius: 0;
    display: flex !important;
    flex-direction: column !important;
    position: static;
}
body.invoice-print .inv-head,
body.invoice-print .inv-books,
body.invoice-print .inv-meta,
body.invoice-print .inv-grid,
body.invoice-print .inv-xfer,
body.invoice-print .inv-notes { flex: none; }
body.invoice-print .inv-head {
    min-height: 50mm;
    padding: 6mm 5mm 7mm;
    gap: 4mm;
}
body.invoice-print .inv-brand h1 { font-size: 9.2mm; }
body.invoice-print .inv-logo { max-width: 38mm; max-height: 28mm; background: none; border: 0; padding: 0; }
body.invoice-print .inv-grid { display: block; }
body.invoice-print .inv-table,
body.invoice-print .inv-pay-table,
body.invoice-print .inv-notes {
    width: 100%;
    height: auto;
    flex: none;
}
body.invoice-print .inv-foot {
    flex: none;
    min-height: 0;
    padding: 3.2mm 3mm 3.6mm;
    font-size: 2.45mm;
    gap: 0.5mm;
}

@media print {
    body { background: #fff !important; }
    #app:has(.workspace) { height: auto; max-height: none; display: block; overflow: visible; }
    .toolbar, .sidebar, .toast, .home, .row-x, .pass-mask, .report-tabs { display: none !important; }
    .inv-filter button, [data-action="invoice-open"], .no-print { display: none !important; }
    .workspace { display: block; padding: 0; overflow: visible; }
    .stage { overflow: visible; }
    .sheet { box-shadow: none; min-width: 0; }
    .ref-pick button { display: none; }
    .kind button:not(.on) { display: none; }
    .kind button.on { border: 0; background: transparent !important; padding: 0; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    html, body, #app {
        width: 210mm;
        height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: #fff !important;
    }

    body.invoice-print .toolbar,
    body.invoice-print .workspace,
    body.invoice-print .home,
    body.invoice-print .toast,
    body.invoice-print #app > :not(.invoice-mask) { display: none !important; }
    body.invoice-print .pass-mask.invoice-mask {
        display: block !important;
        position: static;
        inset: auto;
        padding: 0;
        background: none;
        overflow: hidden;
        width: 210mm;
        height: 297mm;
    }
    body.invoice-print .invoice-box,
    body.invoice-print .invoice-stage,
    body.invoice-print .invoice-fit {
        width: 210mm;
        height: 297mm;
        max-height: 297mm;
        overflow: hidden;
        background: #fff;
        padding: 0;
        margin: 0;
        box-shadow: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        position: static;
    }
    body.invoice-print .invoice-fit { display: flex; flex-direction: column; height: 297mm; }
    body.invoice-print .invoice-sheet {
        position: static;
        transform: none;
        width: 210mm;
        height: 297mm;
        max-height: 297mm;
        overflow: hidden;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
    }
    body.invoice-print .invoice-actions { display: none !important; }
    body.invoice-print .inv-head,
    body.invoice-print .inv-books,
    body.invoice-print .inv-meta,
    body.invoice-print .inv-grid,
    body.invoice-print .inv-xfer,
    body.invoice-print .inv-notes { flex: none; }
    body.invoice-print .inv-head {
        min-height: 50mm;
        padding: 6mm 5mm 7mm;
        gap: 4mm;
    }
    body.invoice-print .inv-brand h1 { font-size: 9.2mm; }
    body.invoice-print .inv-logo { max-width: 38mm; max-height: 28mm; background: none; border: 0; padding: 0; }
    body.invoice-print .inv-grid { display: block; }
    body.invoice-print .inv-notes {
        flex: none;
        height: auto;
        width: 100%;
    }
    body.invoice-print .inv-foot {
        flex: none;
        min-height: 0;
        padding: 3.2mm 3mm 3.6mm;
        font-size: 2.45mm;
        gap: 0.5mm;
    }
    body.invoice-print .inv-table,
    body.invoice-print .inv-pay-table,
    body.invoice-print .inv-notes,
    body.invoice-print .inv-xfer {
        border-collapse: collapse !important;
        width: 100%;
        height: auto;
        flex: none;
        margin: 0;
    }
    body.invoice-print .inv-table th,
    body.invoice-print .inv-table td,
    body.invoice-print .inv-pay-table th,
    body.invoice-print .inv-pay-table td,
    body.invoice-print .inv-xfer td,
    body.invoice-print .inv-notes td {
        display: table-cell !important;
        border: .4mm solid #111 !important;
        box-sizing: border-box;
    }
    body.invoice-print .inv-table thead th { height: 8mm; }
    body.invoice-print .inv-pay-table thead th { height: 13mm; }
    body.invoice-print .inv-table tbody td,
    body.invoice-print .inv-table tfoot td {
        height: 10.2mm;
    }
    body.invoice-print .inv-pay-table td {
        height: 12mm;
    }
    body.invoice-print .inv-details { display: table-cell !important; }
    body.invoice-print .inv-notes ul { padding: 2.4mm 5mm 2.4mm 1.5mm; font-size: 2.5mm; line-height: 1.55; }
    body.invoice-print .inv-sign { padding: 4mm 1mm 3mm; }
    body.invoice-print .inv-xfer td { height: 7.5mm; }
    body.invoice-print .invoice-sheet,
    body.invoice-print .inv-head,
    body.invoice-print .inv-notes,
    body.invoice-print .inv-foot { page-break-inside: avoid; break-inside: avoid; }
}

@page { size: A4 portrait; margin: 0; }
