:root {
    color-scheme: light;
    --bg: #e7f0fb;
    --panel: rgba(248, 252, 255, 0.9);
    --panel-border: rgba(48, 88, 140, 0.14);
    --text: #12273f;
    --muted: #5a7391;
    --accent: #1d5f99;
    --accent-soft: #dcecff;
    --secondary: #5f9ed6;
    --danger: #b24b5f;
    --shadow: 0 24px 60px rgba(34, 67, 108, 0.14);
    --bg-top: rgba(74, 135, 212, 0.24);
    --bg-mid: rgba(111, 178, 226, 0.22);
    --bg-bottom: rgba(20, 76, 134, 0.16);
    --bg-base: #f5faff;
    --button-secondary-bg: rgba(95, 158, 214, 0.16);
    --button-danger-bg: rgba(178, 75, 95, 0.14);
    --button-link-bg: rgba(29, 95, 153, 0.1);
    --button-focus: rgba(95, 158, 214, 0.28);
    --hero-stat-bg: linear-gradient(145deg, rgba(29, 95, 153, 0.12), rgba(95, 158, 214, 0.18));
    --video-frame-bg: linear-gradient(135deg, rgba(17, 63, 114, 0.94), rgba(44, 101, 168, 0.88));
}

html[data-theme="classic"] {
    --bg: #efe6d6;
    --panel: rgba(251, 247, 239, 0.92);
    --panel-border: rgba(178, 164, 143, 0.24);
    --text: #3a2b1c;
    --muted: #7b6650;
    --accent: #8e7961;
    --accent-soft: #f7f3ed;
    --secondary: #a08f7c;
    --danger: #9f584d;
    --shadow: 0 20px 50px rgba(82, 69, 43, 0.14);
    --bg-top: rgba(255, 255, 255, 0.34);
    --bg-mid: rgba(245, 238, 228, 0.28);
    --bg-bottom: rgba(198, 182, 159, 0.16);
    --bg-base: #f8f4ec;
    --button-secondary-bg: rgba(255, 255, 255, 0.72);
    --button-danger-bg: rgba(159, 88, 77, 0.14);
    --button-link-bg: rgba(255, 255, 255, 0.62);
    --button-focus: rgba(255, 255, 255, 0.5);
    --hero-stat-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(234, 225, 213, 0.82));
    --video-frame-bg: linear-gradient(135deg, rgba(168, 149, 125, 0.94), rgba(244, 239, 232, 0.9));
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, var(--bg-top), transparent 34%),
        radial-gradient(circle at 85% 20%, var(--bg-mid), transparent 28%),
        radial-gradient(circle at bottom right, var(--bg-bottom), transparent 30%),
        linear-gradient(180deg, var(--bg-base) 0%, var(--bg) 100%);
}

.app-shell {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.hero,
.panel {
    background: var(--panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 2fr 1fr;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.hero-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.hero-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.theme-picker {
    display: grid;
    gap: 0.3rem;
    min-width: 180px;
    color: var(--muted);
    font-size: 0.9rem;
}

.theme-picker select {
    border: 1px solid rgba(48, 88, 140, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    padding: 0.8rem 1rem;
    color: var(--text);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--secondary);
    margin-bottom: 0.75rem;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1.02;
    margin-bottom: 1rem;
}

.hero-copy,
.panel-header p,
.empty-state,
.scanner-hint,
.batch-list,
.meta-list {
    color: var(--muted);
}

.hero-stats {
    display: grid;
    gap: 1rem;
}

.hero-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-stats div {
    padding: 1rem;
    border-radius: 18px;
    background: var(--hero-stat-bg);
    border: 1px solid rgba(48, 88, 140, 0.1);
}

.hero-stats span {
    display: block;
    font-size: 2rem;
    font-weight: 700;
}

.panel {
    padding: 1.5rem;
}

.provider-routing-summary,
.tag-list,
.provider-card-pills,
.provider-tags {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.provider-routing-summary {
    margin: 1rem 0;
}

.tag-list {
    margin-bottom: 1rem;
}

.provider-routing-list {
    display: grid;
    gap: 1rem;
}

.provider-card {
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 1rem 1.1rem;
    background: rgba(255, 255, 255, 0.5);
}

.provider-card-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
    margin-bottom: 0.85rem;
}

.provider-card h3 {
    margin-bottom: 0.25rem;
}

.provider-card p {
    margin-bottom: 0;
    color: var(--muted);
}

.provider-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 180px));
    gap: 1rem;
    margin-bottom: 0.9rem;
}

.provider-enabled-toggle {
    width: 1.2rem;
    height: 1.2rem;
    margin-top: 0.4rem;
}

.provider-order-input {
    max-width: 140px;
}

.provider-filter-bar {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.provider-filter-label {
    color: var(--muted);
    font-size: 0.92rem;
    padding-top: 0.5rem;
}

.provider-filter-chip.is-active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 24px rgba(29, 95, 153, 0.18);
}

.pill-warning {
    background: rgba(181, 132, 44, 0.14);
    color: #8c671a;
}

.pill-tag {
    background: var(--accent-soft);
    color: var(--accent);
}

.scanner-panel {
    margin-bottom: 1.5rem;
}

.content-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1.5fr 1fr;
    margin-bottom: 1.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
}

.panel-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.camera-picker {
    display: grid;
    gap: 0.3rem;
    min-width: 220px;
    font-size: 0.9rem;
    color: var(--muted);
}

.camera-picker select {
    border: 1px solid rgba(48, 88, 140, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    padding: 0.8rem 1rem;
    color: var(--text);
}

.confidence-picker {
    min-width: 260px;
}

.confidence-picker span {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
}

.confidence-picker input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    padding: 0;
    background: transparent;
    border: 0;
}

.panel-header.compact {
    margin-bottom: 1rem;
}

.lookup-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    margin: 1rem 0;
}

.stack {
    display: grid;
    gap: 0.85rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.95rem;
}

input,
textarea,
button {
    font: inherit;
}

input,
textarea {
    border: 1px solid rgba(48, 88, 140, 0.16);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    padding: 0.9rem 1rem;
    color: var(--text);
}

input[type="checkbox"] {
    border: 0;
    background: transparent;
    padding: 0;
    accent-color: var(--accent);
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--button-focus);
    outline-offset: 1px;
    border-color: rgba(29, 95, 153, 0.28);
}

button {
    border: 0;
    border-radius: 999px;
    padding: 0.9rem 1.25rem;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:hover {
    transform: translateY(-1px);
}

.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.85rem 1.2rem;
    text-decoration: none;
    background: var(--button-link-bg);
    color: var(--accent);
    white-space: nowrap;
}

.primary-button {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 12px 28px rgba(29, 95, 153, 0.24);
}

.secondary-button {
    background: var(--button-secondary-bg);
    color: var(--secondary);
}

.danger-button {
    background: var(--button-danger-bg);
    color: var(--danger);
}

.ghost-button {
    background: transparent;
    border: 1px solid rgba(48, 88, 140, 0.18);
    color: var(--muted);
}

.video-frame {
    position: relative;
    min-height: 240px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--video-frame-bg);
}

.scanner-container,
.scanner-container video,
.scanner-container canvas {
    width: 100%;
    height: 320px;
}

.scanner-container {
    position: relative;
}

.scanner-container video,
.scanner-container canvas {
    object-fit: cover;
    display: block;
}

.scanner-container canvas.drawingBuffer,
.scanner-container canvas.drawing,
.scanner-container video {
    position: absolute;
    inset: 0;
}

.scanner-hint {
    position: absolute;
    inset: auto 1rem 1rem 1rem;
    background: rgba(242, 248, 255, 0.94);
    border-radius: 14px;
    padding: 0.85rem 1rem;
}

.status-banner {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 16px;
    background: var(--accent-soft);
}

.status-banner.status-danger {
    background: rgba(178, 75, 95, 0.12);
    color: var(--danger);
}

.status-banner.status-success {
    background: rgba(29, 95, 153, 0.12);
    color: var(--accent);
}

.permission-panel {
    margin-bottom: 1.5rem;
}

.permission-summary-strong {
    color: var(--text);
    font-weight: 600;
}

.permission-note {
    margin-top: 0.85rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.hidden {
    display: none !important;
}

.product-card,
.candidate-card,
.inventory-card {
    border: 1px solid rgba(48, 88, 140, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
    padding: 1rem;
}

.product-card {
    margin-bottom: 1rem;
}

.product-batch-list {
    margin-top: 1rem;
}

.meta-list,
.batch-list {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.75rem;
    font-size: 0.94rem;
}

.batch-row,
.batch-edit-form,
.batch-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.batch-row {
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(48, 88, 140, 0.08);
}

.batch-edit-form {
    flex-wrap: wrap;
    padding: 0.75rem;
    border: 1px solid rgba(48, 88, 140, 0.12);
    border-radius: 14px;
    background: rgba(247, 251, 255, 0.8);
}

.batch-edit-form label {
    min-width: 150px;
    flex: 1 1 160px;
}

.batch-actions {
    flex-wrap: wrap;
}

.batch-actions button {
    padding: 0.65rem 1rem;
}

.candidate-list,
.inventory-list {
    display: grid;
    gap: 1rem;
}

.review-list {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.review-card {
    display: grid;
    gap: 1rem;
}

.review-card-header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.review-image {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(227, 238, 251, 0.72);
    padding: 0.75rem;
}

.review-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.review-actions button {
    flex: 1 1 180px;
}

.inventory-card header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(29, 95, 153, 0.1);
    color: var(--accent);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
}

.pill-success {
    background: rgba(29, 95, 153, 0.14);
    color: var(--accent);
}

.pill-muted {
    background: rgba(90, 115, 145, 0.12);
    color: var(--muted);
}

.empty-state {
    padding: 1rem;
    border: 1px dashed rgba(48, 88, 140, 0.18);
    border-radius: 16px;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.toolbar-search {
    min-width: min(360px, 100%);
}

.session-actions {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(48, 88, 140, 0.12);
    color: var(--text);
    white-space: nowrap;
}

.role-chip {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--secondary);
}

.auth-shell-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.auth-layout {
    width: min(720px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2.5rem 0 4rem;
}

.auth-panel {
    display: grid;
    gap: 1.25rem;
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.inline-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.inline-checkbox input {
    width: 1rem;
    height: 1rem;
}

.split-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr 1.5fr;
}

.management-grid {
    display: grid;
    gap: 1.5rem;
}

.management-card {
    border: 1px solid rgba(48, 88, 140, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    padding: 1rem;
}

.management-card-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.management-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 0.9rem;
}

.management-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.management-table td,
.management-table th {
    vertical-align: top;
}

.management-table input,
.management-table select {
    width: 100%;
}

.management-table .table-actions {
    min-width: 190px;
}

.table-note {
    color: var(--muted);
    font-size: 0.88rem;
}

.login-help {
    display: grid;
    gap: 0.9rem;
    color: var(--muted);
}

.login-help code {
    font-family: Consolas, "Courier New", monospace;
    background: rgba(255, 255, 255, 0.7);
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

.catalog-create-form {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr 1.2fr 1.5fr auto;
    align-items: end;
}

.catalog-create-description {
    min-width: 0;
}

.page-size-picker {
    display: grid;
    gap: 0.35rem;
    min-width: 140px;
    color: var(--muted);
}

.page-size-picker select {
    border: 1px solid rgba(48, 88, 140, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    padding: 0.8rem 1rem;
    color: var(--text);
}

.count-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    background: rgba(29, 95, 153, 0.1);
    color: var(--accent);
    font-size: 0.9rem;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid rgba(48, 88, 140, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
}

.catalog-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

.catalog-table th,
.catalog-table td {
    padding: 0.9rem 1rem;
    vertical-align: top;
    border-bottom: 1px solid rgba(48, 88, 140, 0.08);
    text-align: left;
}

.catalog-table th {
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: rgba(228, 239, 251, 0.88);
}

.catalog-table tbody tr:last-child td {
    border-bottom: 0;
}

.sort-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    border-radius: 0;
    box-shadow: none;
}

.sort-button:hover {
    transform: none;
    color: var(--accent);
}

.sort-button-active {
    color: var(--accent);
}

.catalog-table input,
.catalog-table textarea {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
}

.catalog-table textarea {
    min-height: 88px;
    resize: vertical;
}

.table-number {
    white-space: nowrap;
    font-weight: 600;
}

.table-actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.table-actions button {
    padding: 0.7rem 1rem;
}

.table-empty {
    text-align: center;
    color: var(--muted);
    padding: 1.4rem;
}

.pagination-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.page-indicator {
    color: var(--muted);
    min-width: 120px;
    text-align: center;
}

@media (max-width: 860px) {
    .hero,
    .content-grid,
    .lookup-form {
        grid-template-columns: 1fr;
    }

    .split-grid {
        grid-template-columns: 1fr;
    }

    .panel-header {
        flex-direction: column;
    }

    .panel-actions {
        width: 100%;
        justify-content: stretch;
    }

    .camera-picker {
        min-width: 0;
        width: 100%;
    }

    .panel-actions button {
        flex: 1 1 0;
    }

    .hero-topbar,
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-topbar-actions {
        justify-content: stretch;
    }

    .link-button {
        width: 100%;
    }

    .session-actions {
        width: 100%;
        justify-content: stretch;
    }

    .session-actions > * {
        width: 100%;
    }

    .theme-picker {
        min-width: 0;
        width: 100%;
    }

    .toolbar-search {
        min-width: 0;
    }

    .catalog-create-form,
    .hero-stats-grid {
        grid-template-columns: 1fr;
    }

    .pagination-bar {
        justify-content: stretch;
    }

    .pagination-bar button,
    .page-indicator {
        width: 100%;
    }
}