:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #627386;
    --line: #d9e1ea;
    --primary: #1769aa;
    --primary-dark: #104f80;
    --danger: #b42318;
    --success: #16794c;
    --warning: #9a5b00;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

.page {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding: 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.card {
    margin: 16px 0;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    color: #fff;
    background: var(--primary);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
}

.flash {
    margin: 16px 0;
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #eef6ff;
}

.flash.success {
    color: var(--success);
    background: #eaf8f0;
    border-color: #bfe7d1;
}

.flash.error {
    color: var(--danger);
    background: #fff0ee;
    border-color: #f3c2bc;
}

.photo-thumb {
    display: block;
    width: 100%;
    max-width: 180px;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #edf1f5;
}

.scanner-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 12px 0;
}

button.secondary,
.button.secondary {
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
}

button.secondary:hover,
.button.secondary:hover {
    background: #eef1f5;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.scanner-panel {
    margin: 12px 0 18px;
}

.barcode-video {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #111827;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.danger {
    color: var(--danger);
}

.muted {
    color: var(--muted);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 10px;
    border-radius: 999px;
    color: var(--muted);
    background: #eef1f5;
    font-size: 0.875rem;
    font-weight: 700;
}

.status.success {
    color: var(--success);
    background: #eaf8f0;
}

.status.warning {
    color: var(--warning);
    background: #fff5dc;
}

.status.error {
    color: var(--danger);
    background: #fff0ee;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 700;
}

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

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

    .card {
        padding: 14px;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
    }

    td {
        padding: 8px 0;
        border: 0;
    }
}
