:root {
    --bg:        #f1f1f4;
    --surface:   #ffffff;
    --surface-2: #f6f6f9;
    --text:      #14161c;
    --text-2:    #8a8f98;
    --text-3:    #b6bac2;
    --separator: rgba(20, 22, 28, 0.06);
    --accent:    var(--tg-theme-button-color, #2c7dfa);
    --accent-2:  var(--tg-theme-button-text-color, #ffffff);

    --shadow-card: 0 1px 2px rgba(20, 22, 28, 0.04), 0 8px 24px rgba(20, 22, 28, 0.05);
    --shadow-soft: 0 2px 6px rgba(20, 22, 28, 0.05);

    --pending:    #e8506e;    --pending-bg:    #fde6ea;
    --approved:   #1bb673;    --approved-bg:   #def6e9;
    --assembly:   #2c7dfa;    --assembly-bg:   #dfecff;
    --transit:    #f29030;    --transit-bg:    #ffe7cd;
    --pickup:     #d9a400;    --pickup-bg:     #fff0b8;
    --arrival:    #8a5cf2;    --arrival-bg:    #ebe1ff;
    --release:    #0d9488;    --release-bg:    #cef5f0;
    --done:       #8a8f98;    --done-bg:       #ebecef;
    --cancelled:  #d63548;    --cancelled-bg:  #fde0e3;

    --r-pill:  999px;
    --r-card:  22px;
    --r-md:    16px;
    --r-sm:    12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
}

button { font-family: inherit; }

#app {
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}

.screen { display: none; }
.screen.active {
    display: block;
    animation: fadeUp 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ Page header ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(16px + env(safe-area-inset-top)) 20px 12px;
}

.page-title {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--text);
}

/* Main screen header variant */
.main-header { align-items: flex-start; }

/* History screen header */
.history-header {
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
}

.history-title { font-size: 26px; }

.back-btn svg { width: 14px; height: 14px; }

.header-text { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Active stat — minimal inline line */
.active-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: -0.005em;
}

.active-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--approved);
    flex-shrink: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--approved) 16%, transparent);
    animation: activePulse 2.6s ease-in-out infinite;
    margin-right: 1px;
}

@keyframes activePulse {
    0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--approved) 14%, transparent); }
    50%      { box-shadow: 0 0 0 5px color-mix(in srgb, var(--approved) 22%, transparent); }
}

.active-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}

.active-divider {
    color: var(--text-3);
    font-weight: 400;
}

.active-amount {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: -0.005em;
}

/* QR box in header */
.qr-box {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    padding: 8px;
    background: var(--surface);
    border: none;
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.18s ease;
    position: relative;
    overflow: hidden;
}

.qr-box::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--accent) 8%, transparent),
        color-mix(in srgb, var(--arrival) 6%, transparent));
    pointer-events: none;
    z-index: 0;
}

.qr-box:active { transform: scale(0.96); }

.qr-box svg, .qr-box img {
    width: 100% !important;
    height: 100% !important;
    display: block;
    position: relative;
    z-index: 1;
}

/* QR overlay */
.qr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.55);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.qr-overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.qr-overlay-card {
    background: var(--surface);
    border-radius: 28px;
    padding: 24px 24px 22px;
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
    animation: scaleUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}

.qr-overlay-big {
    width: 240px;
    height: 240px;
    padding: 12px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

.qr-overlay-big svg, .qr-overlay-big img {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.qr-overlay-info { text-align: center; }

.qr-overlay-name {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.qr-overlay-hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
}

.filter-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--surface);
    color: var(--text);
    border: none;
    border-radius: var(--r-pill);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: transform 0.1s ease;
}

.filter-button:active { transform: scale(0.97); }

.filter-button svg { width: 16px; height: 16px; }

.filter-indicator {
    display: none;
    position: absolute;
    top: 7px;
    right: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pending);
    border: 2px solid var(--surface);
}

.filter-indicator.visible { display: block; }

/* ============ Bottom CTA ============ */
.bottom-cta {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 55%, color-mix(in srgb, var(--bg) 70%, transparent) 85%, transparent);
    pointer-events: none;
    z-index: 20;
}

.bottom-cta .btn-pill { pointer-events: auto; }

.btn-pill {
    display: block;
    width: 100%;
    padding: 17px 24px;
    background: var(--accent);
    color: var(--accent-2);
    border: none;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 32%, transparent);
    transition: transform 0.1s ease;
}

.btn-pill:active { transform: scale(0.985); }

.orders-list.with-cta { padding-bottom: 120px; }

/* ============ Orders list ============ */
.orders-list {
    padding: 14px 14px 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 50vh;
}

.order-card {
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: box-shadow 0.18s ease, transform 0.1s ease;
}

.order-card.expanded { box-shadow: 0 2px 4px rgba(20, 22, 28, 0.04), 0 16px 36px rgba(20, 22, 28, 0.08); }

.card-head {
    padding: 16px 18px 6px;
    cursor: pointer;
}

.card-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.card-date { letter-spacing: -0.005em; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: var(--r-pill);
    font-size: 12.5px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.pill.type { background: var(--surface-2); color: var(--text); }

/* Status pills — neutral background, small colored dot via ::before */
.pill.status {
    background: var(--surface-2);
    color: var(--text-2);
    padding-left: 9px;
}

.pill.status::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-right: 7px;
    background: var(--text-3);
    vertical-align: 1px;
}

.pill.status[data-status="не согласован"]::before        { background: var(--pending); }
.pill.status[data-status="согласован"]::before           { background: var(--approved); }
.pill.status[data-status="не завершён"]::before          { background: var(--text-3); }
.pill.status[data-status="ожидает товар"]::before        { background: var(--release); }
.pill.status[data-status="ожидает поступления"]::before  { background: var(--arrival); }
.pill.status[data-status="задерживается"]::before        { background: var(--transit); }
.pill.status[data-status="сборка"]::before               { background: var(--assembly); }
.pill.status[data-status="ожидает выдачи"]::before       { background: var(--pickup); }
.pill.status[data-status="выдан"]::before                { background: var(--done); }

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

.card-number {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.025em;
}

.card-number .type-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.card-number .type-icon svg { width: 22px; height: 22px; }

.card-total {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.025em;
    white-space: nowrap;
}

/* Toggle row */
.card-toggle {
    border-top: 1px solid var(--separator);
    padding: 13px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.card-toggle:active { background: var(--surface-2); }

.card-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.order-card.expanded .card-toggle svg { transform: rotate(180deg); }

/* Expanded body */
.card-body {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.order-card.expanded .card-body { max-height: 2000px; }

.card-body-inner { padding: 4px 18px 6px; }

/* Status timeline */
.timeline {
    display: flex;
    align-items: center;
    margin: 8px 0 18px;
    padding: 4px 2px;
}

/* Minimal mini-stepper — dots + focal current stage */
.timeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 16px 0 6px;
    padding: 0 16px;
}

.timeline-dots {
    display: inline-flex;
    align-items: center;
    gap: 0;
    min-height: 28px;
}

.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--separator);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    color: transparent;
}

.timeline-line {
    width: 24px;
    height: 2px;
    background: var(--separator);
    border-radius: 1px;
    margin: 0 6px;
    transition: background 0.28s ease;
}
.timeline-line.done { background: var(--approved); }

.timeline-dot.done {
    background: var(--approved);
    width: 10px;
    height: 10px;
}

.timeline-dot.active {
    width: 26px;
    height: 26px;
    background: var(--accent);
    color: #ffffff;
    box-shadow:
        0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent),
        0 4px 12px color-mix(in srgb, var(--accent) 32%, transparent);
}

.timeline-dot.active svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
}

.timeline-dot.failed {
    width: 26px;
    height: 26px;
    background: var(--pending);
    color: #ffffff;
    box-shadow:
        0 0 0 4px color-mix(in srgb, var(--pending) 14%, transparent),
        0 4px 12px color-mix(in srgb, var(--pending) 32%, transparent);
}

.timeline-dot.failed svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
}

.timeline-now {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
}

.timeline-now-kicker {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.timeline-now-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.025em;
    line-height: 1.1;
}

.timeline-now-name.failed { color: var(--pending); }
.timeline-now-name.done   { color: var(--approved); }

.timeline-now-step {
    font-size: 11px;
    color: var(--text-2);
    font-weight: 500;
    margin-top: 1px;
}

/* Items */
.items-list {
    list-style: none;
    margin: 0;
    padding: 4px 0 8px;
    counter-reset: items;
}

.item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    counter-increment: items;
}

.item-num {
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
    width: 18px;
}

.item-num::before { content: counter(items) "."; }

.item-flag {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}

.item-body { flex: 1; min-width: 0; }

.item-title {
    margin: 0 0 2px;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.item-calc {
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
}

.item-arrival {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    padding: 3px 9px;
    background: var(--arrival-bg);
    color: var(--arrival);
    border-radius: 10px;
    font-size: 11.5px;
    font-weight: 700;
}

.item-arrival svg { width: 11px; height: 11px; }

/* Combo pill: type + arrival in one connected pill */
.pill.type.combo {
    padding: 0;
    background: transparent;
    border-radius: 999px;
    overflow: hidden;
    display: inline-flex;
    align-items: stretch;
    box-shadow: 0 1px 2px rgba(20, 22, 28, 0.05);
    isolation: isolate;
}

.combo-main {
    padding: 5px 11px;
    background: var(--surface-2);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    font-weight: 600;
}

.combo-arrival {
    --combo-color: var(--arrival);
    padding: 5px 11px 5px 10px;
    background: var(--surface-2);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    position: relative;
}

.combo.release .combo-arrival  { --combo-color: var(--release); }
.combo.preorder .combo-arrival { --combo-color: var(--arrival); }

.combo-arrival::before {
    content: "";
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 1px;
    background: var(--separator);
}

.combo-arrival svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: var(--combo-color);
}

/* Action row inside card */
.card-action {
    border-top: 1px solid var(--separator);
    padding: 13px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.card-action:active { background: var(--surface-2); }

.card-action svg { width: 15px; height: 15px; }

/* ============ Empty / loading ============ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 72px 24px;
    text-align: center;
    color: var(--text-2);
}

.empty-illustration {
    width: 88px;
    height: 88px;
    margin-bottom: 18px;
    border-radius: 26px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
}

.empty-illustration svg { width: 38px; height: 38px; color: var(--text-3); }

.empty-state-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.empty-state-text {
    margin: 0;
    font-size: 14px;
    max-width: 280px;
    line-height: 1.45;
}

.loader { display: flex; justify-content: center; padding: 100px 0; }

.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--separator);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Filters screen ============ */
.filters-body {
    padding: 4px 20px 120px;
}

.filter-section { padding: 20px 0; border-bottom: 1px solid var(--separator); }
.filter-section:last-of-type { border-bottom: none; }

.filter-section-title {
    margin: 0 0 14px;
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.filter-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 0;
    cursor: pointer;
    user-select: none;
}

.filter-option-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}

.radio {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--text-3);
    background: transparent;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.filter-option.checked .radio {
    border-color: var(--text);
    background: var(--text);
}

.filter-option.checked .radio::after {
    content: "";
    position: absolute;
    inset: 4px;
    background: var(--surface);
    border-radius: 50%;
}

.filter-more {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.filter-more svg { width: 14px; height: 14px; transition: transform 0.2s ease; }
.filter-more.open svg { transform: rotate(180deg); }

.range-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 4px;
}

.range-field { display: flex; flex-direction: column; gap: 6px; }

.range-label {
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
    padding-left: 16px;
}

.range-input {
    background: var(--surface);
    border: none;
    box-shadow: var(--shadow-soft);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-family: inherit;
    outline: none;
    transition: box-shadow 0.15s ease;
    width: 100%;
}

.range-input:focus { box-shadow: 0 0 0 2px var(--accent), var(--shadow-soft); }

.filters-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
    display: flex;
    gap: 10px;
}

.btn-primary, .btn-secondary {
    flex: 1;
    border: none;
    border-radius: 16px;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn-primary { background: var(--accent); color: var(--accent-2); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 32%, transparent); }
.btn-secondary { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }

.btn-primary:active, .btn-secondary:active { transform: scale(0.985); }

/* ============ Invoice screen ============ */
.invoice-body { padding: 12px 16px 40px; }

.invoice {
    background: var(--surface);
    border-radius: 22px;
    padding: 26px 22px 22px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.invoice::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--arrival));
}

.invoice-head {
    text-align: center;
    padding: 4px 0 22px;
    border-bottom: 1px dashed var(--separator);
}

.invoice-kicker {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.invoice-number {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

.invoice-date {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
}

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 18px 0;
    border-bottom: 1px dashed var(--separator);
}

.invoice-party {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.invoice-party-label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.invoice-party-value {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.015em;
    word-break: break-word;
}

.invoice-party-extra {
    font-size: 12.5px;
    color: var(--text-2);
    font-weight: 500;
}

.invoice-section {
    padding: 18px 0 4px;
}

.invoice-section-title {
    margin: 0 0 12px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.invoice-item {
    display: flex;
    gap: 10px;
    padding: 11px 0;
    border-bottom: 1px solid var(--separator);
    align-items: flex-start;
}

.invoice-item:last-of-type { border-bottom: none; }

.invoice-item-num {
    color: var(--text-3);
    font-size: 13px;
    font-weight: 600;
    width: 18px;
    flex-shrink: 0;
}

.invoice-item-body { flex: 1; min-width: 0; }

.invoice-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 3px;
    letter-spacing: -0.01em;
}

.invoice-item-calc {
    font-size: 12px;
    color: var(--text-2);
    font-weight: 500;
}

.invoice-item-sum {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.invoice-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 18px;
    padding: 18px 16px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, var(--surface-2)), var(--surface-2));
    border-radius: 14px;
}

.invoice-total-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.invoice-total-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.invoice-footer {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed var(--separator);
    text-align: center;
    font-size: 11px;
    color: var(--text-3);
    line-height: 1.5;
    font-weight: 500;
}

.invoice-item-flag {
    font-size: 14px;
    margin-right: 3px;
}

/* Invoice screen action button (Save as photo) */
.invoice-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
    z-index: 20;
}

.invoice-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.invoice-actions .btn-primary svg {
    width: 18px;
    height: 18px;
}

/* Extra bottom padding so save button doesn't cover invoice */
.invoice-body { padding-bottom: 100px; }

/* Month section header */
.month-divider {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 10px 6px 2px;
}

/* ===== Оверлей «Сохранить как фото» (фолбэк для Telegram) ===== */
.img-save-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.img-save-overlay[hidden] { display: none; }
.img-save-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    max-height: 100%;
}
.img-save-pic {
    max-width: 100%;
    max-height: 74vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    -webkit-touch-callout: default;
    touch-action: auto;
}
.img-save-hint {
    margin: 0;
    color: #fff;
    font-size: 14px;
    text-align: center;
    opacity: 0.92;
}
.img-save-close { min-width: 180px; }
