:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --panel: #ffffff;
    --surface-soft: #f6f8fc;
    --surface-chip: #eef2f8;
    --text: #172033;
    --text-soft: #34425a;
    --muted: #657187;
    --line: #e3e8f1;
    --border: #e3e8f1;
    --primary: #1f64ff;
    --primary-dark: #154bd1;
    --primary-soft: #eef4ff;
    --danger: #d12f2f;
    --danger-soft: #fff0f0;
    --danger-line: #f1c9c9;
    --success: #138a44;
    --success-soft: #effaf3;
    --success-line: #cdeed9;
    --warning: #8a5d00;
    --warning-soft: #fff8e6;
    --warning-line: #f0dda2;
    --info: #1f64ff;
    --info-soft: #eef4ff;
    --info-line: #dce7ff;
    --sidebar-bg: #101827;
    --sidebar-text: #c8d3e8;
    --sidebar-text-muted: #9ba9c2;
    --sidebar-active-bg: #ffffff;
    --sidebar-active-text: #101827;
    --shadow: 0 14px 40px rgba(30, 45, 80, .08);
    --shadow-strong: 0 14px 34px rgba(20, 34, 58, .15);
    --radius: 18px;
    --overlay: rgba(7, 14, 28, .48);
}

/* Dark palette applies automatically by OS preference, or explicitly once the
   visitor picks a theme with the sidebar toggle (theme_toggle.js sets
   data-theme and persists it). Both blocks below must stay in sync. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0b0f1a;
        --panel: #141b2c;
        --surface-soft: #1a2338;
        --surface-chip: #212b45;
        --text: #eef1f8;
        --text-soft: #c3cbdf;
        --muted: #8b96b3;
        --line: #263050;
        --border: #263050;
        --primary: #5a90ff;
        --primary-dark: #7ea6ff;
        --primary-soft: rgba(90, 144, 255, .16);
        --danger: #ff6b6b;
        --danger-soft: rgba(255, 107, 107, .14);
        --danger-line: rgba(255, 107, 107, .32);
        --success: #3ecf8e;
        --success-soft: rgba(62, 207, 142, .14);
        --success-line: rgba(62, 207, 142, .32);
        --warning: #f0b93d;
        --warning-soft: rgba(240, 185, 61, .14);
        --warning-line: rgba(240, 185, 61, .32);
        --info: #5a90ff;
        --info-soft: rgba(90, 144, 255, .14);
        --info-line: rgba(90, 144, 255, .32);
        --sidebar-bg: #070a13;
        --sidebar-text: #c3cbdf;
        --sidebar-text-muted: #7783a1;
        --sidebar-active-bg: #1a2338;
        --sidebar-active-text: #eef1f8;
        --shadow: 0 14px 40px rgba(0, 0, 0, .45);
        --shadow-strong: 0 14px 34px rgba(0, 0, 0, .55);
        --overlay: rgba(0, 0, 0, .6);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0f1a;
    --panel: #141b2c;
    --surface-soft: #1a2338;
    --surface-chip: #212b45;
    --text: #eef1f8;
    --text-soft: #c3cbdf;
    --muted: #8b96b3;
    --line: #263050;
    --border: #263050;
    --primary: #5a90ff;
    --primary-dark: #7ea6ff;
    --primary-soft: rgba(90, 144, 255, .16);
    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, .14);
    --danger-line: rgba(255, 107, 107, .32);
    --success: #3ecf8e;
    --success-soft: rgba(62, 207, 142, .14);
    --success-line: rgba(62, 207, 142, .32);
    --warning: #f0b93d;
    --warning-soft: rgba(240, 185, 61, .14);
    --warning-line: rgba(240, 185, 61, .32);
    --info: #5a90ff;
    --info-soft: rgba(90, 144, 255, .14);
    --info-line: rgba(90, 144, 255, .32);
    --sidebar-bg: #070a13;
    --sidebar-text: #c3cbdf;
    --sidebar-text-muted: #7783a1;
    --sidebar-active-bg: #1a2338;
    --sidebar-active-text: #eef1f8;
    --shadow: 0 14px 40px rgba(0, 0, 0, .45);
    --shadow-strong: 0 14px 34px rgba(0, 0, 0, .55);
    --overlay: rgba(0, 0, 0, .6);
}
:root[data-theme="dark"] body { background: var(--bg); }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, Arial, sans-serif; background: var(--bg); color: var(--text); transition: background-color .15s ease, color .15s ease; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 280px; background: var(--sidebar-bg); color: #fff; padding: 22px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #3d7cff, #20b6ff); display: grid; place-items: center; font-weight: 800; }
.brand-title { font-weight: 800; letter-spacing: .2px; }
.brand-subtitle { color: var(--sidebar-text-muted); font-size: 13px; }
.nav { margin-top: 28px; display: grid; gap: 8px; }
.nav-link { color: var(--sidebar-text); padding: 12px 14px; border-radius: 12px; font-weight: 650; }
.nav-link:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.user-box { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 12px; color: #dbe5f8; }
.link-button { border: 0; background: transparent; color: var(--sidebar-text); cursor: pointer; font-size: 14px; padding: 0; }
.theme-toggle {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06);
    color: var(--sidebar-text); font-weight: 700; font-size: 13px; cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.theme-toggle-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.theme-toggle-icon--dark { display: none; }
:root[data-theme="dark"] .theme-toggle-icon--light { display: none; }
:root[data-theme="dark"] .theme-toggle-icon--dark { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle-icon--light { display: none; }
    :root:not([data-theme="light"]) .theme-toggle-icon--dark { display: block; }
}
.content { flex: 1; padding: 28px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
h1 { margin: 0; font-size: 30px; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 18px 0 8px; font-size: 15px; }
p { color: var(--muted); margin: 6px 0 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.cards { display: grid; grid-template-columns: repeat(6, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 24px; }
.grid-two { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; }
.table-card { padding: 0; overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { background: var(--surface-soft); color: var(--text-soft); text-align: left; font-weight: 750; }
.table th, .table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 10px; }
.right { text-align: right; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 10px 14px; border-radius: 12px; font-weight: 750; cursor: pointer; min-height: 42px; }
.button:hover { text-decoration: none; border-color: var(--primary); }
.button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button.small { padding: 7px 10px; min-height: 32px; border-radius: 10px; font-size: 13px; }
.button.full { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; margin-bottom: 18px; box-shadow: none; }
.input, input[type="text"], input[type="password"], input[type="email"], input[type="number"], select, textarea { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 11px 12px; font: inherit; color: var(--text); }
.input:focus, input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
.form { max-width: 740px; display: grid; gap: 14px; }
.form.wide { max-width: 1100px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--text-soft); font-weight: 750; }
.wide-field { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.help { color: var(--muted); font-size: 12px; margin-top: 5px; }
.field-error { color: var(--danger); font-size: 13px; margin-top: 5px; }
.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { border-radius: 12px; padding: 12px 14px; background: var(--info-soft); border: 1px solid var(--info-line); color: var(--text); }
.message.success { background: var(--success-soft); border-color: var(--success-line); color: var(--text); }
.message.error { background: var(--danger-soft); border-color: var(--danger-line); color: var(--text); }
.message.warning { background: var(--warning-soft); border-color: var(--warning-line); color: var(--text); }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--surface-chip); color: var(--text-soft); white-space: nowrap; }
.badge.stock { background: var(--info-soft); color: var(--primary); }
.badge.showcase { background: var(--success-soft); color: var(--success); }
.badge.reserved { background: var(--warning-soft); color: var(--warning); }
.badge.repair { background: var(--primary-soft); color: var(--primary); }
.badge.sold { background: var(--surface-chip); color: var(--muted); }
.badge.written_off { background: var(--danger-soft); color: var(--danger); }
.badge.listed { background: var(--info-soft); color: var(--primary); }
.badge.returned { background: var(--warning-soft); color: var(--warning); }
.product-return-note { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; margin-top: 7px; }
.product-return-meta { color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.3; }
.details { display: grid; grid-template-columns: 170px 1fr; gap: 10px 14px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 650; }
/* Barcodes/QR render as black-on-white; the card stays print-paper white in both themes so codes stay scannable. */
.barcode-box { border: 1px dashed var(--line); border-radius: 16px; padding: 18px; background: #fff; }
.barcode-box svg { width: 100%; height: auto; }
.mt { margin-top: 24px; }
.log-mini { margin: 0; padding-left: 18px; color: var(--text-soft); }
.log-mini li { margin: 8px 0; }
.log-mini span { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.login-body { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: radial-gradient(circle at top, var(--primary-soft), var(--bg)); }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 28px; }
.login-brand { margin-bottom: 24px; color: var(--text); }
.login-brand .brand-subtitle { color: var(--muted); }
.login-card input { margin-bottom: 14px; }
@media (max-width: 1200px) { .cards { grid-template-columns: repeat(3, 1fr); } .filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
    .layout { display: block; }
    .sidebar { position: static; width: 100%; height: auto; }
    .content { padding: 18px; }
    .page-head, .grid-two { display: block; }
    .actions { justify-content: flex-start; margin-top: 12px; }
    .cards, .form-grid, .filters { grid-template-columns: 1fr; }
    .card { margin-bottom: 14px; }
}
.cards.three { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.filters.small-filters { grid-template-columns: 2fr 1fr auto; }
.scan-form { max-width: 900px; grid-template-columns: 1fr auto; align-items: end; }
.scan-input { font-size: 22px; font-weight: 750; letter-spacing: .5px; }
.inline { display: inline-flex; margin: 2px; }
.badge.in_transit, .badge.pending { background: var(--warning-soft); color: var(--warning); }
.badge.accepted, .badge.issued, .badge.ready { background: var(--success-soft); color: var(--success); }
.badge.canceled { background: var(--danger-soft); color: var(--danger); }
.badge.diagnostics { background: var(--info-soft); color: var(--primary); }
.badge.in_work, .badge.accepted { background: var(--primary-soft); color: var(--primary); }
@media (max-width: 860px) { .scan-form { grid-template-columns: 1fr; } }
.button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.danger-text { color: var(--danger); }
.checkbox-field { display: flex; align-items: center; }
.check-label { display: flex !important; align-items: center; gap: 10px; margin-top: 28px; cursor: pointer; }
.check-label input { width: 20px; height: 20px; }
.main-search { grid-template-columns: 1fr auto auto; }
.filters-extended { grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; }
.badge.posted { background: var(--info-soft); color: var(--primary); }
.badge.archived { background: var(--surface-chip); color: var(--muted); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-item { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: var(--panel); }
.media-item img, .media-item video { width: 100%; max-height: 260px; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 10px; background: var(--surface-soft); }
.media-caption { color: var(--muted); font-size: 12px; margin-top: 8px; overflow-wrap: anywhere; }
@media (max-width: 1200px) { .filters-extended { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) { .main-search, .filters-extended { grid-template-columns: 1fr; } }
.actions-col { min-width: 360px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions .inline { margin: 0; }
.row-actions .button.small { white-space: nowrap; }
.filters.small-filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
@media (max-width: 860px) { .row-actions { justify-content: flex-start; } .actions-col { min-width: 220px; } .filters.small-filters { grid-template-columns: 1fr; } }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.button.small {
    padding: 8px 12px;
    font-size: 14px;
}

.nav-link-count { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nav-counter { min-width: 25px; height: 25px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center; background: #ff4f5f; color: #fff; font-size: 12px; font-weight: 900; }
.nav-counter.neutral { background: #3d7cff; }
.nav-link.active .nav-counter { background: #e23e50; color: #fff; }
.nav-link.active .nav-counter.neutral { background: #1f64ff; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 11px 15px; color: var(--muted); font-weight: 800; border-bottom: 3px solid transparent; }
.tab:hover { text-decoration: none; color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab span { min-width: 24px; height: 24px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--surface-chip); font-size: 12px; color: var(--text-soft); }
.task-filter { grid-template-columns: minmax(240px, 620px) auto; max-width: 760px; }
.task-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.task-card { position: relative; overflow: hidden; border-left: 5px solid var(--muted); box-shadow: 0 9px 28px rgba(30,45,80,.07); }
.task-card.task-mine, .task-summary.task-mine { border-left-color: var(--primary); background: linear-gradient(100deg, var(--primary-soft) 0, var(--panel) 32%); }
.task-card.task-other, .task-summary.task-other { border-left-color: #ed9b22; background: linear-gradient(100deg, var(--warning-soft) 0, var(--panel) 32%); }
.task-card.task-completed, .task-summary.task-completed { border-left-color: var(--success); background: linear-gradient(100deg, var(--success-soft) 0, var(--panel) 32%); }
.task-card.task-review, .task-summary.task-review { border-left-color: #8b5cf6; background: linear-gradient(100deg, rgba(139,92,246,.12) 0, var(--panel) 32%); }
.task-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.task-card-head time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.task-side { font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.task-card h2 { margin: 0 0 8px; }
.task-card h2 a { color: var(--text); }
.task-description { min-height: 42px; color: var(--text-soft); line-height: 1.45; }
.task-meta { display: grid; gap: 5px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.task-meta strong { color: var(--text-soft); }
.task-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 40px 24px; }
.task-form { max-width: 820px; }
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.task-main { display: grid; gap: 18px; min-width: 0; }
.task-summary { border-left: 5px solid var(--muted); }
.task-full-description { color: var(--text-soft); line-height: 1.55; margin-bottom: 20px; }
.task-details { grid-template-columns: 150px 1fr; }
.task-status-line { margin-bottom: 8px; }
.badge.completed { background: var(--success-soft); color: var(--success); }
.badge.task-mine-badge { background: var(--info-soft); color: var(--primary); }
.badge.task-other-badge { background: var(--warning-soft); color: var(--warning); }
.badge.review { background: rgba(139,92,246,.14); color: #8b5cf6; }
.transfer-form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto minmax(180px, 1fr) auto; gap: 10px; align-items: center; }
.transfer-form label { font-weight: 800; color: var(--text-soft); }
.chat-card { min-width: 0; }
.task-chat { display: grid; gap: 11px; max-height: 580px; overflow-y: auto; padding: 5px 5px 12px 0; }
.chat-message { width: min(84%, 760px); justify-self: start; border-radius: 14px 14px 14px 4px; background: var(--surface-soft); border: 1px solid var(--line); padding: 11px 13px; }
.chat-message.own { justify-self: end; border-radius: 14px 14px 4px 14px; background: var(--primary-soft); border-color: var(--info-line); }
.chat-author { display: flex; justify-content: space-between; gap: 12px; color: var(--text-soft); font-size: 12px; }
.chat-author time { color: var(--muted); white-space: nowrap; }
.chat-text { margin-top: 7px; line-height: 1.45; overflow-wrap: anywhere; }
.chat-files { display: grid; gap: 6px; margin-top: 9px; }
.chat-files a { padding: 7px 9px; border-radius: 9px; background: rgba(127,140,165,.15); font-size: 13px; overflow-wrap: anywhere; }
.chat-files a span { color: var(--muted); }
.message-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.message-form-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; margin-top: 10px; }
.file-field label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 750; }
.activity-card { position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow-y: auto; }
.activity-list { list-style: none; margin: 0; padding: 0; display: grid; }
.activity-list li { position: relative; display: grid; grid-template-columns: 16px 1fr; gap: 8px; padding-bottom: 16px; }
.activity-list li:not(:last-child)::before { content: ''; position: absolute; left: 5px; top: 11px; bottom: 0; width: 2px; background: var(--line); }
.activity-dot { width: 12px; height: 12px; margin-top: 2px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); z-index: 1; }
.activity-list strong { font-size: 13px; }
.activity-list p { font-size: 11px; margin: 2px 0; }
.activity-list small { display: block; color: var(--text-soft); line-height: 1.35; overflow-wrap: anywhere; }
.review-return-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 9px; }
.review-return-form label { font-weight: 800; color: var(--text-soft); }
.selected-files { display: grid; gap: 7px; margin-top: 10px; }
.selected-file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.selected-file-row span { min-width: 0; overflow-wrap: anywhere; }
.selected-file-row small { display: block; color: var(--muted); margin-top: 2px; }
.upload-status { margin-top: 8px; font-size: 13px; }
.upload-status.warning { color: var(--warning); font-weight: 750; }
.upload-progress { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--info-soft); color: var(--text); }
.upload-progress progress { width: 100%; height: 14px; accent-color: var(--primary); }
.upload-progress strong { font-size: 13px; }
.existing-task-files { border-top: 1px solid var(--line); padding-top: 14px; }
.existing-file-list { display: grid; gap: 8px; margin-top: 10px; }
.existing-file-list label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 11px; padding: 10px; cursor: pointer; }
.existing-file-list input { width: 19px; height: 19px; flex: 0 0 auto; }
.existing-file-list small { display: block; color: var(--muted); margin-top: 2px; }

.label-stats { margin-bottom: 18px; }
.label-table-card { box-shadow: var(--shadow); }
.label-table { min-width: 1280px; }
.label-table th:first-child, .label-table td:first-child { position: sticky; left: 0; z-index: 2; background: var(--panel); text-align: center; }
.label-table thead th:first-child { background: var(--surface-soft); }
.label-table textarea { resize: vertical; min-width: 240px; }
.compact-input { padding: 8px 9px !important; border-radius: 9px !important; font-size: 13px !important; }
.label-description-input { min-width: 280px !important; }
.number-input { min-width: 105px; }
.size-input { min-width: 88px; }
.quantity-input { min-width: 76px; }
.select-all-label { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.label-select, .select-all-label input { width: 19px; height: 19px; accent-color: var(--primary); }
.label-cart-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.clear-cart-form { text-align: right; margin-top: 9px; }
.label-tools { grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); }
.label-search-form { grid-template-columns: 1fr auto; margin: 0 0 12px; padding: 0; }
.quick-product-list, .saved-layouts { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.quick-product-list > div, .saved-layouts > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.quick-product-list span, .saved-layouts span { min-width: 0; }
.quick-product-list small, .saved-layouts small { display: block; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.save-layout-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.manual-label-card { scroll-margin-top: 18px; }
.manual-label-form { align-items: end; }
.manual-label-form .wide-field { align-self: stretch; }

.qr-scanner-card { max-width: 900px; box-shadow: none; }
.qr-scanner-card .section-head { align-items: flex-start; }
.scanner-stage { position: relative; width: min(680px, 100%); aspect-ratio: 4 / 3; margin: 14px auto; overflow: hidden; border-radius: 16px; background: #0b0f18; } /* camera stage stays dark in both themes for contrast against the scan frame */
.scanner-stage video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.3); }
.scanner-status { text-align: center; padding: 8px; }
.success-text { color: var(--success); font-weight: 750; }
.error-text { color: var(--danger); font-weight: 750; }

@media (max-width: 1100px) {
    .task-layout { grid-template-columns: 1fr; }
    .activity-card { position: static; max-height: none; }
    .task-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .tabs { overflow-x: auto; }
    .tab { white-space: nowrap; }
    .task-filter, .label-search-form, .save-layout-form { grid-template-columns: 1fr; }
    .task-layout { display: grid; }
    .transfer-form { grid-template-columns: 1fr; }
    .chat-message { width: 94%; }
    .message-form-bottom { grid-template-columns: 1fr; }
    .label-tools { grid-template-columns: 1fr; }
    .label-cart-actions { justify-content: stretch; }
    .label-cart-actions .button { flex: 1 1 100%; }
    .quick-product-list > div, .saved-layouts > div { align-items: flex-start; flex-direction: column; }
    .qr-scanner-card .section-head { display: block; }
}
.pdf-preview-card { padding: 0; overflow: hidden; }
.pdf-preview-card iframe { display: block; width: 100%; height: min(78vh, 980px); min-height: 620px; border: 0; background: var(--surface-soft); }
.pdf-mobile-fallback { display: none; }
@media (max-width: 700px) { .pdf-preview-card iframe { min-height: 70vh; } }

/* V8.1 — единая адаптивная система */
.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    transform: translateY(-150%);
    padding: 10px 14px;
    min-height: 44px;
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
}
.skip-link:focus { transform: translateY(0); }
.mobile-topbar, .sidebar-close, .sidebar-backdrop { display: none; }
.sidebar { overflow-y: auto; overscroll-behavior: contain; }
.content, .card, .field, .task-card, .table-card { min-width: 0; }
h1, h2, h3, strong, .task-side, .mono { overflow-wrap: anywhere; }
.button:focus-visible, button:focus-visible, .nav-link:focus-visible, .tab:focus-visible, .link-button:focus-visible,
a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(31, 100, 255, .42);
    outline-offset: 3px;
}
.button[disabled], button[disabled], input[disabled] { opacity: .55; cursor: wait; }
.button.danger-outline {
    color: var(--danger);
    border-color: var(--danger-line);
    background: var(--danger-soft);
}
.button.danger-outline:hover { border-color: var(--danger); background: var(--danger-soft); }
.task-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.confirm-card { width: min(680px, 100%); margin-inline: auto; }
.danger-kicker { display: block; margin-bottom: 8px; color: var(--danger); font-size: 12px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.confirm-details { margin: 18px 0; padding: 14px; border-radius: 14px; background: var(--surface-soft); }
.checkbox-row { display: flex; align-items: flex-start; gap: 11px; line-height: 1.45; cursor: pointer; }
.checkbox-row input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--danger); }
.upload-progress .button { justify-self: start; }
.pagination { display: grid; grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr); align-items: center; gap: 12px; margin: 18px 0; }
.pagination > :first-child { justify-self: start; }
.pagination > :last-child { justify-self: end; }
.pagination-status { color: var(--muted); text-align: center; }

@media (max-width: 860px) {
    body { min-width: 0; }
    body.menu-open { overflow: hidden; }
    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: calc(64px + env(safe-area-inset-top));
        padding: calc(10px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
        background: color-mix(in srgb, var(--panel) 96%, transparent);
        border-bottom: 1px solid var(--line);
        box-shadow: 0 7px 24px rgba(30, 45, 80, .08);
        backdrop-filter: blur(14px);
    }
    .mobile-brand { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; color: var(--text); }
    .mobile-brand:hover { text-decoration: none; }
    .mobile-brand .brand-mark { width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto; color: #fff; }
    .mobile-brand strong, .mobile-brand small { display: block; }
    .mobile-brand strong { font-size: 15px; }
    .mobile-brand small { color: var(--muted); font-size: 11px; margin-top: 1px; }
    .mobile-menu-button, .sidebar-close {
        width: 44px;
        height: 44px;
        border: 1px solid var(--line);
        border-radius: 13px;
        background: var(--panel);
        color: var(--text);
        cursor: pointer;
    }
    .js .mobile-menu-button { display: grid; align-content: center; justify-items: center; gap: 4px; }
    .mobile-menu-button span { width: 20px; height: 2px; border-radius: 2px; background: currentColor; }
    .layout { display: block; min-height: calc(100dvh - 64px); }
    .js .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 60;
        width: min(86vw, 330px);
        height: 100dvh;
        padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
        transform: translateX(-105%);
        transition: transform .22s ease;
        box-shadow: 24px 0 60px rgba(7, 14, 28, .25);
        touch-action: pan-y;
    }
    .js .sidebar.is-open { transform: translateX(0); }
    .sidebar-brand { display: grid; grid-template-columns: auto 1fr auto; }
    .js .sidebar-close { display: inline-grid; place-items: center; border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: #fff; font-size: 28px; line-height: 1; }
    .js .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 50;
        display: block;
        border: 0;
        padding: 0;
        background: var(--overlay);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .22s ease, visibility .22s ease;
    }
    .js body.menu-open .sidebar-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
    .nav { margin-top: 22px; gap: 6px; }
    .nav-link { min-height: 46px; display: flex; align-items: center; padding: 12px 14px; }
    .nav-link-count { justify-content: space-between; }
    .sidebar-footer { padding-top: 20px; }
    .sidebar-footer .link-button { min-height: 44px; min-width: 88px; text-align: left; }
    .content { width: 100%; padding: 18px; }
    .page-head { display: flex; flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
    .page-head > .actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 0; }
    .page-head > .actions > .button, .page-head > .actions > form, .page-head > .actions > form .button,
    .page-head > .button { width: 100%; }
    .grid-two { display: grid; grid-template-columns: 1fr; }
    .cards, .cards.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card { margin-bottom: 0; }
    .actions { margin-top: 0; }
    .button, .button.small, .link-button { min-height: 44px; }
    .button.small { padding: 9px 12px; }
    .check-label { margin-top: 0; min-height: 44px; }
    .check-label input, input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }
    .form-actions { justify-content: stretch; }
    .form-actions .button { width: 100%; }
    .section-head { flex-wrap: wrap; align-items: flex-start; }
    .details, .task-details { grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); }
    .details dd { min-width: 0; overflow-wrap: anywhere; }
    .actions-col { min-width: 0; }
    .row-actions { justify-content: flex-start; }
    .task-card-head { align-items: flex-start; }
    .task-footer { align-items: flex-end; }
    .task-card-actions { justify-content: flex-end; }
    .task-chat { max-height: min(58dvh, 580px); overscroll-behavior: contain; }
    .chat-author { flex-wrap: wrap; }
    .selected-file-row { align-items: flex-start; }
    .selected-file-row .link-button { flex: 0 0 auto; padding: 7px 8px; }
    .label-table { min-width: 0; }
    .label-table th:first-child, .label-table td:first-child { position: static; }
    .label-description-input, .label-table textarea, .number-input, .size-input, .quantity-input { min-width: 0 !important; width: 100%; }
    .manual-label-form { align-items: stretch; }
    .scanner-stage { width: 100%; aspect-ratio: 3 / 4; max-height: 68dvh; }
    .scanner-frame { inset: 20% 11%; }
    .qr-scanner-card .actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
    .qr-scanner-card .actions .button { width: 100%; }
    .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mobile-label-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
    .mobile-label-toolbar .select-all-label { min-height: 44px; }
    .card > table.table:not(.mobile-card-table) { display: block; max-width: 100%; overflow-x: auto; }
    .pagination { grid-template-columns: 1fr auto 1fr; gap: 8px; }
    .pagination .button { min-width: 0; }
}

@media (max-width: 860px) {
    .table-card {
        overflow: visible;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    .mobile-card-table, .mobile-card-table tbody { display: block; width: 100%; min-width: 0 !important; }
    .mobile-card-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .mobile-card-table tbody { display: grid; gap: 12px; }
    .mobile-card-table tbody tr {
        display: block;
        min-width: 0;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: var(--panel);
        box-shadow: 0 8px 24px rgba(30, 45, 80, .06);
    }
    .mobile-card-table tbody td {
        display: grid;
        grid-template-columns: minmax(94px, 34%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        width: 100%;
        min-width: 0;
        padding: 11px 13px;
        border-bottom: 1px solid var(--line);
        text-align: left;
        overflow-wrap: anywhere;
    }
    .mobile-card-table tbody td:last-child { border-bottom: 0; }
    .mobile-card-table tbody td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        line-height: 1.35;
        text-transform: uppercase;
        letter-spacing: .035em;
    }
    .mobile-card-table tbody td[colspan] { display: block; }
    .mobile-card-table tbody td[colspan]::before { display: none; }
    .mobile-card-table tbody td.row-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: stretch;
    }
    .mobile-card-table tbody td.row-actions::before { flex: 1 0 100%; }
    .mobile-card-table tbody td.row-actions .button,
    .mobile-card-table tbody td.row-actions form { flex: 1 1 132px; }
    .mobile-card-table tbody td.row-actions form .button { width: 100%; }
    .mobile-card-table input, .mobile-card-table select, .mobile-card-table textarea { min-width: 0; }
    .label-table tbody td:first-child { background: var(--surface-soft); }
    .label-table tbody td:first-child::before { align-self: center; }
    .pdf-preview-card { min-height: 180px; display: grid; place-items: center; padding: 24px; text-align: center; }
    .pdf-preview-card iframe { display: none; }
    .pdf-mobile-fallback { display: block; color: var(--muted); line-height: 1.5; }
}

@media (max-width: 520px) {
    .content { padding: 14px 12px calc(18px + env(safe-area-inset-bottom)); }
    h1 { font-size: clamp(23px, 7.2vw, 28px); line-height: 1.15; }
    h2 { font-size: 18px; }
    .card { padding: 14px; border-radius: 15px; }
    .cards, .cards.three { gap: 10px; }
    .stat { padding: 13px; }
    .stat strong { font-size: 21px; }
    .task-card-head { display: grid; gap: 5px; }
    .task-card-head time { white-space: normal; }
    .task-footer { align-items: stretch; flex-direction: column; }
    .task-card-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .task-card-actions .button { width: 100%; }
    .chat-message { width: 100%; }
    .chat-author { display: grid; gap: 3px; }
    .chat-author time { white-space: normal; }
    .task-chat { max-height: min(62dvh, 580px); overflow-y: auto; }
    .details, .task-details, .confirm-details { grid-template-columns: 1fr; gap: 3px; }
    .details dd { margin-bottom: 10px; }
    .confirm-details dd:last-child { margin-bottom: 0; }
    .confirm-card .actions { display: grid; grid-template-columns: 1fr; }
    .confirm-card .actions .button { width: 100%; }
    .media-grid { grid-template-columns: 1fr; }
    .qr-scanner-card .actions { grid-template-columns: 1fr; }
    .login-card { padding: 20px; border-radius: 18px; }
    .pagination { grid-template-columns: 1fr 1fr; }
    .pagination-status { grid-column: 1 / -1; grid-row: 1; }
    .pagination > :first-child { grid-column: 1; grid-row: 2; width: 100%; }
    .pagination > :last-child { grid-column: 2; grid-row: 2; width: 100%; }
}

@media (max-width: 400px) {
    .cards, .cards.three { grid-template-columns: 1fr; }
    .page-head > .actions { grid-template-columns: 1fr; }
    .task-card-actions { grid-template-columns: 1fr; }
    .mobile-card-table tbody td { grid-template-columns: 1fr; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* V8.2 — товары: таблица на широком экране, компактный режим на ноутбуке,
   карточки без горизонтальной прокрутки на планшете и телефоне. */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.product-page-intro { min-width: 0; }
.product-page-intro p { max-width: 780px; line-height: 1.4; }
.product-page-actions { flex: 0 1 720px; }
.filters.product-filters {
    grid-template-columns: minmax(250px, 2fr) minmax(150px, .8fr) minmax(160px, .8fr) minmax(110px, auto);
    align-items: stretch;
}
.product-filter-submit { min-width: 110px; }
.filters.archive-filters { grid-template-columns: minmax(250px, 1fr) auto; }
.product-table-card { max-width: 100%; }
.product-table { width: 100%; }
.product-table th,
.product-table td { padding: 11px 9px; }
.product-table .product-cell--title { min-width: 105px; }
.product-table .product-cell--title a { display: inline-block; line-height: 1.3; }
.product-table .product-cell--purchase,
.product-table .product-cell--sale { white-space: nowrap; }
.product-table .product-cell--actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(104px, 1fr));
    gap: 6px;
    width: 100%;
    min-width: 330px;
    align-items: stretch;
}
.product-table .product-cell--actions .inline { display: block; margin: 0; min-width: 0; }
.product-table .product-cell--actions .product-action {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    padding: 7px 8px;
    font-size: 12px;
    line-height: 1.15;
    white-space: normal;
}
.product-table--dashboard .product-cell--actions {
    grid-template-columns: repeat(2, minmax(100px, 1fr));
    min-width: 220px;
}
.dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }
.product-detail-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; }
.product-detail-summary .badge { vertical-align: middle; }
.product-detail-actions > .inline { margin: 0; }

/* На обычном ноутбуке оставляем табличное сравнение, но убираем второстепенные
   столбцы. Все действия остаются перед глазами и укладываются в две колонки. */
@media (min-width: 1321px) and (max-width: 1919px) {
    .product-table { table-layout: fixed; font-size: 13px; }
    .product-table .product-col-processor,
    .product-table .product-cell--processor,
    .product-table .product-col-sim,
    .product-table .product-cell--sim,
    .product-table .product-col-imei,
    .product-table .product-cell--imei,
    .product-table .product-col-listed,
    .product-table .product-cell--listed,
    .product-table .product-col-updated,
    .product-table .product-cell--updated { display: none; }
    .product-table .product-col-barcode { width: 86px; }
    .product-table .product-col-memory { width: 64px; }
    .product-table .product-col-color { width: 82px; }
    .product-table .product-col-status { width: 88px; }
    .product-table .product-col-purchase,
    .product-table .product-col-sale { width: 78px; }
    .product-table .product-col-created { width: 92px; }
    .product-table .product-col-actions { width: 276px; min-width: 276px; }
    .product-table .product-cell--actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-width: 0;
    }
    .product-table--dashboard .product-col-actions { width: 230px; min-width: 230px; }
    .product-table--dashboard .product-cell--actions { min-width: 0; }
}

@media (max-width: 1320px) {
    .product-page-head,
    .product-detail-head { flex-direction: column; align-items: stretch; }
    .product-page-actions,
    .product-detail-actions { flex: none; width: 100%; justify-content: flex-start; }
    .product-table-card {
        overflow: visible;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    .product-table,
    .product-table tbody { display: block; width: 100%; min-width: 0; }
    .product-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .product-table tbody { display: grid; gap: 14px; }
    .product-table tbody tr.product-row {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        min-width: 0;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 17px;
        background: var(--panel);
        box-shadow: 0 9px 26px rgba(30, 45, 80, .065);
    }
    .product-table tbody td.product-cell {
        order: 3;
        display: block;
        width: 100%;
        min-width: 0;
        padding: 11px 13px;
        border: 0;
        border-top: 1px solid var(--line);
        text-align: left;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }
    .product-table tbody td.product-cell::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--muted);
        font: 800 10px/1.3 Inter, Arial, sans-serif;
        letter-spacing: .045em;
        text-transform: uppercase;
    }
    .product-table tbody td.product-cell--title {
        order: 1;
        grid-column: span 2;
        min-width: 0;
        border-top: 0;
        background: var(--surface-soft);
        font-size: 16px;
    }
    .product-table tbody td.product-cell--barcode {
        order: 2;
        border-top: 0;
        background: var(--surface-soft);
    }
    .product-table tbody td.product-cell--status {
        order: 2;
        border-top: 0;
        background: var(--surface-soft);
    }
    .product-table tbody td.product-cell--purchase,
    .product-table tbody td.product-cell--sale { font-weight: 750; }
    .product-table tbody td.product-cell--actions {
        order: 10;
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        min-width: 0;
        padding: 13px;
        background: var(--surface-soft);
    }
    .product-table tbody td.product-cell--actions::before { grid-column: 1 / -1; margin-bottom: 0; }
    .product-table tbody td.product-cell--actions .product-action { min-height: 40px; font-size: 13px; }
    .product-table tbody tr.product-empty-row { display: block; }
    .product-table tbody tr.product-empty-row td { display: block; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
    .product-table--dashboard tbody td.product-cell--title { grid-column: span 2; }
    .product-table--dashboard .product-cell--actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
    .product-detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1100px) {
    .filters.product-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .product-filter-search,
    .product-filter-submit { grid-column: 1 / -1; }
    .product-table tbody tr.product-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .product-table tbody td.product-cell--title { grid-column: 1 / -1; }
    .product-table tbody td.product-cell--barcode,
    .product-table tbody td.product-cell--status { border-top: 1px solid var(--line); }
    .product-table tbody td.product-cell--actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .product-table tbody td.product-cell--actions .product-action { min-height: 44px; }
    .product-table--dashboard tbody td.product-cell--title { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
    .product-page-head > .product-page-actions,
    .product-detail-head > .product-detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .product-page-head > .product-page-actions > .button,
    .product-detail-head > .product-detail-actions > .button,
    .product-detail-head > .product-detail-actions > form,
    .product-detail-head > .product-detail-actions > form .button { width: 100%; }
    .product-table.mobile-card-table tbody tr.product-row { display: grid; }
    .product-table.mobile-card-table tbody td.product-cell {
        display: block;
        grid-template-columns: none;
    }
    .product-table.mobile-card-table tbody td.product-cell::before { display: block; }
    .product-table.mobile-card-table tbody td.product-cell--actions { display: grid; }
    .product-table.mobile-card-table tbody td.product-cell--actions::before { display: block; }
}

@media (max-width: 560px) {
    .filters.product-filters { grid-template-columns: minmax(0, 1fr); }
    .filters.archive-filters { grid-template-columns: minmax(0, 1fr); }
    .product-filter-search,
    .product-filter-submit { grid-column: auto; }
    .product-page-intro p { font-size: 14px; }
    .product-table tbody td.product-cell { padding: 10px 11px; }
    .product-table tbody td.product-cell--actions { padding: 11px; }
}

@media (max-width: 400px) {
    .product-page-head > .product-page-actions,
    .product-detail-head > .product-detail-actions,
    .product-table tbody td.product-cell--actions,
    .product-table--dashboard .product-cell--actions { grid-template-columns: minmax(0, 1fr); }
    .product-table tbody td.product-cell--actions .product-action { min-height: 44px; }
}

/* Shared price-tag state is used on products, archive and product details. */
.product-label-button.is-added,
.product-label-button.is-added:hover,
.product-label-button.is-added:disabled {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
    opacity: 1;
    cursor: pointer;
}

.product-label-button.is-pending,
.product-label-button:disabled:not(.is-added) {
    cursor: wait;
}

.product-label-button.is-added:disabled {
    cursor: wait;
}

.product-action-feedback {
    margin: 10px 0;
    padding: 10px 13px;
    border: 1px solid var(--success-line);
    border-radius: 12px;
    background: var(--success-soft);
    color: var(--text);
    font-size: 14px;
}

.product-action-feedback[hidden] {
    display: block;
    visibility: hidden;
}

.product-action-feedback.is-error {
    border-color: var(--danger-line);
    background: var(--danger-soft);
    color: var(--text);
}

.security-card {
    width: min(100% - 24px, 560px);
}

.security-card h1 {
    margin-top: 0;
    font-size: clamp(24px, 5vw, 32px);
}

.security-card img {
    /* TOTP QR code: stays print-paper white in both themes so it keeps scanning. */
    display: block;
    width: min(240px, 100%);
    height: auto;
    margin: 18px auto;
    border-radius: 16px;
    background: #fff;
}

.security-secret {
    overflow-wrap: anywhere;
    user-select: all;
}

.security-recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 20px;
    padding: 18px 18px 18px 40px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
}

@media (max-width: 480px) {
    .security-recovery-codes { grid-template-columns: minmax(0, 1fr); }
}

.toast-stack {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 13px 16px;
    border-radius: 12px;
    background: var(--success);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    box-shadow: var(--shadow-strong);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--danger); }
@media (max-width: 520px) {
    .toast-stack { top: max(12px, env(safe-area-inset-top)); right: 8px; left: 8px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .toast { transition: opacity .01ms !important; transform: none !important; }
}
