:root {
    --color-yellow: #d9b23c;
    --color-green: #7fa93f;
    --color-red: #c0453e;
    --color-header-bg: #b9b9b9;
    --color-text-dark: #1c1c1c;
}

html, body {
    height: 100%;
}

.app-body {
    background: #ffffff;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
}

.terminal-screen {
    min-height: 100vh;
}

/* ---------- header ---------- */
.app-header {
    background: var(--color-header-bg);
    color: #fff;
    padding: 0.6rem 0.9rem;
}

.app-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
}

.user-name {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.1;
}

.user-fullname {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.95;
    line-height: 1.1;
}

.store-block {
    font-size: 0.85rem;
    line-height: 1.2;
}

.store-label {
    opacity: 0.9;
}

.store-name {
    font-weight: 600;
}

/* ---------- menu ---------- */
.menu-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 3px 0 0 0;
}

.menu-btn {
    display: flex;
    align-items: center;
    width: 100%;
    border: none;
    text-align: left;
    padding: 0.9rem 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text-dark);
    text-decoration: none;
    cursor: pointer;
}

.menu-btn:hover,
.menu-btn:focus {
    color: var(--color-text-dark);
    filter: brightness(1.05);
}

.menu-btn:active {
    filter: brightness(0.92);
}

.menu-btn.btn-warning { background: var(--color-yellow); }
.menu-btn.btn-success { background: var(--color-green); }
.menu-btn.btn-danger  { background: var(--color-red); }

/* ---------- footer / exit ---------- */
.app-footer {
    padding: 1.5rem 0 2rem 0;
}

.btn-exit {
    background: #fff;
    border: 2px solid var(--color-red);
    color: var(--color-red);
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
    padding: 0.35rem 1.4rem;
    border-radius: 3px;
}

.btn-exit.is-pressed,
.btn-exit:active {
    background: var(--color-red);
    color: #fff;
}

/* ---------- stub pages ---------- */
.stub-header {
    padding: 0.7rem 0.9rem;
}

.back-link {
    width: 34px;
    height: 34px;
    color: #fff;
    text-decoration: none;
    flex-shrink: 0;
}

.stub-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.stub-body {
    background: #fafafa;
}

.stub-placeholder-icon {
    font-size: 2rem;
    letter-spacing: 0.2em;
    color: #b0b0b0;
}

/* ---------- price-check page ---------- */
.header-home-link {
    color: #fff;
    text-decoration: none;
}

.price-check-screen {
    position: relative;
}

.price-check-body {
    background: #fff;
    position: relative;
}

/* переключатель "расширенная информация" — чекбокс визуально скрыт,
   вид переключателя рисуется псевдоэлементами на label (без JS),
   управляет видимостью .extra-info-* через :checked ~ */
#extra-info-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.extra-toggle-row {
    position: relative;
    display: block;
    padding: 0.55rem 0.9rem 0.55rem 3.4rem;
    margin: 0;
    font-size: 0.85rem;
    color: #555;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    user-select: none;
    min-height: 2.1rem;
    line-height: 2.1rem;
}

.extra-toggle-row::before {
    content: "";
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 1.15rem;
    border-radius: 1rem;
    background: #c7c7c7;
    transition: background 0.15s;
}

.extra-toggle-row::after {
    content: "";
    position: absolute;
    left: 1.05rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    transition: left 0.15s;
}

#extra-info-toggle:checked ~ .extra-toggle-row::before {
    background: #0d6efd;
}

#extra-info-toggle:checked ~ .extra-toggle-row::after {
    left: 1.8rem;
}

.extra-info-inline { display: none; }
.extra-info-block { display: none; }

#extra-info-toggle:checked ~ #scan-result .extra-info-inline { display: inline; }
#extra-info-toggle:checked ~ #scan-result .extra-info-block { display: block; }

/* небольшая кнопка сброса результата приёмки, над списком товаров */
.btn-reset-receiving {
    display: block;
    margin: 0.6rem 0.9rem 0;
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    color: var(--color-red);
    background: #fff;
    border: 1px solid var(--color-red);
    border-radius: 4px;
    text-align: left;
}

.btn-reset-receiving:active {
    background: #fdecea;
}

/* временная dev-кнопка */
.btn-dev-scan {
    margin: 0.6rem 0.9rem 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.78rem;
    color: #8a6d00;
    background: #fff8e1;
    border: 1px dashed #d9b23c;
    border-radius: 4px;
    text-align: left;
}

.scan-placeholder {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #a9a9a9;
    font-size: 1.15rem;
    line-height: 1.4;
    padding: 2rem 1.5rem;
}

.scan-card {
    padding: 1.1rem 0.9rem 1.4rem;
}

.scan-card-title {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
}

.scan-product-name {
    text-align: center;
    font-size: 1rem;
    margin-bottom: 1.1rem;
}

.scan-price-block {
    text-align: center;
    margin-bottom: 0.9rem;
}

.scan-price-label {
    font-weight: 700;
    font-size: 1rem;
}

.scan-price-value {
    color: #c0392b;
    font-size: 2.7rem;
    font-weight: 800;
    line-height: 1.15;
}

.scan-details {
    font-size: 0.92rem;
    margin-bottom: 1.3rem;
}

.scan-details > div {
    margin-bottom: 0.3rem;
}

.btn-add-to-list {
    display: block;
    width: 100%;
    background: #e9e9e9;
    border: none;
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    color: #1c1c1c;
}

.btn-add-to-list:active {
    background: #dcdcdc;
}

.btn-add-to-list-done {
    background: #cdead6 !important;
    color: #1e7a3a;
}

.camera-fab {
    position: fixed;
    right: max(16px, calc((100vw - 480px) / 2 + 16px));
    bottom: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #d9d9d9;
    border: none;
    color: #6b6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 20;
}

.camera-fab:active {
    background: #c7c7c7;
}

/* ---------- list-forming page ---------- */
.list-forming-screen {
    position: relative;
}

.lf-toggle-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.lf-toggle-row {
    position: relative;
    display: block;
    padding: 0.55rem 0.9rem 0.55rem 3.4rem;
    margin: 0;
    font-size: 0.85rem;
    color: #555;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    user-select: none;
    min-height: 2.1rem;
    line-height: 2.1rem;
}

.lf-toggle-row::before {
    content: "";
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 1.15rem;
    border-radius: 1rem;
    background: #c7c7c7;
    transition: background 0.15s;
}

.lf-toggle-row::after {
    content: "";
    position: absolute;
    left: 1.05rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    transition: left 0.15s;
}

.lf-toggle-input:checked ~ .lf-toggle-row::before { background: #0d6efd; }
.lf-toggle-input:checked ~ .lf-toggle-row::after { left: 1.8rem; }

/* модальное окно ввода количества — показывается/скрывается через :empty,
   без дополнительного JS/классов */
.scan-modal-backdrop:empty {
    display: none;
}

.scan-modal-backdrop {
    position: fixed;
    top: 0;
    bottom: 0;
    left: max(0px, calc((100vw - 480px) / 2));
    right: max(0px, calc((100vw - 480px) / 2));
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
    z-index: 30;
}

.scan-modal {
    background: #eeeeee;
    border-radius: 10px;
    padding: 1.1rem 1.2rem;
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
}

.confirm-modal {
    text-align: center;
}

.confirm-text {
    font-size: 0.95rem;
    margin-bottom: 1.1rem;
}

.manual-qty-note {
    font-size: 0.8rem;
    color: #7a6a2a;
    background: #fdf6e0;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.9rem;
}

.manual-qty-plan-fact {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.scan-modal-field {
    font-size: 0.85rem;
    color: #333;
}

.scan-modal-name {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.9rem;
}

.scan-modal-price-label {
    font-size: 0.85rem;
    color: #555;
}

.scan-modal-price {
    color: #c0392b;
    font-size: 1.9rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.scan-modal-qty-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.1rem;
    width: 100%;
}

.qty-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 50%;
    border: 1px solid #cfcfcf;
    background: #f5f5f5;
    font-size: 1.3rem;
    color: #333;
    box-sizing: border-box;
}

.qty-btn:active {
    background: #e6e6e6;
}

.qty-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 42px;
    text-align: center;
    font-size: 1.05rem;
    border: 1px solid #cfcfcf;
    border-radius: 8px;
    background: #fff;
    box-sizing: border-box;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.scan-modal-actions {
    display: flex;
    gap: 0.7rem;
}

.btn-modal-cancel,
.btn-modal-confirm {
    flex: 1;
    padding: 0.6rem 0.4rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.btn-modal-cancel { background: var(--color-red); }
.btn-modal-confirm { background: var(--color-green); }
.btn-modal-cancel:active,
.btn-modal-confirm:active { filter: brightness(0.92); }

/* карточки списка */
.lf-list {
    padding: 0.7rem 0.9rem;
    padding-bottom: 112px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.lf-item-card {
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
}

.lf-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
}

.lf-item-code {
    font-size: 0.72rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lf-item-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
}

.lf-item-article {
    font-size: 0.78rem;
    color: #999;
    margin-top: 0.15rem;
}

.lf-item-qty {
    flex-shrink: 0;
    text-align: right;
}

.lf-item-qty-label {
    font-size: 0.72rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.lf-item-qty-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

/* закреплённый футер: узкие кнопки списка + камера в одну строку —
   не перекрывает записи списка, т.к. .lf-list имеет padding-bottom
   не меньше высоты футера */
.lf-footer {
    position: fixed;
    bottom: 0;
    left: max(0px, calc((100vw - 480px) / 2));
    right: max(0px, calc((100vw - 480px) / 2));
    background: #fff;
    border-top: 1px solid #e2e2e2;
    padding: 0.6rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 15;
}

.lf-actions-slot {
    flex: 1 1 auto;
    display: flex;
    gap: 0.5rem;
    min-width: 0;
}

.btn-finish-list,
.btn-clear-list {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-finish-list { background: var(--color-green); flex-grow: 1.4; }
.btn-clear-list { background: var(--color-yellow); color: var(--color-text-dark); }
.btn-finish-list:active,
.btn-clear-list:active { filter: brightness(0.92); }

.lf-camera-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #d9d9d9;
    border: none;
    color: #6b6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lf-camera-btn:active {
    background: #c7c7c7;
}

/* ---------- invoice list page ---------- */
.invoice-search-wrap {
    padding: 0.7rem 0.9rem;
}

.invoice-search-input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    background: #f2f2f2;
    color: #666;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.invoice-card {
    display: block;
    width: calc(100% - 1.8rem);
    margin: 0 0.9rem 0.6rem;
    border: 1.5px solid #3a3a3a;
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    background: #fff;
    text-align: left;
}

.invoice-card:active {
    background: #f7f7f7;
}

.invoice-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
}

.invoice-date {
    font-size: 0.78rem;
    color: #333;
}

.invoice-number {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text-dark);
}

.invoice-sublist {
    font-size: 0.78rem;
    color: #999;
    margin-top: 0.1rem;
}

.invoice-count-label {
    font-size: 0.72rem;
    color: #666;
    text-align: right;
    text-transform: uppercase;
}

.invoice-count-value {
    font-size: 1.7rem;
    font-weight: 700;
    text-align: right;
    color: var(--color-text-dark);
}

.invoice-empty {
    text-align: center;
    color: #a9a9a9;
    padding: 2rem;
    font-size: 0.95rem;
}

/* ---------- invoice detail page ---------- */
.invoice-detail-header {
    padding: 0.6rem 0.9rem;
}

.invoice-detail-date,
.invoice-detail-number {
    font-size: 0.92rem;
    font-weight: 700;
}

.inv-items {
    padding: 0.7rem 0.9rem;
    padding-bottom: 84px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.inv-item-card {
    display: block;
    width: 100%;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    background: #fff;
    text-align: left;
    font: inherit;
    color: inherit;
}

.inv-item-card.marked {
    background: var(--color-yellow);
    border-color: #b5941f;
    cursor: pointer;
}

.inv-item-card.marked:active {
    filter: brightness(0.96);
}

.inv-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
}

.inv-item-code {
    font-size: 0.72rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.inv-item-card.marked .inv-item-code {
    color: #5f4d0d;
}

.inv-item-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
}

.inv-item-article {
    font-size: 0.78rem;
    color: #999;
    margin-top: 0.15rem;
}

.inv-item-card.marked .inv-item-article {
    color: #6e5c1a;
}

.inv-awaiting-note {
    font-size: 0.75rem;
    color: #8a4b00;
    font-weight: 600;
    margin-top: 0.35rem;
}

.inv-item-stats {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.inv-item-stat {
    text-align: center;
}

.inv-item-stat-label {
    font-size: 0.68rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.inv-item-card.marked .inv-item-stat-label {
    color: #6e5c1a;
}

.inv-item-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.1;
}

.inv-item-stat-value.match {
    color: var(--color-green);
}

/* закреплённый футер накладной — то же решение, что и на "Формировании
   списка": фиксирован снизу, у списка есть padding-bottom под его высоту */
.inv-footer {
    position: fixed;
    bottom: 0;
    left: max(0px, calc((100vw - 480px) / 2));
    right: max(0px, calc((100vw - 480px) / 2));
    background: #fff;
    border-top: 1px solid #e2e2e2;
    padding: 0.6rem 0.9rem;
    z-index: 15;
}

.invoice-footer-slot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.btn-start-receiving {
    flex: 1 1 auto;
    background: var(--color-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.8rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.btn-start-receiving:active {
    filter: brightness(0.92);
}

.btn-accept-invoice {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    background: #a3a3a3;
    color: #fff;
}

.btn-accept-invoice.ready {
    background: var(--color-green);
}

.btn-accept-invoice:disabled {
    opacity: 1;
}

.btn-accept-invoice.ready:active {
    filter: brightness(0.92);
}

.inv-camera-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #d9d9d9;
    border: none;
    color: #6b6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inv-camera-btn:active {
    background: #c7c7c7;
}

.invoice-dev-scan {
    margin: 0.6rem 0.9rem 0;
}

/* модалка со списком кодов маркировки */
.codes-modal-title {
    font-weight: 700;
    text-align: center;
}

.codes-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.codes-list li {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.4rem;
    font-size: 0.78rem;
    font-family: "SFMono-Regular", Consolas, monospace;
    word-break: break-all;
}

.codes-empty {
    text-align: center;
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* ---------- adaptive: narrow terminal screens (e.g. Urovo DT40) ---------- */
@media (max-width: 360px) {
    .menu-btn { font-size: 0.95rem; padding: 0.75rem 0.85rem; }
    .user-name { font-size: 1rem; }
    .app-logo { width: 28px; height: 28px; }
}

@media (max-height: 600px) {
    .app-footer { padding: 0.8rem 0 1rem 0; }
    .menu-btn { padding: 0.6rem 0.85rem; }
}
