* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #16a34a;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand a {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    margin-left: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}
.nav-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    margin-left: 2rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
    background: #eff6ff;
}

/* Quick actions — вертикальные кнопки в шапке (Тов. / Доб.) */
.nav-quick {
    display: flex;
    flex-direction: row;
    gap: 0.3rem;
    align-self: stretch;
    margin-left: 1rem;
}

.nav-quick .btn-quick {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    flex: 1 1 0;
    min-width: 44px;
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn-quick-primary {
    background: var(--primary);
    color: #fff;
}

.btn-quick-primary:hover {
    background: var(--primary-hover);
}

.btn-quick-secondary {
    background: #eff6ff;
    color: var(--primary);
}

.btn-quick-secondary:hover {
    background: #dbeafe;
}

.nav-quick .btn-quick.active {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.nav-exit {
    margin-left: 1rem;
}

.username {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-logout {
    color: var(--danger);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-logout:hover {
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-hover);
}

.btn-link {
    background: transparent;
    color: var(--primary);
    padding: 0.3rem 0.5rem;
}

.btn-link:hover {
    background: #eff6ff;
    text-decoration: underline;
}

.btn-link:disabled {
    color: var(--text-muted);
    background: transparent;
    text-decoration: none;
}

.btn-warning {
    background: #f59e0b;
    color: white;
    font-weight: bold;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

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

/* Active button for PSB selection */
#psb-buttons button.active {
    background-color: var(--primary);
    color: white;
}

/* Product image preview */
#product-image-row {
    margin-top: 1rem;
}

.image-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.slider-btn {
    background: var(--secondary);
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
    align-self: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.slider-btn:hover {
    background: var(--primary);
    color: white;
}

.slider-btn:active {
    transform: scale(0.92);
    background: var(--primary);
    color: white;
}

.slider-counter {
    font-size: 13px;
    color: #666;
    text-align: center;
    margin-top: 0.25rem;
}

#image-preview {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    position: relative;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#product-image {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
    background: #f8f9fa;
    transition: transform 0.2s, opacity 0.25s ease;
    display: block;
}

#product-image.loaded {
    opacity: 1;
}

#product-image:hover {
    transform: scale(1.02);
}

#product-image:active {
    transform: scale(0.97);
    opacity: 0.8;
}

/* ── Анимация поиска фото ──────────────────────────────────── */
.img-search-anim {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 260px;
    gap: 14px;
}

.search-orbit {
    position: relative;
    width: 64px;
    height: 64px;
}

.search-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--primary) 20%, transparent);
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
}

.search-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: var(--primary);
    animation: search-pulse 1.4s ease-in-out infinite;
}

@keyframes search-pulse {
    0%, 100% { transform: scale(0.7); opacity: 0.5; }
    50%       { transform: scale(1.2); opacity: 1; }
}

.search-anim-label {
    font-size: 13px;
    color: var(--text-secondary, #666);
    animation: label-fade 0.4s ease;
    margin: 0;
}

@keyframes label-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

/* ── Подсказка выбора ──────────────────────────────────────── */
.img-select-hint {
    font-size: 12px;
    color: var(--primary);
    text-align: center;
    margin-top: 4px;
    opacity: 0.85;
}

/* ── Строка счётчик + статус ───────────────────────────────── */
.img-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.25rem;
    gap: 0.5rem;
}

/* Recent products section */
.recent-products-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.recent-products-section h3 {
    margin-bottom: 1rem;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

/* Horizontal card: image left, info right — responsive width */
.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    height: 100%;
}

.product-image {
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
    opacity: 1;
    transition: opacity 0.3s;
    display: block;
}

.product-image img.loaded {
    opacity: 1;
}

.product-image .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.25rem;
}

/* Info fills remaining space */
.product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.product-article {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.product-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-expiry {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.product-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
}

/* Info chips — окрашивание по длине текста, цвета ≠ статусных (red/orange/yellow/blue/green/gray) */
.info-chip {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    padding: 2px 7px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.35;
    border: 1px solid;
    white-space: nowrap;
}
.chip-article { background: #ecfeff; border-color: #a5f3fc; color: #155e75; }
.chip-ean { background: #f0fdfa; border-color: #99f6e4; color: #115e59; }
.chip-ean.missing { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.chip-expiry { background: #f0fdfa; border-color: #99f6e4; color: #0f766e; }
.chip-qty { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.chip-user { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.chip-date { background: #f1f5f9; border-color: #cbd5e1; color: #334155; }
.chip-name { background: #fdf2f8; border-color: #fbcfe8; color: #9d174d; font-size:0.88rem; font-weight:600; white-space:normal; border-radius:8px; padding:4px 8px; line-height:1.35; display:block; width:fit-content; max-width:100%; }
.product-expiry-chips, .product-article-chips { display:flex; flex-wrap:wrap; gap:0.35rem; }

/* Mobile: keep image visible, slightly larger for retina */
@media (max-width: 768px) {
    .product-card {
        align-items: flex-start;
        gap: 0.75rem;
    }
    .product-image {
        flex: 0 0 72px;
        width: 72px;
        height: 72px;
    }
}
@media (max-width: 480px) {
    .product-image {
        flex: 0 0 68px;
        width: 68px;
        height: 68px;
    }
}

/* Lightbox overlay styles */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    cursor: zoom-out;
    animation: fadeIn 0.2s ease-out;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Clickable product images */
.product-image img.clickable {
    cursor: pointer;
    transition: transform 0.2s;
}

.product-image img.clickable:hover {
    transform: scale(1.05);
}



/* Form */
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.form-card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.status-text {
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.status-ok {
    color: var(--success);
}

.status-info {
    color: var(--primary);
}

/* Product thumbnail in table */
.product-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
}

/* Table column width for photo */
th:first-child,
td:first-child {
    width: 80px;
}

th:nth-child(2),
td:nth-child(2) {
    width: 90px;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.products-table th {
    background: #f1f5f9;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.products-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.products-table tbody tr:hover {
    background: #f8fafc;
}

/* Status colors */
.status-excluded {
    border-left: 3px solid var(--danger);
}

table .status-excluded td:first-child {
    border-left: 3px solid var(--danger);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-red {
    background: #dc2626;
    color: #fff;
}

.badge-orange {
    background: #ea580c;
    color: #fff;
}

.badge-yellow {
    background: #ca8a04;
    color: #fff;
}

.badge-blue {
    background: #2563eb;
    color: #fff;
}

.badge-green {
    background: #16a34a;
    color: #fff;
}

.badge-gray {
    background: #64748b;
    color: #fff;
}

/* Filters */
.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.filter-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: white;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.stat-green .stat-value { color: var(--success); }
.stat-yellow .stat-value { color: var(--warning); }
.stat-red .stat-value { color: var(--danger); }

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.login-card h1 {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-form .form-group {
    margin-bottom: 1rem;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.table-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: right;
}

/* Barcode scanner */
.scanner-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5vh 1rem 15vh;
}

.scanner-box {
    width: 100%;
    max-width: 360px;
}

#reader {
    width: 100%;
    height: 40vh;
    max-height: 300px;
    min-height: 200px;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
}

#reader video,
#reader canvas,
#reader canvas.overlay {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Зелёная рамка по центру */
#reader::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 45%;
    border: 4px solid #00ff00;
    pointer-events: none;
    z-index: 10;
}

#reader video {
    object-fit: cover !important;
}

.scanner-box .btn {
    margin-top: 1rem;
    width: 100%;
    justify-content: center;
}

#capture-btn, #close-scanner {
    font-size: 1.2rem;
    padding: 1rem;
    margin-top: 0.5rem;
}

/* Кнопка захвата */
.btn-capture {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.875rem;
    margin-top: 0.75rem;
    background: linear-gradient(135deg, #00c853, #00e676);
    border: none;
    color: #fff;
}

.btn-capture:hover {
    background: linear-gradient(135deg, #00a046, #00c853);
}

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

/* Загрузка при сканировании */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Статус сканирования */
.scan-status {
    text-align: center;
    padding: 0.75rem;
    margin-top: 0.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.scan-status-hint {
    background: rgba(255,255,255,0.15);
    color: #e0e0e0;
}

.scan-status-processing {
    background: rgba(255,193,7,0.2);
    color: #ffc107;
}

.scan-status-success {
    background: rgba(0,200,83,0.2);
    color: #00e676;
}

.scan-status-error {
    background: rgba(244,67,54,0.2);
    color: #ff5252;
}

/* Анимация захвата кадра */
#reader.capturing {
    animation: capture-flash 0.3s ease-out;
}

@keyframes capture-flash {
    0% {
        box-shadow: inset 0 0 0 0 rgba(0,255,0,0);
    }
    50% {
        box-shadow: inset 0 0 30px 10px rgba(0,255,0,0.4);
    }
    100% {
        box-shadow: inset 0 0 0 0 rgba(0,255,0,0);
    }
}

/* Actions cell */
.actions-cell {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.actions-cell form {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.actions-cell input[type="password"] {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
    width: 120px;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        display: grid;
        grid-template-columns: 1fr auto auto;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "brand quick toggle"
            "user  quick exit"
            "links links links";
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        align-items: center;
    }

    .nav-brand {
        grid-area: brand;
    }

    .nav-quick {
        grid-area: quick;
        align-self: stretch;
        margin-left: 0;
        gap: 0.25rem;
    }

    .nav-quick .btn-quick {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
        min-width: 40px;
    }

    .nav-toggle {
        display: flex;
        grid-area: toggle;
        justify-self: end;
    }

    .nav-user {
        grid-area: user;
        margin-left: 0;
        justify-content: flex-start;
    }

    .nav-exit {
        grid-area: exit;
        margin-left: 0;
        justify-self: end;
    }

    .nav-links {
        grid-area: links;
        display: none;
        flex-direction: column;
        margin-left: 0;
        gap: 0.15rem;
        padding: 0.25rem 0 0.5rem;
        border-top: 1px solid var(--border);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 0.65rem 0.75rem;
        font-size: 0.95rem;
    }

    .container {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .actions-cell {
        flex-direction: column;
    }

    .products-table {
        font-size: 0.85rem;
    }

    .filters {
        flex-direction: column;
    }

    .filters .search-input,
    .filters .filter-select {
        width: 100%;
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease-out;
}

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

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

.modal-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.modal-header .modal-icon {
    font-size: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0 0.25rem;
    margin-left: auto;
}
.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 1rem 1.5rem;
}

.dup-field {
    margin-bottom: 0.75rem;
}

.dup-label {
    display: block;
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.dup-value {
    display: block;
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

.dup-dates {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.5rem;
    max-height: 120px;
    overflow-y: auto;
}

.dup-dates > div {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.dup-dates > div:last-child {
    border-bottom: none;
}

.ean-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--primary);
    background: #eff6ff;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid #eee;
}

.modal-footer .btn {
    flex: 1;
    justify-content: center;
}

/* Update counter for sync button */
.update-counter {
    display: inline-block;
    margin-left: 0.5rem;
    font-weight: bold;
}

/* Notification / unsynced indicator */
.unsynced-dot {
    display: none;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    animation: pulse 2s ease-in-out infinite;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
    flex-wrap: wrap;
}

.page-info {
    font-size: 0.9rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .scanner-container {
        padding: 5vh 1rem 20vh;
    }
    #reader {
        height: 30vh;
        max-height: 250px;
        min-height: 150px;
    }
    #capture-btn, #close-scanner {
        font-size: 1.1rem;
        padding: 0.875rem;
        margin-top: 0.25rem;
    }
    
    .pagination {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .unsynced-dot {
        width: 8px;
        height: 8px;
    }
}

/* Компактные кнопки Google Sheets */
.page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sheet-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sheet-btn {
    flex-shrink: 1;
    min-width: 120px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    padding: 6px 12px;
}

.groups-checkbox-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.groups-checkbox-container label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    margin: 0;
    padding: 2px 0;
    cursor: pointer;
}

.groups-checkbox-container input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
}

/* Товары: таблица на десктопе, карточки на мобильных */
@media (max-width: 768px) {
    #table-container { display: none !important; }
    #products-grid { display: grid !important; }
    .filters { flex-direction: column; }
}
@media (min-width: 769px) {
    #products-grid { display: none !important; }
}
.product-card .product-status { margin: 0.2rem 0; }
.product-card .delete-btn { margin-top: 0.5rem; min-height: 36px; }
.product-card .product-meta { margin-top: 0.25rem; padding-top: 0.3rem; }
.product-card .meta-user, .product-card .meta-date { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48%; }
.no-thumb, .no-image { font-size: 12px; color: var(--text-muted); display:flex; align-items:center; justify-content:center; height:100%; }

@media (max-width: 600px) {
    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sheet-buttons {
        flex-direction: column;
    }
    
    .sheet-btn {
        width: 100%;
        max-width: none;
        font-size: 11px;
        padding: 8px 12px;
        text-align: left;
    }
}

/* Pending Images Section */
.pending-images-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--warning);
}

.pending-images-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pending-card {
    border: 2px solid var(--warning);
    background: #fefce8;
}

.pending-card .product-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }
    
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }
    
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

/* Badge for count */
.badge-warning {
    background: var(--warning);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Фирменные иконки (SVG-спрайт /static/images/icons.svg) */
:root {
    --brand: #e30613;
}
.icon {
    width: 1.15em;
    height: 1.15em;
    vertical-align: -0.2em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}
.icon-lg {
    width: 1.35em;
    height: 1.35em;
}
.nav-brand a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--brand);
}
.brand-logo {
    height: 30px;
    width: 30px;
    border-radius: 7px;
    box-shadow: 0 0 0 1px var(--border);
}
.nav-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.page-header h1 .icon,
main h1 .icon,
main h2 .icon {
    color: var(--brand);
}
.btn .icon {
    width: 1.1em;
    height: 1.1em;
}
.sheet-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.login-brand {
    text-align: center;
    margin-bottom: 0.75rem;
}
.login-brand img {
    width: 76px;
    height: 76px;
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(227, 6, 19, 0.25);
}
.modal-header .modal-icon .icon {
    width: 1.75rem;
    height: 1.75rem;
    color: var(--warning);
    vertical-align: middle;
}
.no-photo-icon .icon {
    width: 2rem;
    height: 2rem;
}
.sync-icon .icon {
    width: 1.5rem;
    height: 1.5rem;
}
