:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-soft: #fafafa;
    --text: #1f1f1f;
    --muted: #7c7c88;
    --line: #e7e8ec;
    --primary: #e53935;
    --primary-dark: #cc2f2c;
    --success-bg: #edf8ef;
    --success-text: #237a3b;
    --warning-bg: #fff5e8;
    --warning-text: #a96a00;
    --error-bg: #fff0f0;
    --error-text: #c62828;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, sans-serif;
}

body {
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

.hidden {
    display: none !important;
}

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

.page {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 20px 14px 32px;
}

.page-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    padding: 6px 2px;
}

.topbar-left,
.topbar-right,
.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title,
.brand-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.1;
}

.topbar-subtitle,
.brand-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-top: 3px;
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(180deg, #ff5b57 0%, #e53935 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(229, 57, 53, 0.28);
}

.brand-logo.small {
    width: 42px;
    height: 42px;
    font-size: 20px;
    border-radius: 14px;
}

.auth-card,
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid rgba(231, 232, 236, 0.9);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 28px 22px;
}

.card {
    padding: 22px 18px;
    margin-bottom: 16px;
}

.card-main {
    padding-top: 24px;
}

.section-head {
    margin-bottom: 18px;
}

.section-head-sm {
    margin-bottom: 14px;
}

.section-title,
.page-title {
    margin: 0;
    font-size: 26px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.section-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.4;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 14px;
}

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

.field-label {
    font-size: 14px;
    font-weight: 600;
    color: #30303a;
}

.input,
input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    height: 52px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 14px;
    padding: 0 16px;
    font-size: 16px;
    color: var(--text);
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, transform .08s ease;
}

.input:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    border-color: rgba(229, 57, 53, 0.55);
    box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.10);
}

.btn {
    height: 52px;
    border: 0;
    border-radius: 14px;
    padding: 0 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .08s ease, opacity .2s ease, background .2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(180deg, #ff5b57 0%, #e53935 100%);
    color: #fff;
    box-shadow: 0 10px 22px rgba(229, 57, 53, 0.22);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #ff524e 0%, #db302d 100%);
}

.btn-light {
    background: #fff;
    color: #24242c;
    border: 1px solid var(--line);
}

.alert {
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #d6eddc;
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: #f6dfb8;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: #f1caca;
}

.status-card {
    background: linear-gradient(180deg, #fff 0%, #fffdfd 100%);
}

.loading-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.status-text {
    color: var(--muted);
    font-size: 14px;
}

.spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #ffd4d2;
    border-top-color: var(--primary);
    animation: spin .9s linear infinite;
    flex: 0 0 auto;
}

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

.qr-block {
    margin-top: 16px;
    text-align: center;
}

.qr-card {
    display: inline-flex;
    padding: 14px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.65);
}

.qr-image {
    width: 100%;
    max-width: 240px;
    height: auto;
    display: block;
    border-radius: 12px;
}

.qr-caption {
    margin-top: 10px;
    font-size: 13px;
    color: var(--muted);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.history-order {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.history-side {
    display: flex;
    align-items: flex-start;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-success_qr_ready,
.status-success_no_qr {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-processing,
.status-queued,
.status-created {
    background: #fff3f2;
    color: #cc4a35;
}

.status-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.empty-state {
    padding: 14px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px dashed var(--line);
    color: var(--muted);
    font-size: 14px;
}

.user-chip {
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
}

.user-chip-name {
    font-size: 14px;
    font-weight: 600;
    color: #2d2d35;
}

@media (max-width: 640px) {
    .page {
        padding: 14px 10px 24px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-right {
        justify-content: space-between;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .section-title,
    .page-title {
        font-size: 23px;
    }

    .card,
    .auth-card {
        border-radius: 20px;
    }

    .history-item {
        flex-direction: column;
    }

    .history-side {
        align-items: flex-start;
    }
}

/* DASHBOARD */
.dashboard-page {
    max-width: 1280px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.sidebar {
    background: var(--surface);
    border-radius: 22px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(231, 232, 236, 0.9);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 16px;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 46px;
    border-radius: 14px;
    padding: 0 14px;
    font-size: 15px;
    font-weight: 600;
    color: #2c2c35;
    transition: background .2s ease, color .2s ease;
}

.nav-link:hover {
    background: #fff2f2;
    color: var(--primary);
}

.dashboard-main {
    min-width: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #fffafa 100%);
    border-radius: 22px;
    padding: 20px 18px;
    border: 1px solid rgba(231, 232, 236, 0.9);
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    line-height: 1;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #202028;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.searchbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 760px;
}

.custom-table thead th {
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    padding: 0 14px 12px;
    white-space: nowrap;
}

.custom-table tbody tr {
    background: var(--surface-soft);
}

.custom-table tbody td {
    padding: 16px 14px;
    border-top: 1px solid var(--line);
    vertical-align: middle;
    font-size: 14px;
    color: #2a2a33;
}

.custom-table tbody tr:first-child td {
    border-top: 1px solid var(--line);
}

.custom-table tbody tr td:first-child {
    border-left: 1px solid var(--line);
    border-top-left-radius: 14px;
    border-bottom-left-radius: 14px;
}

.custom-table tbody tr td:last-child {
    border-right: 1px solid var(--line);
    border-top-right-radius: 14px;
    border-bottom-right-radius: 14px;
}

.custom-table tbody tr + tr td {
    border-top: 10px solid transparent;
    background-clip: padding-box;
}

.table-title {
    font-size: 15px;
    font-weight: 700;
    color: #1f1f28;
}

.table-link {
    color: var(--primary);
    font-weight: 700;
    font-size: 14px;
}

.actions-cell {
    text-align: right;
    white-space: nowrap;
}

.empty-table {
    text-align: center;
    color: var(--muted);
    padding: 28px 14px !important;
}

@media (max-width: 980px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
    }

    .nav-link {
        white-space: nowrap;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .searchbar {
        grid-template-columns: 1fr;
    }
}

/* Dashboard forms */
.form-card {
    max-width: 880px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.field-error {
    font-size: 13px;
    color: var(--error-text);
    margin-top: 2px;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 0 2px;
    font-size: 14px;
    color: #2b2b34;
    font-weight: 600;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.messages-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

select.input {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #7c7c88 50%),
        linear-gradient(135deg, #7c7c88 50%, transparent 50%);
    background-position:
        calc(100% - 22px) calc(50% - 3px),
        calc(100% - 16px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 40px;
}

@media (max-width: 640px) {
    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}


/* Dashboard Company Card */

.company-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
}

.company-hero-main {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.company-avatar {
    width: 64px;
    height: 64px;
    border-radius: 22px;
    background: linear-gradient(180deg, #ff5b57 0%, #e53935 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(229, 57, 53, 0.24);
    flex: 0 0 auto;
}

.company-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: #fff4f4;
    color: #cc3a36;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid #ffd7d6;
}

.company-hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-text {
    font-size: 20px;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

@media (max-width: 760px) {
    .company-hero {
        flex-direction: column;
        align-items: stretch;
    }

    .company-hero-actions {
        width: 100%;
    }

    .company-hero-actions .btn {
        flex: 1 1 100%;
    }
}

/* Deactivate buttons & links */
.btn-danger-soft {
    background: #fff0f0;
    color: #c62828;
    border: 1px solid #f0c8c8;
    box-shadow: none;
}

.btn-danger-soft:hover {
    background: #ffe8e8;
}

.table-title-link {
    color: #1f1f28;
    text-decoration: none;
}

.table-title-link:hover {
    color: var(--primary);
}

.meta-pill-link {
    text-decoration: none;
}

.filter-card {
    margin-bottom: 16px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.pagination {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.pagination a {
    padding: 6px 10px;
    border-radius: 8px;
    background: #f2f3f5;
    text-decoration: none;
    color: #333;
}

.pagination a:hover {
    background: #e53935;
    color: white;
}

.filters-grid input[name="q"] {
    grid-column: span 2;
}


@media (max-width: 390px) {
    .filters-grid input[name="q"] {
        grid-column: span 1;
    }
}


/*.issue-top-row {*/
/*    display: grid;*/
/*    grid-template-columns: minmax(0, 1fr) 120px 180px;*/
/*    gap: 14px;*/
/*    align-items: end;*/
/*}*/
.issue-top-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 180px;
    gap: 14px;
    align-items: end;
}

.field-grow,
.field-places,
.field-add-btn {
    min-width: 0;
}

.field-label-empty {
    visibility: hidden;
}

.btn-add-order {
    width: 100%;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .issue-top-row {
        grid-template-columns: minmax(0, 1fr) 145px;
        gap: 12px;
    }

    .field-grow {
        grid-column: 1 / -1;
    }

    .field-places {
        grid-column: 1 / 2;
    }

    .field-add-btn {
        grid-column: 2 / 3;
    }
}

@media (max-width: 480px) {
    .issue-top-row {
        grid-template-columns: 1fr;
    }

    .field-grow,
    .field-places,
    .field-add-btn {
        grid-column: 1 / -1;
    }

    .field-label-empty {
        display: none;
    }

    .field-add-btn .btn {
        width: 100%;
    }
}

.batch-box {
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 12px;
}

.orders-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.order-chip {
    padding: 6px 10px;
    background: #fff4f4;
    border-radius: 20px;
    display: flex;
    gap: 6px;
}

.order-chip-remove {
    cursor: pointer;
}


/* History styles */
.history-item-stack {
    flex-direction: column;
    align-items: stretch;
}

.history-top-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.batch-history {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.batch-toggle-btn {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 14px;
    font-weight: 700;
    /*color: var(--primary);*/
    color: #cb716f;
    cursor: pointer;
}

.batch-toggle-btn:hover {
    opacity: 0.85;
}

.batch-history-content {
    margin-top: 10px;
}

.batch-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.batch-history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 5px 12px;
    border-radius: 12px;
    background: #fafbfc;
    border: 1px solid var(--line);
}

.batch-history-number {
    font-size: 14px;
    font-weight: 600;
    color: #22242b;
    word-break: break-word;
}

.batch-history-places {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}

.batch-history-single {
    padding-top: 0;
    border-top: 0;
}

@media (max-width: 640px) {
    .history-top-row {
        flex-direction: column;
    }

    .batch-history-row {
        align-items: flex-start;
        flex-direction: column;
        padding: 10px 12px;
    }
}

.status-ready {
    background: #e6f7ec;
    color: #1f7a3f;
}

.status-error {
    background: #ffecec;
    color: #c62828;
}

/* QR Modal */
.history-side-stack {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: flex-end;
}

.qr-open-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--primary);
    border-radius: 12px;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.qr-open-btn:hover {
    background: #fff5f5;
}

.qr-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.qr-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.68);
    backdrop-filter: blur(2px);
}

.qr-modal-content {
    position: relative;
    z-index: 2;
    width: min(92vw, 520px);
    max-height: 92vh;
    margin: 4vh auto 0;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}

.qr-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.qr-modal-title {
    font-size: 18px;
    font-weight: 800;
    color: #1f1f28;
}

.qr-modal-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: #f4f5f7;
    color: #2a2a33;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.qr-modal-close:hover {
    background: #eceef2;
}

.qr-modal-body {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fcfcfd;
}

.qr-modal-image {
    display: block;
    width: min(100%, 420px);
    height: auto;
    border-radius: 16px;
    background: #fff;
    padding: 12px;
    border: 1px solid var(--line);
}

@media (max-width: 640px) {
    .history-side-stack {
        align-items: flex-start;
    }

    .qr-modal-content {
        width: calc(100vw - 20px);
        margin-top: 10px;
        max-height: calc(100vh - 20px);
    }

    .qr-modal-body {
        padding: 14px;
    }
}
.qr-empty {
    color: var(--muted);
    font-size: 14px;
}

/* Small QR*/
.qr-preview {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 4px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.qr-preview:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

@media (max-width: 640px) {
    .qr-preview {
        width: 56px;
        height: 56px;
    }
}

.qr-preview {
    position: relative;
}

.qr-preview::after {
    content: "🔍";
    position: absolute;
    right: 2px;
    bottom: 2px;
    font-size: 10px;
    opacity: 0.7;
}


/* Fix QR Courier Page */
.history-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.history-item-stack {
    flex-direction: column;
    align-items: stretch;
}

.history-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.history-main {
    min-width: 0;
    flex: 1 1 auto;
}

.history-order {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.25;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.history-side {
    display: flex;
    align-items: flex-start;
}

.history-side-stack {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.qr-preview {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 4px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex: 0 0 auto;
}

.qr-preview:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.10);
}

.batch-history {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.batch-toggle-btn {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 14px;
    font-weight: 700;
    color: #de6b61;
    cursor: pointer;
}

.batch-toggle-btn:hover {
    opacity: 0.85;
}

.batch-history-content {
    margin-top: 10px;
}

.batch-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.batch-history-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 38px;
    padding: 5px 12px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--line);
}

.batch-history-number {
    font-size: 14px;
    font-weight: 600;
    color: #22242b;
    word-break: break-word;
}

.batch-history-places {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}

.batch-history-single {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

@media (max-width: 640px) {
    .history-top-row {
        flex-direction: column;
        gap: 12px;
    }

    .history-side-stack {
        width: 100%;
        justify-content: flex-start;
    }

    .qr-preview {
        width: 56px;
        height: 56px;
    }

    .batch-history-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 12px;
    }
}

/* Toast */
.toast-container {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(92vw, 420px);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.14);
    border: 1px solid transparent;
    background: #fff;
    color: #1f1f28;
    animation: toastIn 0.22s ease;
}

.toast-success {
    background: #edf8ef;
    border-color: #d6eddc;
    color: #237a3b;
}

.toast-error {
    background: #fff0f0;
    border-color: #f1caca;
    color: #c62828;
}

.toast-warning {
    background: #fff6e9;
    border-color: #f3dfba;
    color: #a96a00;
}

.toast-info {
    background: #eef4ff;
    border-color: #d7e4ff;
    color: #285ea8;
}

.toast-body {
    flex: 1 1 auto;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 600;
}

.toast-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scanner */
.scanner-box {
    width: min(94vw, 500px);
    background: transparent;
    padding: 0;

}

/* Видео во весь экран */
#scanner-video {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
}

/* Затемнение */
.scanner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
}

/* Горизонтальное окно */
.scanner-window {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);

    width: min(90vw, 300px);
    height: 100px; /* 🔥 главное изменение */

    border: 2px solid #ff3b3b;
    border-radius: 12px;

    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.65),
        0 0 20px rgba(255, 59, 59, 0.4);
}

/* Красная линия сканирования */
.scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #ff3b3b;
    animation: scanLine 2s linear infinite;
}

@keyframes scanLine {
    0% { top: 0; }
    100% { top: 100%; }
}

/* Хедер */
.scanner-head {
    position: fixed;
    top: 20px;
    left: 0;
    right: 0;

    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    color: white;
    font-size: 16px;
}

@media (max-width: 500px) {
    #scan-barcode-btn {
        /*width: 100%;*/
        margin-top: 18px;
    }
}

/* Овер */
.order-chip-oversize {
    background: #fff3e0;
    border-color: #ffb74d;
}

.oversize-label {
    margin-left: 8px;
    color: #e65100;
    font-size: 12px;
}

.order-chip-oversize-btn {
    position: relative;
    z-index: 5;
    cursor: pointer;
    border: 0;
    background: #ff9800;
    color: #fff;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
}

/* Recipient */
.batch-history-row-recipient {
    align-items: flex-start;
}

.batch-history-recipient {
    margin-top: 4px;
    font-size: 13px;
    color: #6b7280;
}

.history-recipient {
    margin-top: 4px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.table-order-main {
    font-weight: 700;
}

.table-recipient {
    margin-top: 4px;
    font-size: 13px;
    color: #6b7280;
}
.table-recipient-list {
    margin-top: 4px;
    font-size: 13px;
    color: #6b7280;
}

/* Contacts */
.contacts-card {
    margin-top: 18px;
}

.contacts-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.contact-result {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    font-size: 15px;
}

.contact-result-title {
    font-weight: 800;
    margin-bottom: 8px;
}

@media (max-width: 640px) {
    .contacts-row {
        grid-template-columns: 1fr;
    }
}