* {
    box-sizing: border-box;
}

:root {
    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-alt: #eef3ff;
    --text: #182235;
    --muted: #5f6c82;
    --border: #d7deeb;
    --primary: #1d4ed8;
    --primary-dark: #163ea8;
    --success: #157347;
    --success-bg: #e9f8ef;
    --danger: #c53030;
    --danger-bg: #fff0f0;
    --warning-bg: #fff9e8;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(180deg, #eff4ff 0%, var(--bg) 240px, var(--bg) 100%);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

strong {
    font-weight: 700;
}

code,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #0f172a;
    color: #fff;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    color: inherit;
    text-decoration: none;
}

.brand-link:hover {
    text-decoration: none;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.brand-link strong,
.login-brand h1 {
    display: block;
    margin: 0;
    font-size: 1.05rem;
}

.brand-link small,
.login-brand p {
    display: block;
    color: rgba(255, 255, 255, 0.72);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}


.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 0.92rem;
}

.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.9rem 1.25rem 0;
}

.nav-tabs a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1rem;
    border-radius: 14px 14px 0 0;
    background: rgba(255, 255, 255, 0.64);
    border: 1px solid rgba(215, 222, 235, 0.7);
    border-bottom: none;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
}

.nav-tabs a.is-active {
    background: #fff;
    color: var(--text);
}

.main-shell {
    padding: 0 1.25rem 2rem;
}

.page-hero {
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.page-hero-meta {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}


.page-hero h1 {
    margin: 0.2rem 0 0.5rem;
    font-size: clamp(1.4rem, 2vw, 2rem);
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 800;
}

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

.flash {
    border-radius: 16px;
    padding: 0.95rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--success-bg);
    border-color: #b6e1c4;
    color: #0e5935;
}

.flash-error {
    background: var(--danger-bg);
    border-color: #f0b8b8;
    color: #8a1f1f;
}

.card,
.stat-card,
.notice-card,
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card,
.notice-card,
.stat-card {
    padding: 1.15rem;
}

.card-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.card-grid-sidebar {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header-wrap {
    flex-wrap: wrap;
}

.card-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.stat-card span {
    color: var(--muted);
    font-size: 0.9rem;
}

.stat-card strong {
    font-size: 2rem;
    line-height: 1;
}

.stat-card small {
    color: var(--muted);
}

.stat-link,
.stat-sub-link {
    color: inherit;
    text-decoration: none;
}

.stat-link:hover,
.stat-sub-link:hover {
    text-decoration: underline;
}

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

.is-active-filter {
    border-color: #9bb8ff;
    background: #eef4ff;
}

.badge-stack {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.large-gap {
    gap: 1rem;
}

.source-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.badge-item {
    background: #e8f0ff;
    color: #1d4ed8;
}

.badge-bin {
    background: #e8fbff;
    color: #0f766e;
}

.badge-aisle {
    background: #f1f5ff;
    color: #5b21b6;
}

.badge-unassigned {
    background: #fff1f2;
    color: #be123c;
}

.quick-links {
    display: grid;
    gap: 0.75rem;
}

.quick-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.95rem 1rem;
    background: var(--panel-alt);
    border-radius: 14px;
    border: 1px solid #dbe7ff;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.quick-link:hover {
    text-decoration: none;
    border-color: #a6c2ff;
}

.rule-list {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.75rem;
}

.coverage-block {
    display: grid;
    gap: 1rem;
}

.coverage-block strong {
    display: block;
    font-size: 2rem;
}

.table-wrap {
    overflow-x: auto;
}

.small-table-wrap {
    max-height: 26rem;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

thead th {
    text-align: left;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.8rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: #fbfcff;
}

tbody td {
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid #edf1f7;
    vertical-align: top;
}

tbody tr:hover {
    background: #fafcff;
}

.stack-form {
    display: grid;
    gap: 0.95rem;
}

.stack-form label,
.inline-form {
    display: grid;
    gap: 0.35rem;
}

.stack-form label span,
.inline-form span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.78rem 0.85rem;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(29, 78, 216, 0.15);
    border-color: #9bb8ff;
}

textarea {
    min-height: 7rem;
    resize: vertical;
}

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 0.65rem;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

.field-grid {
    display: grid;
    gap: 0.85rem;
}

.field-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.form-help {
    margin: -0.25rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.78rem 1rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: #eef2ff;
    color: #1e293b;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
}

.button:hover {
    text-decoration: none;
}

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

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

.button-light {
    background: #fff;
    border-color: var(--border);
}

.button-small {
    padding: 0.55rem 0.8rem;
    font-size: 0.86rem;
}

.button-block {
    width: 100%;
}

.sticky-card {
    position: sticky;
    top: 1rem;
    align-self: start;
}

.notice-card {
    background: #f8fbff;
}

.notice-card.compact {
    padding: 0.9rem 1rem;
}

.notice-card p,
.notice-card strong {
    margin: 0 0 0.35rem;
}

.warning-card {
    background: var(--warning-bg);
    border-color: #eedca3;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.6rem;
}

.inline-form input,
.inline-form select {
    min-width: 10rem;
}

.search-form {
    flex: 1 1 auto;
    justify-content: flex-end;
}

.scanner-shell {
    min-height: 320px;
    border-radius: 16px;
    overflow: hidden;
    background: #0b1220;
    margin-bottom: 1rem;
}


.scanner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 0.9rem;
}

.scan-status {
    margin: 0 0 0.9rem;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    border: 1px solid #dbe5f0;
    background: #f8fafc;
    font-weight: 600;
}

.scan-status-info {
    color: #0f172a;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.scan-status-success {
    color: #166534;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.scan-status-warn {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

.scan-status-error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.scanner-placeholder {
    min-height: 320px;
    display: grid;
    place-items: center;
    text-align: center;
    color: #cbd5e1;
    padding: 1.25rem;
}

.scanner-shell video,
.scanner-shell canvas,
.scanner-shell img {
    display: block;
    width: 100% !important;
    height: auto !important;
}

.scanner-shell > div {
    max-width: 100%;
}

.hidden-form {
    display: none;
}

.detail-list {
    display: grid;
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.detail-list div {
    display: grid;
    gap: 0.15rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #edf1f7;
}

.detail-list dt {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.detail-list dd {
    margin: 0;
    font-weight: 600;
}

.code-sample {
    margin: 0;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: #0f172a;
    color: #e2e8f0;
    overflow: auto;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.login-shell {
    width: 100%;
    max-width: 440px;
}

.login-card {
    padding: 1.5rem;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.login-brand .brand-mark {
    width: 56px;
    height: 56px;
}

.source-note {
    font-size: 0.9rem;
    color: var(--muted);
}

.scan-result-layout {
    align-items: start;
}

#reader__dashboard {
    padding: 0.8rem;
    background: #111827;
    color: #fff;
}

#reader__scan_region {
    min-height: 220px;
}

#reader button,
#reader select,
#reader input {
    max-width: 100%;
}

@media (max-width: 1100px) {
    .card-grid-4,
    .card-grid-3,
    .card-grid-2,
    .card-grid-sidebar {
        grid-template-columns: 1fr;
    }

    .sticky-card {
        position: static;
    }
}

@media (max-width: 720px) {
    .topbar {
        align-items: start;
        flex-direction: column;
    }

    .nav-tabs {
        gap: 0.35rem;
    }

    .nav-tabs a {
        border-radius: 12px;
        border-bottom: 1px solid rgba(215, 222, 235, 0.7);
        flex: 1 1 calc(50% - 0.35rem);
        min-width: 8rem;
    }

    .main-shell {
        padding: 0 0.85rem 1.5rem;
    }

    .page-hero,
    .card,
    .stat-card,
    .notice-card,
    .login-card {
        border-radius: 16px;
    }

    thead th,
    tbody td {
        padding-left: 0.55rem;
        padding-right: 0.55rem;
    }

    .search-form {
        justify-content: stretch;
    }
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.badge-record-updated {
    background: #ecfdf5;
    color: #047857;
}

.badge-record-local {
    background: #eef2ff;
    color: #4338ca;
}

.badge-record-source {
    background: #f8fafc;
    color: #475569;
}

.candidate-list {
    display: grid;
    gap: 0.85rem;
}

.candidate-card {
    display: grid;
    gap: 0.4rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fbfcff;
    color: var(--text);
    text-decoration: none;
}

.candidate-card:hover {
    text-decoration: none;
    border-color: #9bb8ff;
    box-shadow: 0 8px 20px rgba(29, 78, 216, 0.08);
}

.candidate-card-top {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 0.75rem;
}

@media (max-width: 920px) {
    .field-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
