:root {
    --primary: #1565a8;
    --primary-dark: #0f4c81;
    --primary-soft: #e8f4fd;
    --accent: #f59e0b;
    --success: #22c55e;
    --danger: #ef4444;
    --bg: #e8eef5;
    --bg-from: #f5f7fa;
    --bg-to: #e8eef5;
    --card: #fff;
    --text: #1a2b3c;
    --muted: #64748b;
    --border: #e2e8f0;
    --surface: #f8fafc;
    --input-bg: #ffffff;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(15, 39, 68, .08);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --sheet-line: #1e293b;
    --sheet-ink: #0f172a;
    --sheet-muted: #64748b;
    --sheet-placeholder: #94a3b8;
    --sheet-accent: #2563eb;
    --sheet-accent-soft: #dbeafe;
    --sheet-highlight: #fff59d;
    --sheet-head: #ffe082;
    --sheet-panel: #f8fafc;
    --sheet-paper: #ffffff;
    --sheet-head-ink: #0f172a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    padding-bottom: calc(72px + var(--safe-bottom));
}

.hidden { display: none !important; }

.splash {
    min-height: 100vh;
    display: grid;
    place-items: center;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -.01em;
    opacity: .88;
}

.screen { display: none; min-height: calc(100vh - 72px); }
.screen.active { display: block; }

.app-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: .55rem .85rem .45rem;
    border-radius: 0 0 16px 16px;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 40;
    transition: transform .15s ease;
    --pull: 0;
}

.app-header h1 { font-size: 1.15rem; margin-bottom: .25rem; }
.app-header p { font-size: .85rem; opacity: .85; }

.project-topbar {
    padding-bottom: .4rem;
    user-select: none;
    touch-action: pan-y;
}
.project-topbar.pulling {
    transition: none;
}
.project-header-main {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.project-header-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .25rem;
    flex-shrink: 0;
}
.header-icon-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.16);
    color: #fff;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.header-icon-btn.dark {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 1.4rem;
}
.header-icon-btn:active { transform: scale(.96); }
.header-pdf-btn {
    appearance: none;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.2);
    color: #fff;
    font: inherit;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.15;
    padding: .4rem .55rem;
    cursor: pointer;
    white-space: nowrap;
    max-width: 7.5rem;
}
.header-pdf-btn:active { transform: scale(.96); filter: brightness(.95); }

.project-header-title { flex: 1; min-width: 0; }
.project-switcher-trigger {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: right;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: .4rem;
    position: relative;
    min-height: 34px;
}
.project-switcher-name {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 1.3rem;
    min-width: 0;
}
.project-switcher-meta {
    font-size: .75rem;
    opacity: .82;
    white-space: nowrap;
    flex-shrink: 0;
}
.project-switcher-chevron {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: .95rem;
    opacity: .9;
    transition: transform .2s ease;
}
.project-sheet.open ~ .noop,
.project-topbar.is-open .project-switcher-chevron {
    transform: translateY(-50%) rotate(180deg);
}
.pull-handle {
    display: flex;
    justify-content: center;
    margin-top: .35rem;
}
.pull-handle span {
    width: calc(28px + (var(--pull) * 24px));
    height: 3px;
    border-radius: 99px;
    background: rgba(255,255,255,.45);
    transition: width .1s ease;
}

.project-sheet-backdrop,
.header-menu-backdrop,
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 120;
}
.project-sheet-backdrop.open,
.header-menu-backdrop.open,
.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.header-menu-backdrop { z-index: 130; background: transparent; }
.modal-backdrop {
    z-index: 150;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.project-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-height: min(72vh, 560px);
    background: var(--card);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 22px 22px;
    box-shadow: var(--shadow);
    transform: translateY(-105%);
    transition: transform .28s cubic-bezier(.2,.8,.2,1);
    z-index: 125;
    display: flex;
    flex-direction: column;
    padding: .35rem .85rem 1rem;
}
.project-sheet.open { transform: translateY(0); }
.project-sheet-handle {
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: var(--border);
    margin: .35rem auto .75rem;
}
.project-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
    padding: 0 .15rem;
}
.project-sheet-head strong {
    font-size: 1rem;
    color: var(--text);
}
.project-sheet-list {
    overflow: auto;
    display: grid;
    gap: .55rem;
    padding-bottom: .35rem;
}
.project-sheet-item {
    display: flex;
    align-items: center;
    gap: .85rem;
    width: 100%;
    text-align: right;
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
    color: var(--text);
    cursor: pointer;
}
.project-sheet-item.active {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.project-sheet-check {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.header-menu {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    min-width: 200px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255,255,255,.06);
    z-index: 140;
    padding: .4rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(.98);
    transition: .18s ease;
}
.header-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}
.header-menu-item {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: right;
    padding: .8rem .9rem;
    border-radius: 10px;
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: -.01em;
    color: var(--text);
    cursor: pointer;
}
.header-menu-item:hover,
.header-menu-item:focus-visible {
    background: var(--surface);
    outline: none;
}
.header-menu-item:active {
    background: var(--primary-soft);
}
.header-menu-item.danger {
    color: #f87171;
}

.inactive-projects-list {
    display: grid;
    gap: .65rem;
    max-height: min(52vh, 360px);
    overflow: auto;
    margin-bottom: .85rem;
}
.inactive-project-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.inactive-project-row .project-card-body {
    flex: 1;
    min-width: 0;
}
.inactive-project-row .project-card-body strong {
    display: block;
    margin-bottom: .15rem;
    color: var(--text);
}
.inactive-project-row .project-card-body span {
    font-size: .82rem;
    color: var(--muted);
}

.modal-card {
    width: min(100%, 420px);
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.15rem;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.modal-card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
}
.modal-actions {
    display: flex;
    gap: .55rem;
    justify-content: flex-start;
    margin-top: .35rem;
}
.modal-actions .btn { flex: 1; }

.color-swatch-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
}
.color-swatch {
    cursor: pointer;
    position: relative;
}
.color-swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.color-swatch span {
    display: block;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    box-shadow: inset 0 0 0 2px #fff;
    border: 2px solid transparent;
}
.color-swatch.selected span,
.color-swatch:has(input:checked) span {
    border-color: var(--primary-dark);
    box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--primary-dark);
}
.modal-sub {
    color: var(--muted);
    font-size: .88rem;
    margin: -.35rem 0 1rem;
}

.modal-card-wide {
    width: min(100%, 520px);
    max-height: min(88vh, 720px);
    overflow: auto;
}
.field-hint {
    margin-top: .35rem;
    font-size: .78rem;
    color: var(--muted);
}
.project-images-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .65rem;
    margin-bottom: 1rem;
}
@media (min-width: 420px) {
    .project-images-grid { grid-template-columns: repeat(3, 1fr); }
}
.project-image-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    display: flex;
    flex-direction: column;
}
.project-image-item img,
.project-image-thumb img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    background: #e2e8f0;
}
.project-image-item .btn {
    margin: .45rem;
}
.project-image-thumb {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.project-images-upload {
    border-top: 1px solid var(--border);
    padding-top: .85rem;
}
.dash-images-grid {
    margin-bottom: 0;
}

.page {
    padding: 1rem;
    padding-bottom: calc(1rem + 88px + var(--safe-bottom));
    max-width: 640px;
    margin: 0 auto;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h2 { font-size: 1rem; margin-bottom: .75rem; }

.field { margin-bottom: .85rem; }
.field label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .35rem;
}

input, select, textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: .7rem .9rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: var(--input-bg);
    color: var(--text);
}

textarea { min-height: 90px; resize: vertical; }

/* Hint text always right-aligned while field is empty */
input:placeholder-shown,
textarea:placeholder-shown {
    text-align: right !important;
}
input::placeholder,
textarea::placeholder {
    text-align: right;
    direction: rtl;
}

.jalali-date-input,
.time-picker-input {
    cursor: pointer;
    background: #f8fafc !important;
}
.jalali-date-input::placeholder,
.time-picker-input::placeholder { color: #94a3b8; }

input[type="number"] {
    direction: ltr;
    text-align: left;
    font-weight: 600;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 2.75rem;
    padding: .65rem 1.1rem;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-block { width: 100%; }
.btn-sm { min-height: 2.2rem; padding: .4rem .75rem; font-size: .85rem; }

.toolbar {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
}

@media (min-width: 480px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .span-full { grid-column: 1 / -1; }
}

.ops-page {
    padding-top: .5rem;
}

.ops-page #install-banner {
    display: none !important;
}

.ops-banner {
    background: transparent;
    color: var(--muted);
    text-align: center;
    font-weight: 600;
    font-size: .86rem;
    letter-spacing: -.01em;
    line-height: 1.3;
    padding: .35rem .5rem .65rem;
    border: 0;
    border-radius: 0;
    margin-bottom: .35rem;
    box-shadow: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ops-menu {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ops-group {
    border: 1.5px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: .75rem .65rem .85rem;
    box-shadow: none;
}

.ops-group-payments {
    border-color: #f1a8a8;
    background: #fff7f7;
}

.ops-group-purchases {
    border-color: #f0c97a;
    background: #fffbf0;
}

.ops-group-income {
    border-color: #86d4a5;
    background: #f4fdf7;
}

.ops-group-title {
    text-align: center;
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 .7rem;
    line-height: 1.4;
    letter-spacing: -.015em;
    position: relative;
}

.ops-group-title::after {
    content: '';
    display: block;
    width: 2.25rem;
    height: 2px;
    margin: .4rem auto 0;
    border-radius: 999px;
    background: var(--primary);
    opacity: .7;
}

.ops-list {
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.ops-list-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: .5rem;
    align-items: stretch;
    width: 100%;
}

.ops-list-row .ops-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch;
    gap: .3rem;
    direction: rtl !important;
    width: auto !important;
    min-width: 0;
}

.ops-list-row .ops-num {
    order: 0 !important;
    flex: none;
    width: 100%;
    height: auto;
    font-size: 1rem;
    padding: 0;
    justify-content: center;
}

.ops-list-row .ops-body {
    padding: .65rem .55rem;
    border-radius: 10px;
    border-width: 1px;
    box-shadow: none;
    min-height: 4.5rem;
}

.ops-list-row .ops-title {
    font-size: .86rem;
    margin-bottom: .12rem;
    line-height: 1.35;
}

.ops-list-row .ops-hint {
    font-size: .7rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ops-item {
    display: flex;
    align-items: stretch;
    gap: .7rem;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: right;
    direction: ltr;
    transition: transform .12s ease;
}

.ops-item-report .ops-body {
    background: color-mix(in srgb, #fef3c7 55%, #fff);
    border-color: #f59e0b;
}

.ops-item-report .ops-title {
    color: #92400e;
}

.ops-item-report .ops-num {
    color: #d97706;
}

.ops-num {
    flex: 0 0 2.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--primary);
    padding-top: .1rem;
    order: -1;
    opacity: .92;
}

.ops-body {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 10px;
    padding: .75rem .9rem;
    text-align: right;
    direction: rtl;
    box-shadow: none;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.ops-title {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: .25rem;
    line-height: 1.5;
    letter-spacing: -.01em;
}

.ops-hint {
    display: block;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text);
    opacity: .82;
    line-height: 1.65;
}

.ops-item:hover .ops-body {
    border-color: var(--primary);
}

.ops-item:active {
    transform: scale(.985);
}

.ops-item:active .ops-body,
.ops-item:focus-visible .ops-body {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    outline: none;
}

.entry-group { margin-bottom: 1.25rem; }
.entry-group-title {
    font-size: .8rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: .65rem;
}

.entry-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .65rem;
}

.entry-card {
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    padding: .95rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: right;
    width: 100%;
    font: inherit;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.entry-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 4px; height: 100%;
    background: var(--accent-color, var(--primary));
}

.entry-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.2rem;
    background: color-mix(in srgb, var(--accent-color, var(--primary)) 12%, white);
    flex-shrink: 0;
}

.entry-title { font-weight: 700; font-size: .95rem; margin-bottom: .15rem; }
.entry-hint { font-size: .78rem; color: var(--muted); line-height: 1.5; }

.project-card {
    display: block;
    width: 100%;
    text-align: right;
    padding: 1rem;
    margin-bottom: .65rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.project-card strong { display: block; margin-bottom: .2rem; }
.project-card span { font-size: .82rem; color: var(--muted); }

.tx-item {
    padding: .85rem 0;
    border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }
.tx-top { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.tx-type { font-weight: 700; font-size: .92rem; }
.tx-amount { font-weight: 700; direction: ltr; }
.tx-meta { font-size: .78rem; color: var(--muted); }
.tx-actions {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-top: .55rem;
    align-items: center;
}
.tx-item-active {
    background: #eff6ff;
    margin: 0 -.85rem;
    padding: .85rem;
    border-radius: 12px;
}
.tx-editing-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--primary);
}
.type-history {
    margin-top: 1rem;
}
.type-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}
.type-history-head h2 {
    margin: 0;
    font-size: 1rem;
}
.self-name-field {
    display: flex;
    gap: .5rem;
    align-items: stretch;
}
.self-name-field input { flex: 1; min-width: 0; }
.self-name-field .self-name-btn { flex-shrink: 0; white-space: nowrap; }
.name-suggest-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}
.sheet-select-row > .name-suggest-wrap {
    display: contents;
}
.sheet-select-row > .name-suggest-wrap > input {
    width: 100%;
    min-width: 0;
}
.name-suggest-wrap > input {
    width: 100%;
}
.name-suggest-menu {
    position: absolute;
    top: calc(100% + .2rem);
    left: 0;
    right: 0;
    z-index: 80;
    background: #fff;
    border: 1.5px solid var(--sheet-line);
    border-radius: .55rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .16);
    max-height: 220px;
    overflow: auto;
    padding: .25rem;
}
.name-suggest-item {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: right;
    font: inherit;
    font-weight: 600;
    color: var(--sheet-ink);
    padding: .55rem .65rem;
    border-radius: .4rem;
    cursor: pointer;
}
.name-suggest-item.is-active,
.name-suggest-item:hover {
    background: #e0f2fe;
    color: #075985;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
}

.stat {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .85rem;
}

.stat-label { font-size: .75rem; color: var(--muted); margin-bottom: .25rem; }
.stat-value { font-weight: 700; font-size: 1rem; direction: ltr; text-align: left; }

.item-card {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: .85rem;
    margin-bottom: .75rem;
    background: var(--surface);
}

.item-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .65rem;
}

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #fff;
    border-top: 1px solid var(--border);
    padding: .45rem .35rem calc(.45rem + var(--safe-bottom));
    z-index: 100;
    transition: transform .28s ease, opacity .28s ease;
    will-change: transform;
}

.bottom-nav.is-hidden {
    transform: translateY(110%);
    opacity: 0;
    pointer-events: none;
}

.bottom-nav-peek {
    position: fixed;
    left: 50%;
    bottom: calc(6px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 101;
    width: 48px;
    height: 6px;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 55%, #94a3b8);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.bottom-nav-peek.is-visible {
    opacity: .85;
    pointer-events: auto;
}

body.nav-collapsed {
    padding-bottom: calc(18px + var(--safe-bottom));
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .35rem;
    border: none;
    background: none;
    font: inherit;
    font-size: .68rem;
    color: var(--muted);
    cursor: pointer;
}

.nav-btn.active { color: var(--primary); font-weight: 700; }
.nav-btn .icon { font-size: 1.15rem; }

.form-sticky-head {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
}
.form-sticky-head .app-header {
    border-radius: 0;
    box-shadow: none;
}
.sheet-sticky .project-topbar.sheet-project-bar {
    background: color-mix(in srgb, var(--project-color, #86efac) 55%, #ffffff) !important;
    color: var(--sheet-ink) !important;
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
    padding: .4rem .75rem;
}
.sheet-sticky .sheet-project-bar .header-icon-btn {
    width: 34px;
    height: 34px;
    background: var(--sheet-paper);
    color: var(--sheet-ink) !important;
    border: 1.5px solid var(--sheet-line);
    border-radius: 4px;
    font-size: 1.15rem;
}
.sheet-sticky .sheet-project-bar .project-switcher-name {
    color: var(--sheet-ink) !important;
    font-size: 1.2rem;
    padding-left: 1.6rem;
}
.sheet-sticky .sheet-project-bar .project-switcher-chevron {
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--sheet-line);
    background: var(--sheet-paper);
    color: var(--sheet-ink) !important;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    line-height: 1;
    top: 50%;
}
.form-topic-bar {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .7rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 6px 16px rgba(15, 39, 68, .06);
    position: sticky;
    top: 0;
    z-index: 46;
}
.sheet-topic-bar {
    background: var(--sheet-head);
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
    box-shadow: none;
    padding: .55rem .65rem;
    gap: .45rem;
    color: var(--sheet-head-ink);
}
.sheet-topic-bar-payment .sheet-topic-title,
.sheet-topic-bar-entry .sheet-topic-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .65rem;
    text-align: center;
}
.sheet-date-field {
    display: flex;
    align-items: center;
    gap: .25rem;
    width: 100%;
    position: relative;
}
.sheet-date-field .jalali-date-input {
    flex: 1;
    min-width: 0;
    padding-left: 1.8rem;
    cursor: pointer;
}
.sheet-date-field .sheet-date-edit {
    position: absolute;
    left: .35rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--sheet-muted);
    font-size: .85rem;
}
.sheet-date-cell {
    cursor: pointer;
}
.sheet-topic-date {
    flex-shrink: 0;
    font-size: .92rem;
    font-weight: 700;
    color: var(--sheet-ink);
    direction: ltr;
    background: var(--sheet-paper);
    border: 1.5px solid var(--sheet-line);
    padding: .25rem .55rem;
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font: inherit;
    border-radius: 8px;
}
.sheet-topic-date:active {
    transform: scale(.97);
    background: color-mix(in srgb, var(--primary-soft, #e8f4fd) 55%, #fff);
}
.sheet-topic-title {
    flex: 1;
    text-align: center;
    min-width: 0;
}
.sheet-topic-title strong {
    font-size: 1.05rem;
    color: var(--sheet-head-ink);
}
.sheet-back-btn {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 1.5px solid var(--sheet-line);
    background: var(--sheet-paper);
    color: var(--sheet-ink);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
}
.sheet-sticky .form-supporter-btn {
    order: -1;
    margin-inline-start: 0;
    margin-inline-end: auto;
    background: #16a34a !important;
    box-shadow: none;
    border-radius: 6px;
    font-size: .72rem;
    padding: .35rem .55rem;
    min-height: 2rem;
}
.entry-sheet {
    margin: 0;
    padding: 0;
    background: var(--sheet-paper);
    border: 1.5px solid var(--sheet-line);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    color: var(--sheet-ink);
}
.sheet-row {
    display: flex;
    align-items: stretch;
    min-height: 48px;
    border-bottom: 1.5px solid var(--sheet-line);
    background: var(--sheet-paper);
    color: var(--sheet-ink);
}
.sheet-row:last-child { border-bottom: none; }
.sheet-today {
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1rem;
    padding: .7rem .85rem;
}
.sheet-today-sticky {
    display: flex;
    background: var(--card);
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
    margin: 0;
    min-height: 48px;
}
.sheet-label {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: .65rem .85rem;
    font-weight: 700;
    border-left: 1.5px solid var(--sheet-line);
    min-width: 4.5rem;
    justify-content: center;
    color: var(--sheet-ink);
    background: var(--sheet-paper);
}
.sheet-input,
.sheet-select {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    padding: .65rem .75rem;
    color: var(--sheet-ink);
    outline: none;
}
.sheet-input::placeholder,
.sheet-select::placeholder,
.jalali-date-input.sheet-input::placeholder,
.time-picker-input.sheet-input::placeholder {
    color: var(--sheet-placeholder);
    opacity: 1;
    text-align: right;
    direction: rtl;
}
.sheet-amount-input {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--sheet-ink);
}
.sheet-amount-payment {
    background: var(--sheet-highlight);
}
.sheet-amount-payment .sheet-label,
.sheet-amount-payment .sheet-currency-wrap {
    background: var(--sheet-paper);
}
.sheet-currency-wrap {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    border-right: 1.5px solid var(--sheet-line);
}
.sheet-currency-fixed {
    display: grid;
    place-items: center;
    min-width: 4.2rem;
    padding: 0 .65rem;
    font-weight: 800;
    color: var(--sheet-ink);
    white-space: nowrap;
}
.sheet-currency {
    width: auto;
    min-width: 4.2rem;
    text-align: center;
    font-weight: 700;
    appearance: none;
    padding-inline-end: .2rem;
}
.sheet-chevron {
    width: 34px;
    display: grid;
    place-items: center;
    border-right: 1.5px solid var(--sheet-line);
    font-size: 1.2rem;
    color: var(--sheet-ink);
    background: var(--sheet-paper);
    flex-shrink: 0;
}
.sheet-select-row {
    position: relative;
}
.sheet-select-full {
    width: 100%;
    appearance: none;
    padding-left: 2.4rem;
    font-weight: 600;
}
.sheet-select.is-placeholder,
.sheet-input.is-placeholder,
#linked-purchase-toggle-label.is-placeholder,
#payer-display.is-placeholder {
    color: var(--sheet-placeholder) !important;
    font-weight: 500;
    text-align: right !important;
}
.sheet-select.has-value,
.sheet-input.has-value,
#linked-purchase-toggle-label.has-value,
#payer-display.has-value {
    color: var(--sheet-ink) !important;
    font-weight: 700;
}
.sheet-select option {
    color: var(--sheet-ink);
    font-weight: 600;
    background: var(--sheet-paper);
}
.sheet-select option.sheet-option-placeholder,
.sheet-select option[value=""] {
    color: var(--sheet-placeholder);
    font-weight: 500;
}
.sheet-select-row .sheet-chevron {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-right: 0;
    border-left: 1.5px solid var(--sheet-line);
}
.sheet-select-row .sheet-chevron.is-open {
    transform: rotate(-90deg);
}
.linked-purchase-modal {
    position: fixed;
    inset: 0;
    z-index: 160;
    display: grid;
    place-items: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
}
.linked-purchase-modal.open {
    opacity: 1;
    pointer-events: auto;
}
.linked-item-report-btn {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: var(--sheet-line);
    font-size: 1.1rem;
    cursor: pointer;
    padding: .35rem .45rem;
}
.linked-item-report-btn:hover,
.linked-item-report-btn:focus-visible {
    color: #2563eb;
}
.entry-sheet-income .sheet-amount-payment {
    background: color-mix(in srgb, #22c55e 12%, #fff);
}
.linked-purchase-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}
.linked-purchase-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    max-height: min(86vh, 640px);
    overflow: auto;
    background: #fff;
    border: 1.5px solid var(--sheet-line);
    box-shadow: 0 18px 40px rgba(15, 23, 42, .22);
}
.linked-purchase-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .85rem .75rem .7rem;
    border-bottom: 1.5px solid var(--sheet-line);
    background: #fff;
}
.linked-purchase-head strong {
    font-size: 1.05rem;
    color: var(--sheet-ink);
}
.linked-purchase-close {
    border: 0;
    background: transparent;
    color: var(--sheet-accent);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    padding: .1rem .4rem;
}
.linked-purchase-fields {
    min-width: 0;
}
.linked-purchase-fields .sheet-row {
    border-bottom: 1.5px solid var(--sheet-line);
}
.linked-purchase-fields .sheet-row:last-child {
    border-bottom: 0;
}
.linked-purchase-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--sheet-highlight);
    border-top: 1.5px solid var(--sheet-line);
}
.linked-purchase-actions .sheet-action-btn {
    min-height: 2.75rem;
    border: 0;
    border-left: 1.5px solid var(--sheet-line);
    background: transparent;
    font: inherit;
    font-weight: 800;
    font-size: .95rem;
    color: var(--sheet-ink);
    cursor: pointer;
}
.linked-purchase-actions .sheet-action-btn:last-child {
    border-left: 0;
}
.linked-field-row .sheet-unit-cell {
    flex-shrink: 0;
    min-width: 3.4rem;
    display: grid;
    place-items: center;
    border-right: 1.5px solid var(--sheet-line);
    font-weight: 700;
    font-size: .85rem;
    color: #64748b;
    background: var(--card);
}
.linked-field-row .sheet-unit-with-input {
    min-width: 5.2rem;
    padding: .2rem .35rem;
    gap: .1rem;
}
.linked-field-row .sheet-unit-with-input small {
    font-size: .68rem;
    color: #94a3b8;
    font-weight: 600;
}
.linked-field-row .sheet-unit-with-input .sheet-input {
    padding: .15rem;
    text-align: center;
    font-weight: 700;
    color: var(--sheet-ink);
}
.linked-field-row .sheet-chevron {
    position: static;
    border-left: 0;
    border-right: 1.5px solid var(--sheet-line);
}
#linked-purchase-toggle {
    cursor: pointer;
}
#linked-purchase-toggle-label {
    pointer-events: none;
}
.party-block {
    border-bottom: 1.5px solid var(--sheet-line);
}
.party-block .sheet-row {
    border-bottom: 1.5px solid var(--sheet-line);
}
.party-block .sheet-row:last-child {
    border-bottom: 0;
}
.party-block-head {
    border-bottom: 0 !important;
}
.party-block-panel {
    background: var(--sheet-panel);
    border-top: 1.5px solid var(--sheet-line);
}
.party-block-panel.hidden {
    display: none;
}
.party-hint {
    margin: 0;
    padding: .55rem .75rem .35rem;
    font-size: .78rem;
    line-height: 1.55;
    color: #64748b;
    text-align: center;
}
.party-hint-faded {
    opacity: .72;
}
.party-expand-btn {
    width: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-right: 0;
    border-left: 1.5px solid var(--sheet-line);
    background: #fff;
    color: var(--sheet-accent);
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
}
.party-expand-btn.is-open {
    transform: rotate(-90deg);
}
.party-block-head {
    position: relative;
}
.party-block-head .sheet-input,
.party-block-head .sheet-select,
.party-block-head #payer-display {
    padding-left: 2.4rem;
}
.party-block-head:has(.party-actions) .sheet-field .sheet-input {
    padding-left: .65rem;
}
.sheet-inline-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding-left: .5rem;
}
.sheet-textarea {
    resize: vertical;
    min-height: 2.5rem;
}
.sheet-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 0;
}
.sheet-cell {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    min-height: 64px;
    padding: .35rem .5rem .5rem;
    background: var(--sheet-paper);
    color: var(--sheet-ink);
}
.sheet-cell + .sheet-cell {
    border-right: 1.5px solid var(--sheet-line);
}
.sheet-cell-label {
    text-align: center;
    font-size: .78rem;
    font-weight: 700;
    color: var(--sheet-muted);
    margin-bottom: .15rem;
}
.sheet-center { text-align: center; font-weight: 600; color: var(--sheet-ink); }
.sheet-media-cell {
    align-items: center;
    justify-content: center;
    gap: .35rem;
}
.sheet-media-btn {
    width: 100%;
    min-height: 2.6rem;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 700;
    font-size: 1rem;
    color: var(--sheet-ink) !important;
    cursor: pointer;
    display: grid;
    place-items: center;
    text-align: center;
}
.sheet-media-btn.recording,
#voice-record-btn.recording {
    color: #b91c1c;
}
.sheet-media-meta {
    border-top: 0;
    padding: .55rem .75rem;
}
.sheet-media-meta:empty { display: none; }
.photo-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .45rem;
}
.photo-preview-item {
    width: 72px;
    display: grid;
    gap: .2rem;
}
.photo-preview-item img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.photo-preview-item span {
    font-size: .65rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sheet-section-title {
    justify-content: center;
    align-items: center;
    font-weight: 700;
    background: var(--sheet-panel);
}
.sheet-actions-inline {
    justify-content: center;
    align-items: center;
    padding: .55rem;
}
.sheet-items .item-card {
    border-radius: 0;
    border: 0;
    border-bottom: 1.5px solid var(--sheet-line);
    box-shadow: none;
}
.sheet-items-purchase .sheet-item-block,
.sheet-items-contract .sheet-item-block,
.sheet-items-consumption .sheet-item-block {
    display: contents;
}
.sheet-item-toolbar {
    justify-content: space-between;
    align-items: center;
    padding: .45rem .75rem;
    background: var(--sheet-panel);
    font-size: .85rem;
}
.sheet-qty-row,
.sheet-price-row,
.sheet-total-row,
.sheet-progress-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
}
.sheet-qty-stock-row {
    display: grid;
    grid-template-columns: 1fr minmax(5.5rem, 7rem) auto;
    align-items: stretch;
}
.sheet-qty-stock-row .sheet-input {
    border: 0;
    border-radius: 0;
    min-height: 48px;
}
.sheet-stock-cell {
    display: grid;
    place-items: center;
    gap: .1rem;
    border-right: 1.5px solid var(--sheet-line);
    border-left: 1.5px solid var(--sheet-line);
    background: #eef1f4;
    padding: .25rem .4rem;
    text-align: center;
}
.sheet-stock-cell small {
    font-size: .68rem;
    color: var(--sheet-muted);
    font-weight: 600;
}
.sheet-stock-cell .item-remaining {
    font-size: .95rem;
    font-weight: 800;
    color: var(--sheet-ink);
}
.sheet-qty-stock-row .sheet-unit-cell {
    flex-shrink: 0;
    min-width: 4.6rem;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .85rem;
    color: var(--sheet-ink);
    background: var(--sheet-panel);
    padding: .2rem .35rem;
}
.sheet-qty-stock-row .sheet-unit-with-input {
    min-width: 5.2rem;
    gap: .1rem;
}
.sheet-qty-stock-row .sheet-unit-with-input small {
    font-size: .68rem;
    color: var(--sheet-muted);
    font-weight: 600;
}
.sheet-qty-stock-row .sheet-unit-with-input .sheet-input {
    padding: .15rem;
    text-align: center;
    font-weight: 700;
    color: var(--sheet-ink);
    min-height: 1.6rem;
    background: transparent;
}
.sheet-consumption-tools {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: stretch;
    min-height: 48px;
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
}
.sheet-consumption-modes {
    display: grid;
    grid-template-rows: 1fr 1fr;
    min-width: 5.8rem;
    border-left: 1.5px solid var(--sheet-line);
}
.sheet-mode-btn {
    border: 0;
    border-bottom: 1.5px solid var(--sheet-line);
    background: #f3f4f6;
    color: var(--sheet-ink);
    font: inherit;
    font-weight: 700;
    font-size: .82rem;
    padding: .35rem .55rem;
    cursor: pointer;
    line-height: 1.2;
}
.sheet-mode-btn:last-child {
    border-bottom: 0;
}
.sheet-mode-btn.is-active {
    background: #fde047;
    font-weight: 800;
}
.sheet-consumption-modes.field-invalid .sheet-mode-btn {
    box-shadow: inset 0 0 0 1.5px #dc2626;
}
.sheet-consumption-type-wrap {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
    background: #fef9c3;
}
.sheet-consumption-type {
    display: grid;
    place-items: center;
    font-weight: 800;
    color: var(--sheet-ink);
}
.sheet-consumption-type-wrap .sheet-chevron {
    position: static;
    display: grid;
    place-items: center;
    width: 2.2rem;
    border-right: 1.5px solid var(--sheet-line);
    color: #2563eb;
}
.sheet-consumption-hint {
    padding: .55rem .75rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--sheet-muted);
    background: #f8fafc;
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
}
.sheet-consumption-hint.is-required-hint {
    color: #b45309;
    background: #fffbeb;
}
.sheet-items-consumption.is-disabled-block {
    opacity: .55;
    pointer-events: none;
}
.sheet-tool-btn {
    border: 0;
    border-left: 1.5px solid var(--sheet-line);
    background: #f3f4f6;
    color: var(--sheet-ink);
    font: inherit;
    font-weight: 700;
    font-size: .85rem;
    padding: .5rem .75rem;
    cursor: pointer;
    white-space: nowrap;
}
.sheet-stock-cell .item-remaining {
    border: 0;
    background: transparent;
    font-size: .95rem;
    font-weight: 800;
    color: var(--sheet-ink);
    min-height: 1.4rem;
    padding: 0;
    width: 100%;
    pointer-events: none;
}
.stock-picker-list {
    display: grid;
    gap: .5rem;
    padding: .75rem;
    max-height: min(55vh, 420px);
    overflow: auto;
}
.stock-picker-item {
    display: grid;
    gap: .2rem;
    text-align: right;
    border: 1.5px solid var(--sheet-line);
    background: var(--sheet-paper);
    color: var(--sheet-ink);
    border-radius: 10px;
    padding: .75rem .85rem;
    font: inherit;
    cursor: pointer;
}
.stock-picker-item strong {
    font-size: .95rem;
}
.stock-picker-item span {
    font-size: .8rem;
    color: var(--sheet-muted);
}
.entry-sheet-consumption .sheet-items-consumption {
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
}
.sheet-progress-row,
.sheet-items-contract .sheet-price-row {
    grid-template-columns: 1fr auto auto;
}
.sheet-qty-row .sheet-input,
.sheet-price-row .sheet-input,
.sheet-total-row .sheet-input,
.sheet-progress-row .sheet-input {
    border: 0;
    border-radius: 0;
    min-height: 48px;
}
.sheet-qty-row .sheet-unit-cell,
.sheet-price-row .sheet-unit-cell,
.sheet-total-row .sheet-unit-cell,
.sheet-progress-row .sheet-unit-cell {
    flex-shrink: 0;
    min-width: 4.6rem;
    display: grid;
    place-items: center;
    border-right: 1.5px solid var(--sheet-line);
    font-weight: 700;
    font-size: .85rem;
    color: var(--sheet-ink);
    background: var(--sheet-panel);
    padding: .2rem .35rem;
}
.sheet-qty-row .sheet-unit-with-input {
    min-width: 5.2rem;
    gap: .1rem;
    position: relative;
}
.sheet-price-row .sheet-unit-with-input {
    min-width: 5.2rem;
    gap: .1rem;
    position: relative;
    background: var(--sheet-panel);
}
.sheet-qty-row .sheet-unit-with-input small,
.sheet-price-row .sheet-unit-with-input small {
    font-size: .68rem;
    color: var(--sheet-muted);
    font-weight: 600;
}
.sheet-qty-row .sheet-unit-with-input .sheet-input,
.sheet-price-row .sheet-unit-with-input .sheet-input {
    padding: .15rem;
    text-align: center;
    font-weight: 700;
    color: var(--sheet-ink);
    min-height: 1.6rem;
    background: transparent;
}
.sheet-qty-row .sheet-unit-with-input .sheet-input::placeholder,
.sheet-price-row .sheet-unit-with-input .sheet-input::placeholder {
    color: var(--sheet-placeholder);
    font-weight: 600;
}
.sheet-unit-arrow {
    font-size: .65rem;
    color: #2563eb;
    line-height: 1;
}
.sheet-price-row .sheet-chevron,
.sheet-progress-row .sheet-chevron {
    position: static;
    display: grid;
    place-items: center;
    width: 2.2rem;
    border-right: 1.5px solid var(--sheet-line);
    color: #2563eb;
    background: var(--sheet-paper);
}
.sheet-subject-row {
    display: grid !important;
    grid-template-columns: auto auto 1fr auto;
    align-items: stretch;
}
.sheet-subject-row .sheet-input {
    border: 0;
    border-radius: 0;
    min-height: 48px;
    padding-left: .75rem !important;
}
.sheet-subject-plus,
.sheet-help-q {
    width: 2.2rem;
    border: 0;
    border-left: 1.5px solid var(--sheet-line);
    background: var(--sheet-paper);
    color: #2563eb;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}
.sheet-help-q {
    font-size: 1rem;
    font-weight: 800;
}
.sheet-help-q:active {
    background: color-mix(in srgb, #dbeafe 70%, #fff);
}
.sheet-subject-row .sheet-chevron {
    position: static !important;
    display: grid;
    place-items: center;
    width: 2.2rem;
    border-right: 1.5px solid var(--sheet-line);
    border-left: 0;
    color: #2563eb;
    background: var(--sheet-paper);
}
.sheet-contract-link-hint {
    justify-content: center;
    align-items: center;
    min-height: 2rem;
    padding: .25rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--sheet-muted);
    background: color-mix(in srgb, #fef3c7 70%, #fff);
    text-align: center;
}
.entry-sheet-contract .sheet-linked-payment {
    background: #bfdbfe;
}
.entry-sheet-contract .sheet-linked-payment .sheet-chevron {
    color: #2563eb;
    font-size: .85rem;
}
.sheet-currency-unit,
.sheet-currency-label {
    min-width: 4.5rem;
    color: var(--sheet-ink);
}
.sheet-unit-select {
    width: 100%;
    min-height: 2.4rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    font: inherit;
    font-size: .78rem;
    font-weight: 700;
    text-align: center;
    padding: 0 .25rem;
    appearance: none;
    color: #475569;
}
.sheet-linked-payment {
    background: #dbeafe;
}
.sheet-linked-payment .sheet-select,
.sheet-linked-payment .sheet-select-full {
    background: transparent;
    font-weight: 700;
}
.linked-payment-panel {
    border-bottom: 1.5px solid var(--sheet-line);
    background: #dbeafe;
}
.linked-payment-panel.hidden { display: none !important; }
.linked-payment-panel .linked-pay-line {
    border-bottom: 1.5px solid #93c5fd;
    padding-bottom: 0.15rem;
    margin-bottom: 0.15rem;
}
.linked-payment-panel .linked-pay-line:last-child {
    border-bottom: 0;
    margin-bottom: 0;
}
.linked-payment-panel .linked-pay-line-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.65rem;
    background: #bfdbfe;
    border-bottom: 1.5px solid var(--sheet-line);
    min-height: 40px;
}
.linked-payment-panel .linked-pay-line-title {
    font-size: 0.85rem;
    color: #1e3a8a;
}
.linked-payment-panel .linked-pay-add-row {
    padding: 0.4rem 0.65rem;
    background: #dbeafe;
    border-bottom: 0;
}
.linked-payment-panel .linked-pay-row {
    border-bottom: 1.5px solid var(--sheet-line);
    background: #eff6ff;
    min-height: 48px;
}
.linked-payment-panel .linked-pay-row:last-child {
    border-bottom: 0;
}
.linked-payment-panel .sheet-amount {
    background: #eff6ff;
}
.linked-payment-panel .sheet-amount .sheet-label {
    background: #eff6ff;
}
.linked-payment-panel .sheet-amount .sheet-currency-wrap {
    background: #eff6ff;
}
.linked-payment-panel .sheet-amount .sheet-chevron {
    position: static;
    display: grid;
    place-items: center;
    width: 2.2rem;
    border-right: 1.5px solid var(--sheet-line);
    color: #2563eb;
    background: #eff6ff;
}
.linked-payment-panel .sheet-select-row .sheet-chevron {
    color: #2563eb;
}
.linked-payment-panel .linked-pay-datetime {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 0;
    gap: 0;
}
.linked-payment-panel .linked-pay-datetime .sheet-cell {
    display: flex;
    align-items: stretch;
    min-width: 0;
    padding: 0;
}
.linked-payment-panel .linked-pay-datetime .sheet-cell + .sheet-cell {
    border-right: 1.5px solid var(--sheet-line);
}
.linked-payment-panel .linked-pay-datetime .sheet-input {
    border: 0;
    border-radius: 0;
    min-height: 48px;
    background: transparent;
    width: 100%;
}
.linked-receive-panel .linked-receive-date {
    padding: 0;
}
.linked-receive-panel .linked-receive-date .sheet-input {
    border: 0;
    border-radius: 0;
    min-height: 48px;
    background: transparent;
    width: 100%;
}
.sheet-purchase-day {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: .5rem;
    padding: .35rem .75rem;
}
.sheet-purchase-day .sheet-cell-label {
    margin: 0;
    white-space: nowrap;
}
.sheet-purchase-day .sheet-input {
    border: 0;
}
.sheet-day-top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
    min-height: 48px;
}
.sheet-day-top .sheet-day-top-date {
    border: 0;
    border-radius: 0;
    min-height: 48px;
    font-weight: 700;
    direction: ltr;
}
.sheet-day-top-label {
    display: grid;
    place-items: center;
    min-width: 5.5rem;
    padding: .35rem .55rem;
    border-right: 1.5px solid var(--sheet-line);
    background: var(--sheet-panel);
    font-weight: 700;
    font-size: .9rem;
    color: var(--sheet-ink);
}
.sheet-invoice-total {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: stretch;
    min-height: 48px;
    background: color-mix(in srgb, var(--sheet-panel) 80%, #fff);
}
.sheet-invoice-input {
    border: 0 !important;
    border-radius: 0 !important;
    min-height: 48px;
    font-weight: 800;
    background: transparent;
}
.sheet-invoice-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--sheet-ink);
}
.sheet-invoice-value {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 5rem;
    padding: 0 .5rem;
    font-weight: 800;
    direction: ltr;
}
.sheet-invoice-total .sheet-unit-cell {
    min-width: 4.5rem;
    display: grid;
    place-items: center;
    border-right: 1.5px solid var(--sheet-line);
    background: var(--sheet-panel);
    font-weight: 700;
}
.form-topic-title {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: .1rem;
}
.form-topic-title-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-width: 0;
}
.form-topic-title-row strong {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.form-topic-date {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: .75rem !important;
    font-weight: 700;
    white-space: nowrap;
    direction: ltr;
}
.form-topic-title span {
    font-size: .75rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.form-supporter-btn {
    flex-shrink: 0;
    margin-inline-start: auto;
    white-space: nowrap;
    background: #25d366 !important;
    color: #fff !important;
    text-decoration: none;
    font-size: .75rem;
    padding: .4rem .75rem;
    min-height: 2.2rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(37, 211, 102, .28);
}
.btn-supporter {
    background: #25d366;
    color: #fff;
    text-decoration: none;
}
.btn-supporter:active { filter: brightness(.95); }

#chat-root {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(15, 23, 42, .45);
}
#chat-root.open { display: flex; align-items: stretch; justify-content: center; }
#chat-root.workspace { background: rgba(15, 23, 42, .55); padding: .75rem; }
.chat-workspace {
    position: relative;
    width: min(1200px, 100%);
    height: 100%;
    max-height: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    background: #eef2f7;
    overflow: hidden;
    border: 1.5px solid var(--sheet-line);
}
#chat-root.workspace .chat-workspace {
    height: calc(100% - 0px);
    max-height: calc(100vh - 1.5rem);
    border-radius: 12px;
}
.chat-workspace.has-edit {
    grid-template-columns: 1fr;
}
.chat-panel {
    position: relative;
    inset: auto;
    display: flex;
    flex-direction: column;
    background: #eef2f7;
    max-width: none;
    margin: 0;
    min-height: 0;
    min-width: 0;
}
.chat-header {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .75rem 1rem;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
}
.chat-header-info {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: .1rem;
}
.chat-header-info strong { font-size: 1rem; }
.chat-header-info span { font-size: .78rem; opacity: .85; }
.chat-messages {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    min-height: 0;
}
.chat-empty {
    text-align: center;
    color: var(--muted);
    margin: auto;
    padding: 2rem 1rem;
}
.chat-bubble {
    max-width: min(85%, 360px);
    padding: .65rem .8rem;
    border-radius: 14px;
    background: var(--card);
    box-shadow: var(--shadow);
}
.chat-bubble.mine {
    align-self: flex-end;
    background: var(--primary-soft);
    border-bottom-left-radius: 4px;
}
.chat-bubble.theirs {
    align-self: flex-start;
    background: var(--card);
    border-bottom-right-radius: 4px;
}
.chat-bubble-meta {
    font-size: .7rem;
    color: var(--muted);
    margin-bottom: .3rem;
}
.chat-bubble img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    display: block;
}
.chat-image-open {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: zoom-in;
    display: block;
}
.chat-bubble audio { width: min(100%, 260px); }
.chat-text { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.chat-compose {
    display: flex;
    gap: .45rem;
    align-items: center;
    padding: .65rem .75rem calc(.65rem + var(--safe-bottom));
    background: #fff;
    border-top: 1px solid var(--border);
}
.chat-compose-rich {
    flex-direction: column;
    align-items: stretch;
    gap: .55rem;
}
.chat-compose-row {
    display: flex;
    gap: .45rem;
    align-items: center;
}
.chat-compose-tools {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}
.chat-media-pick {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .4rem .7rem;
    border-radius: 10px;
    background: #e0f2fe;
    color: #075985;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #bae6fd;
}
.chat-tool-btn {
    min-height: 38px;
    padding: 0 .75rem;
    border: 0;
    border-radius: 10px;
    background: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 700;
    font: inherit;
}
.chat-tool-btn.recording {
    background: #fee2e2;
    color: #b91c1c;
    animation: pulse 1s infinite;
}
#chat-text-input {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .45rem .7rem;
    font: inherit;
}
.chat-edit-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    background: #fff;
    border-top: 1.5px solid var(--sheet-line);
}
.chat-edit-head {
    padding: .75rem 1rem;
    background: #f5e6c8;
    border-bottom: 1px solid #e2e8f0;
    display: grid;
    gap: .2rem;
}
.chat-edit-head strong { font-size: .95rem; }
.chat-edit-head span { font-size: .75rem; color: #64748b; }
.chat-edit-form {
    flex: 1;
    overflow: auto;
    padding: .85rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    min-height: 0;
}
.chat-edit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
}
.chat-edit-grid label {
    display: grid;
    gap: .3rem;
    font-size: .78rem;
    font-weight: 700;
    color: #334155;
}
.chat-edit-grid label.span-2 { grid-column: 1 / -1; }
.chat-edit-grid input,
.chat-edit-grid select,
.chat-edit-grid textarea {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: .5rem .65rem;
    font: inherit;
    font-weight: 500;
    color: var(--sheet-ink);
    background: #fff;
}
.chat-edit-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-top: .35rem;
}
.chat-media-viewer {
    position: absolute;
    inset: auto auto .85rem .85rem;
    width: min(420px, 46%);
    max-height: 55%;
    z-index: 5;
    background: rgba(15, 23, 42, .92);
    border: 1.5px solid #fff;
    border-radius: 12px;
    padding: .5rem;
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.chat-media-viewer.hidden { display: none; }
.chat-media-viewer img {
    max-width: 100%;
    max-height: 48vh;
    object-fit: contain;
    border-radius: 8px;
}
.chat-media-viewer-close {
    align-self: flex-end;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 1.2rem;
}

@media (min-width: 900px) {
    .chat-workspace.has-edit {
        grid-template-columns: minmax(340px, 1.05fr) minmax(360px, 1fr);
    }
    .chat-edit-panel {
        border-top: 0;
        border-right: 1.5px solid var(--sheet-line);
    }
    .chat-media-viewer {
        /* stays over chat side so edit panel remains free */
        right: auto;
        left: .85rem;
        bottom: .85rem;
        width: min(380px, 42%);
    }
}

@media (max-width: 899px) {
    #chat-root.workspace {
        padding: 0;
    }
    #chat-root.workspace .chat-workspace {
        max-height: 100vh;
        border-radius: 0;
        border: 0;
    }
    .chat-workspace.has-edit {
        grid-template-rows: minmax(42vh, 1fr) minmax(40vh, 1fr);
    }
    .chat-media-viewer {
        width: min(92vw, 360px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: 42vh;
    }
}
.chat-edit-grid label.field-incomplete {
    color: #b91c1c;
}
.chat-edit-grid label.field-incomplete input,
.chat-edit-grid label.field-incomplete select,
.chat-edit-grid label.field-incomplete textarea {
    border-color: #ef4444;
    background: #fef2f2;
    box-shadow: 0 0 0 1px #fecaca;
}
.sheet-row.field-incomplete,
.sheet-cell.field-incomplete,
.sheet-currency-wrap.field-incomplete,
.sheet-unit-cell.field-incomplete {
    background: #fef2f2 !important;
    color: #b91c1c;
}
.sheet-row.field-incomplete .sheet-label,
.sheet-row.field-incomplete .sheet-select,
.sheet-row.field-incomplete .sheet-input,
.sheet-cell.field-incomplete .sheet-cell-label {
    color: #b91c1c;
    font-weight: 700;
}
.sheet-row.field-incomplete .sheet-input,
.sheet-row.field-incomplete .sheet-select,
.sheet-cell.field-incomplete .sheet-input {
    background: #fff5f5;
}
.incomplete-banner {
    margin: .65rem 1rem 0;
    padding: .65rem .85rem;
    border-radius: 10px;
    background: #fef2f2;
    border: 1.5px solid #fca5a5;
    color: #991b1b;
    font-size: .88rem;
    font-weight: 700;
    text-align: center;
}
.admin-filled-banner {
    margin: .65rem 1rem 0;
    padding: .65rem .85rem;
    border-radius: 10px;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    color: #166534;
    font-size: .88rem;
    font-weight: 700;
    text-align: center;
}
.chat-edit-grid label.field-admin-filled {
    color: #166534;
}
.chat-edit-grid label.field-admin-filled input,
.chat-edit-grid label.field-admin-filled select,
.chat-edit-grid label.field-admin-filled textarea {
    border-color: #22c55e;
    background: #f0fdf4;
    box-shadow: 0 0 0 1px #bbf7d0;
}
.sheet-row.field-admin-filled,
.sheet-cell.field-admin-filled,
.sheet-currency-wrap.field-admin-filled,
.sheet-unit-cell.field-admin-filled {
    background: #f0fdf4 !important;
    color: #166534;
}
.sheet-row.field-admin-filled .sheet-label,
.sheet-row.field-admin-filled .sheet-select,
.sheet-row.field-admin-filled .sheet-input,
.sheet-cell.field-admin-filled .sheet-cell-label {
    color: #166534;
    font-weight: 700;
}
.sheet-row.field-admin-filled .sheet-input,
.sheet-row.field-admin-filled .sheet-select,
.sheet-cell.field-admin-filled .sheet-input {
    background: #f7fef9;
}
.form-page {
    padding: 0 0 calc(260px + var(--safe-bottom));
}
.sheet-consumption-date,
.sheet-payment-date {
    margin: 0;
    border-bottom: 1.5px solid var(--sheet-line);
    background: var(--sheet-paper);
    min-height: 52px;
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    align-items: stretch;
    cursor: pointer;
}
.sheet-consumption-date .sheet-cell-label,
.sheet-payment-date .sheet-cell-label {
    font-weight: 700;
    display: grid;
    place-items: center;
    padding: 0 .75rem;
    white-space: nowrap;
    pointer-events: none;
    color: var(--sheet-muted);
}
.sheet-consumption-date .sheet-input,
.sheet-payment-date .sheet-input {
    font-weight: 800;
    direction: ltr;
    border: 0;
    min-height: 52px;
    cursor: pointer;
    color: var(--sheet-ink);
    text-align: center;
}
.sheet-consumption-date .sheet-date-edit,
.sheet-payment-date .sheet-date-edit {
    position: static !important;
    display: grid;
    place-items: center;
    width: 2.4rem;
    border-right: 1.5px solid var(--sheet-line);
    color: #2563eb;
    background: var(--sheet-paper);
    pointer-events: none;
}
.form-page:has(.form-bottom-dock-consumption) {
    padding-bottom: calc(220px + var(--safe-bottom));
}
.form-page:has(.form-bottom-dock-payment) {
    padding-bottom: calc(300px + var(--safe-bottom));
}
.sheet-time-only-row {
    display: grid;
    grid-template-columns: 1fr;
}
.sheet-time-only-row .sheet-cell {
    border-left: 0;
}
.form-page .type-history {
    margin: .85rem 1rem 0;
}
.sheet-file-fallback {
    display: none;
    width: 100%;
    margin-top: .45rem;
    font-size: .78rem;
}
.sheet-file-fallback.is-visible {
    display: block;
}
.form-bottom-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(84px + var(--safe-bottom));
    z-index: 95;
    max-width: 640px;
    margin: 0 auto;
    background: var(--sheet-paper);
    color: var(--sheet-ink);
}
.sheet-dock-date {
    margin: 0;
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
    background: var(--sheet-paper);
    min-height: 48px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: stretch;
    cursor: pointer;
    position: relative;
    z-index: 2;
}
.sheet-dock-date .sheet-cell-label {
    font-weight: 700;
    display: grid;
    place-items: center;
    padding: 0 .75rem;
    white-space: nowrap;
    pointer-events: none;
}
.sheet-dock-date .sheet-input {
    font-weight: 800;
    direction: ltr;
    border: 0;
    min-height: 48px;
    cursor: pointer;
    color: var(--sheet-ink);
}
.sheet-dock-date .jalali-date-input {
    pointer-events: auto;
}
.sheet-dock-date .sheet-date-edit {
    position: static;
    display: grid;
    place-items: center;
    width: 2.2rem;
    border-right: 1.5px solid var(--sheet-line);
    color: #2563eb;
    background: var(--sheet-paper);
    pointer-events: none;
}
.form-action-bar.sheet-action-bar .sheet-action-btn {
    min-height: 3rem;
    border: 0;
    border-left: 1.5px solid var(--sheet-line);
    background: #fef9c3;
    font: inherit;
    font-weight: 800;
    font-size: 1rem;
    color: var(--sheet-ink);
    cursor: pointer;
}
.form-action-bar.sheet-action-bar .sheet-action-btn.sheet-action-final {
    background: #fde047;
}
.form-action-bar.sheet-action-bar .sheet-action-btn:last-child {
    border-left: 0;
}
.sheet-media-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 52px;
    background: var(--sheet-paper);
    border: 1.5px solid var(--sheet-line);
    border-bottom: 0;
    color: var(--sheet-ink);
}
.sheet-media-bar .sheet-cell + .sheet-cell {
    border-right: 1.5px solid var(--sheet-line);
}
.form-bottom-dock .sheet-media-meta {
    padding: .35rem .65rem;
    border-left: 1.5px solid var(--sheet-line);
    border-right: 1.5px solid var(--sheet-line);
    background: var(--sheet-paper);
    color: var(--sheet-ink);
    max-height: 88px;
    overflow: auto;
}
.form-bottom-dock .sheet-media-meta:empty,
.form-bottom-dock .sheet-media-meta:not(:has(.voice-item, .photo-preview-item)) {
    display: none;
    padding: 0;
    border: 0;
}
.form-action-bar {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 0;
    background: var(--sheet-highlight);
    border: 1.5px solid var(--sheet-line);
    border-radius: 0;
    backdrop-filter: none;
    box-shadow: none;
    max-width: none;
    margin: 0;
}
.form-action-bar.sheet-action-bar .sheet-action-btn:disabled {
    opacity: .65;
    cursor: wait;
}
.form-action-bar .btn {
    min-height: 2.85rem;
    font-weight: 700;
}
.form-action-bar .btn:disabled {
    opacity: .65;
    cursor: wait;
}

.toast {
    position: fixed;
    left: 1rem; right: 1rem; bottom: calc(80px + var(--safe-bottom));
    background: var(--sheet-line);
    color: #fff;
    padding: .85rem 1rem;
    border-radius: 12px;
    text-align: center;
    z-index: 200;
    box-shadow: var(--shadow);
}
body:has(.form-bottom-dock) .toast {
    bottom: calc(250px + var(--safe-bottom));
}

.req-mark {
    color: #b91c1c;
    font-style: normal;
    font-weight: 800;
}
.field-invalid {
    background: #fef2f2 !important;
    outline: 2px solid #ef4444;
    outline-offset: -2px;
}
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.saved {
    background: #2563eb;
    font-weight: 800;
    letter-spacing: .01em;
    font-size: 1.05rem;
    box-shadow: 0 10px 28px rgba(37, 99, 235, .35);
}

.form-bottom-dock.saved-flash,
#tx-form.saved-flash {
    animation: form-saved-glow 1.4s ease;
}
.sheet-action-btn.hint-draft {
    background: #2563eb !important;
    color: #fff !important;
    animation: form-saved-glow 1.2s ease;
}
.sheet-action-btn.saved-ok {
    background: #2563eb !important;
    color: #fff !important;
    transition: background .2s ease, color .2s ease;
    animation: form-saved-pulse 2.4s ease;
}
.form-action-bar.sheet-action-bar .sheet-action-btn.saved-ok {
    background: #2563eb !important;
    color: #fff !important;
}
@keyframes form-saved-glow {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, #2563eb 55%, transparent); }
    35% { box-shadow: 0 0 0 4px color-mix(in srgb, #2563eb 45%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, #2563eb 0%, transparent); }
}
@keyframes form-saved-pulse {
    0% { filter: brightness(1); transform: scale(1); }
    20% { filter: brightness(1.08); transform: scale(1.02); }
    100% { filter: brightness(1); transform: scale(1); }
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(160deg, var(--primary-dark), var(--bg-from));
}

.login-brand {
    text-align: center;
    color: #fff;
    margin-bottom: 2rem;
}

.login-brand .logo {
    width: 72px; height: 72px;
    margin: 0 auto .85rem;
    border-radius: 18px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    display: grid; place-items: center;
    font-size: 1.8rem;
    box-shadow: 0 12px 32px rgba(245, 158, 11, .35);
}

.login-brand h1 { font-size: 1.4rem; margin-bottom: .35rem; }
.login-brand p { opacity: .75; font-size: .9rem; }

.login-card {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem;
    font-size: .9rem;
}

.voice-block { margin-top: 1rem; }
.voice-toolbar { display: flex; gap: .65rem; align-items: center; margin-bottom: .65rem; }
.voice-timer { font-weight: 700; color: #b91c1c; direction: ltr; }
.voice-list { display: grid; gap: .65rem; }
.voice-item {
    display: grid;
    gap: .45rem;
    padding: .75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
}
.voice-item audio { width: 100%; }
.voice-meta { font-size: .82rem; color: var(--muted); }
.voice-empty { font-size: .85rem; color: var(--muted); }
.btn.recording { animation: pulse 1s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .65; }
}

.install-banner {
    background: var(--primary-soft);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 14px;
    padding: .9rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: .65rem;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.5;
}

.dash-loading { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.dash-hero-mini {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}
.dash-hero-mini-label { font-size: .75rem; opacity: .8; margin-bottom: .25rem; }
.dash-hero-mini strong { display: block; font-size: 1.05rem; margin-bottom: .15rem; }
.dash-hero-mini span { font-size: .82rem; opacity: .85; }
.dash-stat-grid .stat-green { background: #f0fdf4; border-color: #bbf7d0; }
.dash-stat-grid .stat-red { background: #fef2f2; border-color: #fecaca; }
.dash-stat-grid .stat-blue { background: #eff6ff; border-color: #bfdbfe; }
.dash-stat-grid .stat-gold { background: #fffbeb; border-color: #fde68a; }
.dash-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .55rem;
}
.dash-quick {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .25rem;
    padding: .75rem .5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
}
.dash-quick span { font-size: 1.25rem; }
.dash-tx-item {
    display: flex;
    justify-content: space-between;
    gap: .65rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}
.dash-tx-item:last-child { border-bottom: none; }
.dash-tx-type { font-weight: 700; font-size: .9rem; }
.dash-tx-meta { font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.dash-tx-amount { font-weight: 700; direction: ltr; white-space: nowrap; }
.card-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    margin-bottom: .75rem;
}
.card-head-row h2 { margin: 0; }
.dash-project-card {
    display: flex;
    align-items: center;
    gap: .85rem;
    text-align: right;
}
.project-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #dbeafe;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.project-card-body { flex: 1; }
.project-card-arrow { color: var(--muted); font-size: 1.4rem; }

.report-page {
    padding: .75rem .65rem calc(168px + var(--safe-bottom));
}
.report-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-end;
    gap: .55rem;
    margin-bottom: .65rem;
}
.report-toolbar-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .45rem;
    flex: 1;
    min-width: 0;
}
.report-back-btn {
    flex: 0 0 auto;
    align-self: flex-end;
    border: 1.5px solid var(--sheet-line);
    border-radius: .55rem;
    background: #fff;
    font: inherit;
    font-weight: 700;
    font-size: .82rem;
    color: var(--sheet-ink);
    padding: .45rem .65rem;
    cursor: pointer;
    white-space: nowrap;
}
.report-back-btn:active {
    transform: scale(.97);
}
.report-type-wrap {
    display: grid;
    gap: .2rem;
    min-width: 0;
}
.report-type-label {
    font-size: .72rem;
    font-weight: 700;
    color: #64748b;
}
.report-type-select,
.report-toolbar .report-filter-select,
.report-toolbar-currency {
    min-width: 8.5rem;
    max-width: 100%;
    border: 1.5px solid var(--sheet-line);
    border-radius: .55rem;
    background: #fff;
    font: inherit;
    font-weight: 700;
    font-size: .82rem;
    text-align: right;
    color: var(--sheet-ink);
    padding: .45rem .55rem;
    appearance: auto;
    cursor: pointer;
}
.report-type-select.has-value,
.report-toolbar .report-filter-select.has-value {
    color: var(--primary);
    border-color: var(--primary);
}
.report-toolbar-currency {
    min-width: 6.5rem;
}
.report-person-wrap .report-filter-select {
    color: #94a3b8;
}
.report-person-wrap .report-filter-select.has-value {
    color: var(--primary);
}
.report-pdf-btn {
    appearance: none;
    border: 1.5px solid var(--sheet-line);
    background: var(--sheet-ink);
    color: #fff;
    font: inherit;
    font-weight: 700;
    font-size: .88rem;
    padding: .55rem 1rem;
    border-radius: .55rem;
    cursor: pointer;
    min-height: 2.4rem;
}
.report-pdf-btn:active {
    filter: brightness(.92);
}
.report-pdf-btn:disabled {
    opacity: .65;
    cursor: wait;
}
.report-total-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(68px + var(--safe-bottom));
    z-index: 95;
    padding: 0 .65rem;
    pointer-events: none;
}
.report-summary-bar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(72px + var(--safe-bottom));
    z-index: 110;
    padding: 0 .45rem;
    pointer-events: none;
    justify-content: flex-start;
    align-items: flex-end;
}
.report-summary-dock {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0;
    width: max-content;
    max-width: calc(100vw - .9rem);
    background: #fff;
    border: 1.5px solid var(--sheet-line);
    border-radius: .55rem;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
    pointer-events: auto;
}
.report-summary-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    flex: 0 0 auto;
    margin: 0;
    border: 0;
    border-inline-end: 1px solid #cbd5e1;
    background: #fde047;
    color: var(--sheet-ink);
    font: inherit;
    font-weight: 800;
    font-size: .82rem;
    padding: .5rem .65rem;
    cursor: pointer;
    min-height: 2.7rem;
    white-space: nowrap;
}
.report-summary-bar.is-collapsed .report-summary-toggle {
    border-inline-end: 0;
}
.report-summary-toggle-label {
    font-weight: 800;
}
.report-summary-toggle-amount {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-size: .8rem;
}
.report-summary-toggle-chevron {
    font-size: .7rem;
    color: var(--primary);
    line-height: 1;
}
.report-summary-bar-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.report-summary-bar-inner[hidden] {
    display: none !important;
}
.report-summary-cell {
    display: grid;
    gap: .12rem;
    justify-items: center;
    align-content: center;
    padding: .4rem .55rem;
    border-inline-start: 1px solid #cbd5e1;
    min-width: 0;
    text-align: center;
    flex: 0 0 auto;
    white-space: nowrap;
}
.report-summary-cell:first-child {
    border-inline-start: 0;
}
.report-summary-cell .report-filter-caption {
    font-size: .62rem;
    color: #64748b;
    font-weight: 700;
}
.report-summary-cell strong {
    font-size: .78rem;
    font-weight: 800;
    color: var(--sheet-ink);
    line-height: 1.3;
    word-break: break-word;
}
.report-summary-cell .num {
    direction: ltr;
    font-variant-numeric: tabular-nums;
}
.report-summary-total {
    background: #fde047;
    font-weight: 800;
    font-size: .88rem;
    align-items: center;
    justify-items: center;
}
.report-total-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    background: #fde047;
    border: 1.5px solid var(--sheet-line);
    border-radius: .7rem;
    padding: .7rem .85rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
    pointer-events: auto;
}
.report-total-bar-text {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-width: 0;
}
.report-total-bar-label {
    font-weight: 800;
    font-size: .92rem;
    color: var(--sheet-ink);
    line-height: 1.35;
    word-break: break-word;
}
.report-total-bar-meta {
    font-size: .75rem;
    color: #475569;
    font-weight: 600;
}
.report-total-bar-amount {
    flex-shrink: 0;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--sheet-ink);
}
.report-pdf-document {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    color: var(--sheet-ink);
    padding: 12px 16px 20px;
    box-sizing: border-box;
    touch-action: pan-x pan-y pinch-zoom;
}
.report-pdf-document h1 {
    margin: 0 0 .75rem;
    font-size: 1.35rem;
    font-weight: 800;
}
.report-pdf-meta,
.report-pdf-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem 1.1rem;
    margin-bottom: .7rem;
    font-size: .88rem;
}
.report-pdf-meta span,
.report-pdf-filters span {
    color: #64748b;
}
.report-pdf-meta strong,
.report-pdf-filters strong {
    color: var(--sheet-ink);
    font-weight: 700;
}
.report-pdf-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: .82rem;
}
.report-pdf-table th,
.report-pdf-table td {
    border: 1px solid #94a3b8;
    padding: .42rem .35rem;
    text-align: center;
    vertical-align: middle;
    word-break: break-word;
}
.report-pdf-table thead th {
    background: #f5e6c8;
    font-weight: 800;
}
.report-pdf-table tfoot td {
    background: #fef9c3;
    font-weight: 800;
}
.report-pdf-table .num {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.report-pdf-table .desc {
    text-align: right;
}
.report-pdf-table tr.is-draft td {
    color: #94a3b8;
    font-style: italic;
}
.report-pdf-table tr.is-deleted td {
    color: #64748b;
    text-decoration: line-through;
}
.payment-report {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.payment-report-landscape {
    display: none;
}
.payment-report-portrait .payment-report-table col.report-col-date { width: 22%; }
.payment-report-portrait .payment-report-table th:nth-child(1),
.payment-report-portrait .payment-report-table td:nth-child(1) { width: 22%; }
.payment-report-portrait .payment-report-table th:nth-child(2),
.payment-report-portrait .payment-report-table td:nth-child(2) { width: 20%; }
.payment-report-portrait .payment-report-table th:nth-child(3),
.payment-report-portrait .payment-report-table td:nth-child(3) { width: 20%; }
.payment-report-portrait .payment-report-table th:nth-child(4),
.payment-report-portrait .payment-report-table td:nth-child(4) { width: 38%; }
.purchase-report-table-portrait {
    min-width: 0;
    table-layout: fixed;
}
.purchase-report-table-portrait th:nth-child(1),
.purchase-report-table-portrait td:nth-child(1) { width: 30%; }
.purchase-report-table-portrait th:nth-child(2),
.purchase-report-table-portrait td:nth-child(2) { width: 40%; }
.purchase-report-table-portrait th:nth-child(3),
.purchase-report-table-portrait td:nth-child(3) { width: 30%; }
.purchase-report-table-portrait .report-head .report-type-select {
    width: 100%;
    max-width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 800;
    text-align: center;
    color: var(--sheet-ink);
    cursor: pointer;
    padding: 0;
}
.purchase-report-table-portrait .report-project-code {
    font-size: 1rem;
}
.purchase-report-table-portrait .report-project-label {
    font-size: .7rem;
}
.report-purchase-portrait-date {
    font-weight: 700;
    margin-bottom: .25rem;
}
.report-purchase-portrait-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .2rem;
    justify-content: center;
}
.report-summary-bar.is-purchase {
    display: flex;
    bottom: calc(68px + var(--safe-bottom));
}
.report-page:has(.report-summary-bar.is-purchase) {
    padding-bottom: calc(168px + var(--safe-bottom));
}
.report-page:has(.report-summary-bar.is-purchase.is-collapsed) {
    padding-bottom: calc(118px + var(--safe-bottom));
}
.payment-report-table {
    width: 100%;
    min-width: 320px;
    border-collapse: collapse;
    table-layout: fixed;
    background: #fff;
    border: 1.5px solid var(--sheet-line);
    font-size: .84rem;
}
.payment-report-table th,
.payment-report-table td {
    border: 1px solid #94a3b8;
    padding: .7rem .4rem;
    text-align: center;
    vertical-align: middle;
    word-break: break-word;
}
.payment-report-table .report-head th {
    background: #fde047;
    font-weight: 800;
    color: var(--sheet-ink);
    border-color: var(--sheet-line);
    padding: .55rem .4rem;
    line-height: 1.35;
    text-align: center;
    vertical-align: middle;
}
.payment-report-table .report-subhead th {
    background: #fff;
    font-weight: 700;
    border-color: var(--sheet-line);
    font-size: .74rem;
    padding: .65rem .55rem .75rem;
    min-height: 4.1rem;
    vertical-align: middle;
}
.report-head-block {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    width: 100%;
    min-height: 2.4rem;
    padding: 0 .45rem;
    box-sizing: border-box;
}
.report-head-block .report-type-select {
    width: calc(100% - .2rem);
    max-width: 100%;
    margin-inline: auto;
    box-sizing: border-box;
}
.payment-report-table .report-head-chevron {
    display: inline-block;
    font-size: .85rem;
    line-height: 1;
    color: var(--primary);
}
.report-currency-fixed {
    font-weight: 800;
}
.report-project-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .12rem;
    width: 100%;
    min-height: 2.4rem;
}
.report-project-code {
    direction: ltr;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.report-project-label {
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.report-currency-select {
    width: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 800;
    text-align: center;
    color: var(--sheet-ink);
    appearance: none;
    cursor: pointer;
    min-height: 2rem;
}
.payment-report-table tbody td {
    min-height: 3.6rem;
    height: auto;
    padding: .75rem .4rem;
    line-height: 1.45;
}
.payment-report-table tbody tr.empty-row td {
    min-height: 2.8rem;
    height: 2.8rem;
    padding: .5rem .4rem;
}
.payment-report-table tr.is-draft td {
    color: #94a3b8;
    font-style: italic;
}
.payment-report-table .num {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.payment-report-table .report-foot td {
    border-color: var(--sheet-line);
    font-weight: 800;
    background: #fff;
    padding: .55rem .35rem;
}
.payment-report-table .report-total-label {
    background: #fde047;
    text-align: center;
    font-size: .9rem;
}
.report-foot-stack {
    display: grid;
    gap: .2rem;
    justify-items: center;
}
.report-foot-stack .report-filter-caption {
    color: #64748b;
}
.report-desc-btn {
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    padding: .15rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.report-desc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 280;
    background: rgba(15, 23, 42, .5);
    padding: 1rem;
    align-items: center;
    justify-content: center;
}
.report-desc-overlay.open {
    display: flex;
}
.report-desc-panel {
    width: min(920px, 100%);
    max-height: min(88vh, 720px);
    background: #fff;
    border: 1.5px solid var(--sheet-line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 39, 68, .25);
}
.report-desc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .85rem 1rem;
    background: #f5e6c8;
    border-bottom: 1.5px solid var(--sheet-line);
}
.report-desc-head strong {
    font-size: 1.05rem;
}
.report-desc-close {
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--sheet-line);
    background: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}
.report-desc-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .55rem;
    padding: .85rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.report-desc-meta div {
    display: grid;
    gap: .15rem;
}
.report-desc-meta span {
    font-size: .72rem;
    color: #64748b;
    font-weight: 600;
}
.report-desc-meta strong {
    font-size: .92rem;
    color: var(--sheet-ink);
}
.report-desc-meta .num {
    direction: ltr;
}
.report-desc-body {
    flex: 1;
    overflow: auto;
    padding: 1.1rem 1.15rem 1.35rem;
}
.report-desc-body p {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.85;
    font-size: 1.05rem;
    color: var(--sheet-ink);
}
.report-desc-empty {
    color: #94a3b8 !important;
    text-align: center;
    padding: 2rem 1rem;
}

@media (orientation: landscape) {
    .report-desc-panel {
        max-height: 92vh;
        width: min(960px, 96vw);
    }
    .report-desc-body p {
        font-size: 1rem;
    }
}
.report-filter-select {
    width: calc(100% - 1.1rem);
    max-width: calc(100% - 1.1rem);
    margin-inline: auto;
    display: block;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-weight: 700;
    font-size: .78rem;
    text-align: center;
    color: #94a3b8;
    appearance: none;
    cursor: pointer;
    min-height: 2.15rem;
    padding: .35rem .3rem;
    line-height: 1.25;
    box-sizing: border-box;
}
.report-filter-select.has-value {
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 55%, #cbd5e1);
    background: color-mix(in srgb, var(--primary-soft, #e8f4fd) 70%, #fff);
}
.report-filter-stack {
    display: grid;
    gap: .28rem;
    justify-items: center;
    width: 100%;
    box-sizing: border-box;
    padding: 0 .55rem;
}
.report-filter-caption {
    font-size: .68rem;
    color: #64748b;
    font-weight: 700;
    letter-spacing: .01em;
}
.report-sort-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 8px;
    font: inherit;
    font-weight: 800;
    color: var(--sheet-ink);
    cursor: pointer;
    padding: .45rem .35rem;
    white-space: nowrap;
    min-height: 2.15rem;
    width: calc(100% - 1.1rem);
    max-width: calc(100% - 1.1rem);
    margin-inline: auto;
    display: block;
    box-sizing: border-box;
}
.report-sort-btn.is-active {
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 55%, #cbd5e1);
    background: color-mix(in srgb, var(--primary-soft, #e8f4fd) 70%, #fff);
}
.report-action-btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 8px;
    padding: .4rem .55rem;
    font: inherit;
    font-size: .74rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--sheet-ink);
    white-space: nowrap;
    min-height: 2rem;
    line-height: 1.2;
}
.report-action-btn:active {
    background: #e2e8f0;
}
.payment-report-table tr.is-edited td {
    background: #fecaca !important;
    color: #7f1d1d !important;
}
.payment-report-table tr.is-edited td .report-desc-btn,
.payment-report-table tr.is-edited td .report-method-hold,
.payment-report-table tr.is-edited td .report-date-hold,
.payment-report-table tr.is-edited td .report-pay-cell-btn {
    color: #7f1d1d !important;
}
.report-pdf-table tr.is-edited td {
    background: #fecaca;
    color: #7f1d1d;
}
.payment-report-table tr.is-deleted td {
    background: #cbd5e1 !important;
    color: #475569 !important;
}
.payment-report-table tr.is-deleted td:not(.report-actions-cell) {
    text-decoration: line-through;
}
.payment-report-table tr.is-deleted td.report-actions-cell,
.payment-report-table tr.is-deleted td.report-actions-cell * {
    text-decoration: none !important;
}
.payment-report-table tr.is-deleted td .report-desc-btn,
.payment-report-table tr.is-deleted td .report-method-hold {
    color: #475569 !important;
}
.report-restore-btn {
    background: #dbeafe !important;
    border-color: #93c5fd !important;
    color: #1d4ed8 !important;
    font-weight: 800 !important;
}
.report-party-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 3.2rem;
}
.report-party-name {
    font-weight: 700;
    font-size: .8rem;
    line-height: 1.35;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.report-party-actions,
.report-actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    justify-content: center;
    align-items: center;
}
.report-msg-btn {
    background: #dcfce7 !important;
    border-color: #86efac !important;
    color: #15803d !important;
}
.report-method-hold {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 700;
    color: inherit;
    cursor: pointer;
    width: 100%;
    max-width: 100%;
    padding: .15rem;
    display: grid;
    gap: .15rem;
    justify-items: center;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.report-method-name {
    line-height: 1.3;
    word-break: break-word;
}
.report-method-time {
    display: none;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-size: .72rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.report-method-hold.is-holding .report-method-time {
    display: block;
}
.report-method-hold.is-holding .report-method-name {
    color: var(--primary);
}
.report-date-hold {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 700;
    color: inherit;
    cursor: pointer;
    width: 100%;
    max-width: 100%;
    padding: .15rem;
    display: grid;
    gap: .15rem;
    justify-items: center;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.report-date-value {
    line-height: 1.3;
}
.report-date-time {
    display: none;
    direction: ltr;
    font-variant-numeric: tabular-nums;
    font-size: .72rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}
.report-date-hold.is-holding .report-date-time {
    display: block;
}
.report-date-hold.is-holding .report-date-value {
    color: var(--primary);
}
.report-pay-cell-btn {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-weight: 700;
    color: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.report-pay-toggle.is-active {
    background: #dbeafe;
    border-color: #93c5fd;
}
.report-side-dock {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(440px, 46vw);
    z-index: 270;
    padding: 0;
    background: transparent;
    pointer-events: none;
}
.report-side-dock.open {
    display: block;
}
.report-side-dock .report-desc-panel.is-dock {
    pointer-events: auto;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border-left: 1.5px solid var(--sheet-line);
    box-shadow: 8px 0 28px rgba(15, 39, 68, .18);
}
body.report-dock-open .payment-report-landscape,
body.report-dock-open .payment-report-portrait {
    margin-left: min(440px, 46vw);
}
.report-dock-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    padding: .75rem 1rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}
.report-media-body {
    flex: 1;
    overflow: auto;
    padding: .85rem 1rem 1rem;
    display: grid;
    gap: .75rem;
}
.report-media-item img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #e2e8f0;
    background: #fff;
}
.report-media-item audio {
    width: 100%;
}
.report-media-text {
    white-space: pre-wrap;
    line-height: 1.7;
    font-size: .95rem;
}
.report-pdf-table .desc {
    text-align: right;
    white-space: pre-wrap;
    word-break: break-word;
}
.report-pdf-zoom-hint {
    margin-top: .75rem;
    font-size: .85rem;
    color: #64748b;
    text-align: center;
}
@media (max-width: 900px) {
    .report-side-dock {
        inset: 0;
        width: 100%;
    }
    body.report-dock-open .payment-report-landscape,
    body.report-dock-open .payment-report-portrait {
        margin-left: 0;
    }
}
.report-delete-btn {
    background: #fee2e2 !important;
    border-color: #fecaca !important;
    color: #b91c1c !important;
}
.tx-item-edited {
    border-color: #fca5a5;
    background: #fef2f2;
}
.tx-item-deleted {
    border-color: #cbd5e1;
    background: #f1f5f9;
    opacity: .85;
}
.tx-item-deleted .tx-top,
.tx-item-deleted .tx-meta {
    color: #64748b;
    text-decoration: line-through;
}
.tx-item-deleted .tx-actions {
    text-decoration: none;
}

@media (orientation: landscape) {
    .payment-report-portrait { display: none; }
    .payment-report-landscape { display: block; }
    .report-page {
        padding: .35rem .4rem calc(148px + var(--safe-bottom));
    }
    .report-page:has(.report-summary-bar.is-collapsed) {
        padding-bottom: calc(108px + var(--safe-bottom));
    }
    .report-total-bar-portrait {
        display: none;
    }
    .report-summary-bar {
        display: flex;
        bottom: calc(68px + var(--safe-bottom));
    }
    .payment-report-table-landscape {
        min-width: 720px;
        font-size: .78rem;
    }
    .purchase-report-table-landscape {
        min-width: 1100px;
        font-size: .72rem;
    }
    .contract-report-table-landscape {
        min-width: 1180px;
        font-size: .7rem;
    }
    .contract-report-table-landscape.is-receive-open,
    .contract-report-table-landscape:has(.report-receive-detail) {
        min-width: 1480px;
    }
    .contract-report-table-landscape .report-sort-stack {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: .1rem;
        line-height: 1.15;
        white-space: normal;
    }
    .contract-report-table-landscape .report-sort-sub {
        display: block;
        font-size: .58rem;
        font-weight: 600;
        color: var(--sheet-muted, #64748b);
    }
    .contract-report-table-landscape .report-desc-td {
        position: relative;
        overflow: visible;
    }
    .contract-report-table-landscape .report-desc-hover {
        max-width: 5.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        transition: max-width .15s ease;
    }
    .contract-report-table-landscape .report-desc-hover:hover,
    .contract-report-table-landscape .report-desc-hover:focus {
        max-width: min(60vw, 18rem);
        white-space: normal;
        position: absolute;
        z-index: 8;
        inset-inline: 0;
        top: 50%;
        transform: translateY(-50%);
        background: #fffbeb;
        border: 1px solid #f59e0b;
        box-shadow: 0 6px 18px rgba(15, 23, 42, .14);
        padding: .35rem .45rem;
        border-radius: 6px;
    }
    .report-summary-bar.is-contract .report-summary-toggle {
        background: #fde047;
    }
    .report-summary-bar.is-contract .report-summary-dock {
        background: #fef9c3;
        border-color: #eab308;
    }
    .report-pay-cell-btn {
        border: 0;
        background: transparent;
        color: inherit;
        font: inherit;
        cursor: pointer;
        padding: .1rem .2rem;
        max-width: 100%;
    }
    .report-receive-toggle.is-open {
        color: #2563eb;
        font-weight: 800;
    }
    .purchase-report-table-landscape th,
    .purchase-report-table-landscape td {
        padding: .4rem .18rem;
    }
    .purchase-report-table-landscape .report-subhead th {
        font-size: .64rem;
        min-height: 3.1rem;
    }
    .purchase-report-table-landscape .report-head .report-type-select {
        width: auto;
        max-width: 100%;
        border: 0;
        background: transparent;
        font: inherit;
        font-weight: 800;
        text-align: center;
        color: var(--sheet-ink);
        cursor: pointer;
    }
    .payment-report-table-landscape th,
    .payment-report-table-landscape td {
        padding: .45rem .4rem;
    }
    .payment-report-table-landscape .report-head th {
        background: #fde047;
        font-size: .82rem;
        min-height: auto;
        padding: .4rem .4rem;
    }
    .payment-report-table-landscape .report-project-code {
        font-size: 1.05rem;
    }
    .payment-report-table-landscape .report-project-label {
        font-size: .68rem;
    }
    .payment-report-table-landscape .report-subhead th {
        font-size: .68rem;
        min-height: 3.4rem;
        padding: .5rem .45rem .6rem;
        background: #fff;
    }
    .payment-report-table-landscape .report-subhead .report-filter-stack {
        padding: 0 .45rem;
    }
    .payment-report-table-landscape .report-filter-select,
    .payment-report-table-landscape .report-sort-btn {
        width: calc(100% - 1.2rem);
        max-width: calc(100% - 1.2rem);
    }
    .payment-report-table-landscape tbody td {
        min-height: 2.9rem;
    }
    body:has(.payment-report-landscape) .bottom-nav {
        opacity: .92;
    }
}

/* —— راهنمای جذاب صفحه انتخاب پروژه —— */
.app-guide {
    margin: 0 0 1rem;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--border);
    background:
        radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 45%),
        radial-gradient(90% 70% at 0% 100%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 50%),
        var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
    animation: guide-in .45s ease both;
}
@keyframes guide-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}
.app-guide-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .95rem 1rem;
    text-align: right;
    font: inherit;
    color: var(--text);
    cursor: pointer;
}
.app-guide-toggle-main {
    display: grid;
    gap: .2rem;
    min-width: 0;
}
.app-guide-badge {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
}
.app-guide-toggle-main strong {
    font-size: .98rem;
    font-weight: 800;
    color: var(--text);
}
.app-guide-toggle-main small {
    color: var(--muted);
    font-size: .78rem;
}
.app-guide-chevron {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 16%, transparent);
    position: relative;
    flex-shrink: 0;
    transition: transform .25s ease, background .2s ease;
}
.app-guide-chevron::before {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: translateY(-2px) rotate(45deg);
}
.app-guide.is-collapsed .app-guide-chevron {
    transform: rotate(-90deg);
    background: color-mix(in srgb, var(--muted) 22%, transparent);
}
.app-guide-body {
    padding: 0 1rem 1rem;
}
.app-guide-track {
    position: relative;
    min-height: 168px;
    touch-action: pan-y;
}
.app-guide-slide {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: .85rem;
    align-items: center;
    opacity: 0;
    transform: translateX(-12px) scale(.98);
    pointer-events: none;
    transition: opacity .35s ease, transform .35s ease;
}
.app-guide-slide.active {
    opacity: 1;
    transform: none;
    pointer-events: auto;
    position: relative;
}
.app-guide-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: linear-gradient(145deg, var(--surface), var(--primary-soft));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
    animation: guide-icon-float 3.6s ease-in-out infinite;
}
.app-guide-icon svg { width: 48px; height: 48px; }
.app-guide-slide[data-tone="teal"] .app-guide-icon {
    color: #2dd4bf;
    background: linear-gradient(145deg, var(--surface), color-mix(in srgb, #14b8a6 28%, var(--card)));
}
.app-guide-slide[data-tone="amber"] .app-guide-icon {
    color: #fbbf24;
    background: linear-gradient(145deg, var(--surface), color-mix(in srgb, #f59e0b 28%, var(--card)));
}
.app-guide-slide[data-tone="violet"] .app-guide-icon {
    color: #c4b5fd;
    background: linear-gradient(145deg, var(--surface), color-mix(in srgb, #8b5cf6 28%, var(--card)));
}
@keyframes guide-icon-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
.app-guide-copy { min-width: 0; color: var(--text); }
.app-guide-step-label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: .25rem;
}
.app-guide-copy h3 {
    font-size: .98rem;
    font-weight: 800;
    margin: 0 0 .35rem;
    line-height: 1.35;
    color: var(--text);
}
.app-guide-copy p {
    margin: 0 0 .55rem;
    font-size: .84rem;
    line-height: 1.7;
    color: var(--muted);
}
.app-guide-tip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .28rem .65rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .74rem;
    font-weight: 700;
}
.app-guide-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: .85rem;
}
.app-guide-nav {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--primary);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.app-guide-nav:active { transform: scale(.96); }
.app-guide-dots {
    display: flex;
    gap: .4rem;
    align-items: center;
    justify-content: center;
}
.app-guide-dot {
    width: 7px;
    height: 7px;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 55%, transparent);
    padding: 0;
    cursor: pointer;
    transition: width .25s ease, background .25s ease;
}
.app-guide-dot.active {
    width: 18px;
    background: var(--primary);
}
@media (prefers-reduced-motion: reduce) {
    .app-guide,
    .app-guide-slide,
    .app-guide-icon,
    .app-guide-chevron,
    .app-guide-dot {
        animation: none !important;
        transition: none !important;
    }
}

/* —— راهنمای نگه‌داشتن انگشت —— */
.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + var(--safe-bottom, 0px));
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: help-fade-in .2s ease;
}
.help-overlay.hidden { display: none; }
@keyframes help-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.help-card {
    width: min(100%, 22rem);
    background: var(--card);
    color: var(--text);
    border-radius: 18px;
    padding: 1.25rem 1.15rem 1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .35);
    border: 1px solid var(--border);
    text-align: center;
    animation: help-card-in .28s cubic-bezier(.2, .9, .2, 1);
}
@keyframes help-card-in {
    from { opacity: 0; transform: translateY(16px) scale(.96); }
    to { opacity: 1; transform: none; }
}
.help-card-icon {
    font-size: 1.75rem;
    line-height: 1;
    margin-bottom: .55rem;
}
.help-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .45rem;
}
.help-card-body {
    font-size: .92rem;
    line-height: 1.7;
    color: var(--muted);
    margin-bottom: .85rem;
}
.help-card-hint {
    font-size: .75rem;
    color: var(--muted);
    margin: 0 0 .9rem;
    line-height: 1.5;
    opacity: .9;
}
.help-card-ok {
    margin-top: .15rem;
}
.help-target-glow {
    outline: 2px solid color-mix(in srgb, var(--primary, #1565a8) 75%, #fff) !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary, #1565a8) 22%, transparent) !important;
    border-radius: 10px;
    transition: outline .15s ease, box-shadow .15s ease;
}
@media (prefers-reduced-motion: reduce) {
    .help-overlay,
    .help-card {
        animation: none !important;
    }
}


/* Contract total fields — muted grey (readonly totals) */
.sheet-items-contract .sheet-total-row .sheet-input {
    color: #64748b;
    background: #f1f5f9;
}
.sheet-items-contract .sheet-total-row .sheet-unit-cell {
    color: #64748b;
    background: #e2e8f0;
}

/* Income sheet mirrors payment */
.entry-sheet-income .sheet-amount-payment .sheet-label {
    font-weight: 700;
}

/* Payment / income portrait: 3 columns */
.payment-report-portrait:not(.purchase-report-portrait) .payment-report-table th:nth-child(1),
.payment-report-portrait:not(.purchase-report-portrait) .payment-report-table td:nth-child(1) { width: 28%; }
.payment-report-portrait:not(.purchase-report-portrait) .payment-report-table th:nth-child(2),
.payment-report-portrait:not(.purchase-report-portrait) .payment-report-table td:nth-child(2) { width: 28%; }
.payment-report-portrait:not(.purchase-report-portrait) .payment-report-table th:nth-child(3),
.payment-report-portrait:not(.purchase-report-portrait) .payment-report-table td:nth-child(3) { width: 44%; }

/* —— Feedback 1405-5-10: floating labels stay visible —— */
.sheet-field,
.float-field {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-width: 0;
    flex: 1;
    min-height: 3.1rem;
}
.sheet-row.sheet-select-row > .sheet-field,
.sheet-row.sheet-select-row > .float-field {
    flex: 1;
}
.sheet-row.sheet-qty-row > .sheet-field,
.sheet-row.sheet-price-row > .sheet-field,
.sheet-row.sheet-total-row > .sheet-field,
.sheet-row.sheet-invoice-total > .sheet-field,
.sheet-row.sheet-qty-row > .float-field,
.sheet-row.sheet-price-row > .float-field,
.sheet-row.sheet-total-row > .float-field,
.sheet-row.sheet-invoice-total > .float-field {
    flex: 1 1 auto;
}
.sheet-field-label,
.float-label {
    position: absolute;
    right: .7rem;
    left: .7rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .95rem;
    font-weight: 600;
    color: var(--sheet-placeholder);
    line-height: 1.2;
    padding: 0;
    margin: 0;
    pointer-events: none;
    z-index: 1;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: top .16s ease, font-size .16s ease, transform .16s ease, color .16s ease, opacity .16s ease;
}
.sheet-field.is-filled .sheet-field-label,
.sheet-field.is-focused .sheet-field-label,
.sheet-field:focus-within .sheet-field-label,
.float-field.is-filled .float-label,
.float-field.is-focused .float-label,
.float-field:focus-within .float-label,
.sheet-field.is-filled .float-label,
.sheet-field.is-focused .float-label,
.sheet-field:focus-within .float-label {
    top: .22rem;
    transform: none;
    font-size: .68rem;
    font-weight: 700;
    color: var(--sheet-muted);
}
.sheet-field-label .req-mark,
.float-label .req-mark {
    color: var(--danger);
    font-style: normal;
    margin-right: .15rem;
}
.sheet-row .sheet-field .sheet-input,
.sheet-row .sheet-field .sheet-select,
.sheet-row .float-field .sheet-input,
.sheet-row .float-field .sheet-select,
.float-field > .sheet-input,
.float-field > .sheet-select,
.chat-edit-form .float-field input,
.chat-edit-form .float-field select,
.chat-edit-form .float-field textarea {
    width: 100%;
    position: relative;
    z-index: 0;
    padding-top: 1.2rem !important;
    padding-bottom: .35rem !important;
}
.sheet-field .sheet-input::placeholder,
.sheet-field .sheet-select::placeholder,
.float-field .sheet-input::placeholder,
.float-field input::placeholder,
.float-field textarea::placeholder {
    color: transparent !important;
    opacity: 0 !important;
}
.sheet-cell-label.is-floated-away {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.sheet-cell:has(> .float-field) {
    position: relative;
}
.sheet-amount .float-field {
    min-height: 3.2rem;
}
.sheet-amount .float-field .sheet-amount-input {
    text-align: center;
}
.sheet-amount .float-field .float-label {
    text-align: center;
    right: .5rem;
    left: .5rem;
}
.sheet-subject-row .float-field,
.sheet-subject-row .sheet-field {
    min-height: 48px;
}
.float-field:has(.sheet-center) .float-label,
.sheet-field:has(.sheet-center) .float-label,
.sheet-field:has(.sheet-center) .sheet-field-label {
    text-align: center;
}
.float-field.is-empty > select.sheet-select,
.sheet-field.is-empty > select.sheet-select {
    color: transparent;
}
.float-field.is-filled > select.sheet-select,
.float-field.is-focused > select.sheet-select,
.sheet-field.is-filled > select.sheet-select,
.sheet-field.is-focused > select.sheet-select,
.float-field:focus-within > select.sheet-select,
.sheet-field:focus-within > select.sheet-select {
    color: var(--sheet-ink);
}
.float-field > select.sheet-select option,
.sheet-field > select.sheet-select option {
    color: var(--sheet-ink);
}
/* Dual chevrons (report + list) — must override absolute .sheet-select-row .sheet-chevron */
.party-actions {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    align-self: stretch;
    position: relative;
    z-index: 2;
    border-right: 1.5px solid var(--sheet-line);
}
.party-actions .sheet-chevron {
    position: static !important;
    left: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none !important;
    border: 0;
    border-left: 1px solid var(--sheet-line);
    min-width: 2.35rem;
    width: 2.35rem;
    height: auto;
    cursor: pointer;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
}
.party-actions .sheet-chevron:first-child {
    border-left: 0;
}
.party-report-btn {
    color: var(--sheet-accent);
    font-weight: 800;
}
.party-list-btn.is-open,
.party-report-btn.is-open {
    background: var(--sheet-accent-soft);
}
.party-extra-link {
    display: block;
    width: 100%;
    border: 0;
    border-top: 1px dashed color-mix(in srgb, var(--sheet-line) 80%, transparent);
    background: transparent;
    color: #64748b;
    font-size: .78rem;
    text-align: center;
    padding: .4rem .75rem;
    cursor: pointer;
}
.party-extra-link.is-open {
    color: var(--sheet-accent);
    font-weight: 600;
    background: var(--sheet-panel);
}
.counterparty-picker-search-row {
    border-bottom: 1.5px solid var(--sheet-line) !important;
}
.counterparty-picker-item.is-selected {
    background: var(--sheet-accent-soft);
    border-color: var(--sheet-accent);
}

/* Linked panels as distinct modal windows */
.linked-purchase-dialog,
.linked-payment-panel {
    border: 2px solid var(--sheet-accent);
    box-shadow: 0 12px 36px rgba(37, 99, 235, .18);
    background: #f8fbff;
}
.linked-payment-panel {
    margin-top: .35rem;
    border-radius: 14px;
    padding: .65rem .55rem;
}
.linked-payment-panel.linked-receive-panel {
    border-color: #16a34a;
    background: #f3fdf6;
    box-shadow: 0 12px 36px rgba(22, 163, 74, .14);
}
.linked-purchase-modal.open .linked-purchase-dialog {
    animation: linked-modal-in .22s ease;
}
@keyframes linked-modal-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: none; }
}
.linked-purchase-fields {
    max-height: min(62vh, 520px);
    overflow: auto;
}
.linked-purchase-dialog .sheet-row.linked-field-row .sheet-chevron:not(.linked-item-report-btn) {
    display: none;
}
.linked-payment-panel .sheet-amount .sheet-chevron {
    display: none;
}

/* Narrower unit/price cells like description */
.sheet-qty-row .sheet-unit-cell,
.sheet-price-row .sheet-unit-cell {
    min-width: 4.5rem;
    max-width: 5.5rem;
}
.sheet-qty-row .sheet-input,
.sheet-price-row .sheet-input,
.sheet-total-row .sheet-input {
    flex: 1 1 auto;
}

/* Item block (قلم ۲) visually separated */
.sheet-item-block + .sheet-item-block {
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 2px dashed color-mix(in srgb, var(--sheet-accent) 35%, var(--border));
}
.sheet-item-toolbar {
    background: var(--sheet-accent-soft);
    border-radius: 10px;
    padding: .35rem .55rem;
    margin-bottom: .35rem;
}

/* Amount with thousand separators */
input.amount-sep,
.sheet-amount-input[inputmode="decimal"],
.item-price.amount-sep,
.item-total.amount-sep,
.item-total-progress.amount-sep,
#linked-payment-amount.amount-sep,
.linked-payment-panel .lp-amount.amount-sep,
#linked-unit-price.amount-sep,
#linked-total.amount-sep,
#linked-sale-unit-price.amount-sep,
#linked-sale-total.amount-sep,
#purchase-invoice-total.amount-sep {
    direction: ltr;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Non-registry time highlight in reports */
.report-time-custom {
    color: #b45309;
    font-weight: 700;
    background: #fef3c7;
    border-radius: 6px;
    padding: .05rem .3rem;
}

/* Sticky frozen report header */
.payment-report-landscape .payment-report-table thead th,
.payment-report-portrait .payment-report-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--sheet-head);
}
.report-filter-row th {
    position: sticky;
    top: 2.4rem;
    z-index: 2;
    background: #fff8e7;
}

/* PDF preview modal */
.report-preview-backdrop {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.report-preview-modal {
    width: min(960px, 100%);
    max-height: min(90vh, 900px);
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.report-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.report-preview-actions {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
}
.report-preview-body {
    overflow: auto;
    padding: 1rem;
    background: #f8fafc;
    -webkit-overflow-scrolling: touch;
}
.report-preview-body .report-pdf-document {
    background: #fff;
    margin: 0 auto;
}

/* Media: camera + gallery */
.sheet-media-photo-actions {
    display: flex;
    gap: .35rem;
    width: 100%;
}
.sheet-media-photo-actions .sheet-media-btn {
    flex: 1;
    text-align: center;
    font-size: .78rem;
    padding: .55rem .35rem;
}

/* Counterparty report / list active */
.counterparty-report-btn.is-open,
.party-list-btn.is-open,
.party-expand-btn.is-open {
    background: var(--sheet-accent-soft);
}

/* Wide report incomplete fix */
@media (min-width: 900px) {
    .payment-report-landscape {
        overflow-x: auto;
    }
    .payment-report-landscape .payment-report-table {
        min-width: 1100px;
    }
}
