:root {
    color-scheme: light;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 14px;
    color: #253247;
    background: #f5f7fa;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: #f5f7fa; color: #253247; }
a, a:visited { color: #225a82; }
a:hover { text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, input[type="submit"] { cursor: pointer; }
button, input[type="submit"], .button-link { padding: 9px 13px; border-radius: 4px; }
button.primary, input[type="submit"].primary, .button-link, .button-link:link, .button-link:visited {
    display: inline-flex; justify-content: center; align-items: center;
    background: #205a82; border: 1px solid #205a82; color: #fff; text-decoration: none;
    font-weight: 600; cursor: pointer;
}
button.primary:hover, input[type="submit"].primary:hover, .button-link:hover {
    background: #174766; border-color: #174766; color: #fff;
}
button.secondary { background: #fff; border: 1px solid #b5c1d0; color: #254057; }
button.secondary:hover { background: #edf3f8; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #80b7db; outline-offset: 2px; }
button:disabled { opacity: .6; cursor: not-allowed; }

.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px 28px; padding: 16px max(3%, 22px); background: #173653; color: #fff; }
.brand { display: flex; align-items: center; flex-shrink: 0; gap: 14px; }
.brand strong { font-size: 24px; letter-spacing: -.7px; line-height: 1.15; }
.brand span { opacity: .88; font-size: 13px; line-height: 1.2; }
.topnav { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.topnav a, .topnav a:visited { color: #fff; font-weight: 600; text-decoration: none; }
.topnav a:hover { text-decoration: underline; }
.user-name { opacity: .85; font-size: 13px; }
.logout-form { display: inline; margin: 0; }
.logout-form button { background: transparent; color: #fff; border: 1px solid #ffffff85; padding: 7px 14px; }
.logout-form button:hover { background: #ffffff19; }

.content { max-width: 1500px; margin: 26px auto; padding: 0 22px; min-height: 65vh; }
.footer { text-align: center; font-size: 12px; color: #6b7889; padding: 20px; }
h1 { font-size: 26px; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 18px 0 10px; }
hr { border: 0; border-top: 1px solid #dce3eb; }
.panel { margin: 0 0 20px; padding: 22px 25px; background: #fff; border: 1px solid #dce3eb; border-radius: 8px; box-shadow: 0 3px 16px #2532470a; }
.panel p { line-height: 1.5; }
.narrow { max-width: 470px; margin: 35px auto; }
.panel label { display: block; margin: 14px 0 5px; font-weight: 600; font-size: 13px; }
.panel input:not([type="checkbox"]), .panel select { width: 100%; max-width: 600px; padding: 10px 12px; border: 1px solid #aebed0; border-radius: 4px; background: #fff; color: #203448; }
.panel input[type="checkbox"] { width: auto; }
.error { color: #a31e33; }
.ok { color: #176740; }
.muted { color: #687889; font-size: 13px; }
.alert-panel { padding: 14px 20px; }
.page-heading, .panel-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.panel-heading h2 { margin-bottom: 5px; }
.panel-heading p { margin: 0; }
.panel-heading form { margin: 0; }
.flex { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: #fff; padding: 20px; border: 1px solid #dce3eb; border-radius: 8px; }
.stat strong { display: block; font-size: 27px; margin-bottom: 5px; }
.stat span { color: #6b7889; font-size: 13px; }
.breadcrumbs { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: #687889; font-size: 13px; }
.breadcrumbs a, .breadcrumbs a:visited { color: #225a82; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs [aria-current="page"] { color: #536577; }

.table-scroll { overflow-x: auto; background: #fff; border: 1px solid #dce3eb; border-radius: 7px; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
.data-table th { background: #eaf0f6; text-align: left; font-weight: 600; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid #e2e9ef; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.results-table { width: 100%; margin-top: 0; }
.results-table td { border-right: 1px solid #e2e9ef; }
.sale-item { background: #ffffe5; font-weight: 600; }
.sale-item td { background: #ffffe5; }
.results-table .case-breakdown { white-space: nowrap; font-variant-numeric: tabular-nums; }
.quantity-edit { min-width: 36px; padding: 6px 9px; border: 1px solid #9dabb9; background: #eef2f6; color: #203448; }
.pill { display: inline-block; padding: 3px 8px; background: #e6eef6; color: #295574; border-radius: 15px; font-size: 12px; }
.pill.off { background: #f8e6e8; color: #86262d; }
.permissions { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.permissions label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; }
.permissions input { flex: none; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; gap: 10px; }
.filter-grid label { margin: 0 0 4px; }
.filter-grid input, .filter-grid select { width: 100%; }

#barcode-scanner { position: relative; height: 480px; margin: 10px 0; overflow: hidden; border: 1px solid #aebed0; }
#barcode-scanner video, #barcode-scanner canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#barcode-scanner video { object-fit: cover; }
#barcode-scanner canvas { z-index: 10; }
.quantity-dialog { width: min(94vw, 540px); max-height: 88vh; overflow: auto; padding: 26px; border: 1px solid #aebed0; border-radius: 9px; box-shadow: 0 15px 55px #0004; color: #253247; }
.quantity-dialog::backdrop { background: #0c1e32a8; }
.quantity-dialog label { display: block; font-weight: 600; margin: 16px 0 5px; }
.quantity-dialog input, .quantity-dialog textarea { width: 100%; padding: 10px; border: 1px solid #aebed0; border-radius: 5px; color: #253247; }
.quantity-dialog textarea { resize: vertical; }
.decision-form { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 10px; }
.decision-form:last-child { margin-bottom: 0; }
.decision-form input { width: min(220px, 100%); padding: 7px; border: 1px solid #aebed0; border-radius: 4px; }
.approval-table { min-width: 1050px; }
.approval-product { min-width: 180px; max-width: 340px; }
.approval-product > strong, .approval-product > .muted { display: block; }
.approval-reason { min-width: 130px; max-width: 230px; overflow-wrap: anywhere; }
.approval-decision { min-width: 190px; max-width: 300px; overflow-wrap: anywhere; }
.request-product-details { margin-top: 7px; font-size: 13px; font-weight: 400; }
.request-product-details summary { display: list-item; width: fit-content; color: #225a82; text-decoration: underline; cursor: pointer; }
.request-product-body { margin-top: 10px; padding: 12px; border: 1px solid #dce3eb; border-radius: 5px; background: #f7f9fc; min-width: 275px; }
.item-detail-grid { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(120px, 1.5fr); gap: 0; margin: 0; }
.item-detail-grid dt, .item-detail-grid dd { padding: 7px 0; margin: 0; border-bottom: 1px solid #dce3eb; overflow-wrap: anywhere; }
.item-detail-grid dt { font-weight: 600; }
.item-detail-grid dd { text-align: right; }
.item-detail-links { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.item-detail-links:empty { display: none; }

@media (max-width: 760px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .brand { gap: 8px; }
    .topnav { gap: 12px; }
    .content { margin: 20px auto; padding: 0 14px; }
    .panel { padding: 17px 15px; }
    .data-table { font-size: 12px; }
}

@media (max-width: 600px) {
    .desktop-only { display: none !important; }
    .results-table, .results-table thead, .results-table tbody, .results-table tr, .results-table td { display: block; }
    .results-table thead { display: none; }
    .results-table tr { margin-bottom: 12px; border: 1px solid #cbd6e1; border-radius: 5px; overflow: hidden; }
    .results-table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; border-right: 0; border-bottom: 1px solid #e2e9ef; text-align: right; }
    .results-table td::before { content: attr(data-label); flex: 0 0 42%; font-weight: 600; text-align: left; color: #253247; }
    .results-table td:last-child { border-bottom: 0; }
    .results-table td a { display: inline-block; text-align: right; }
    .results-table td:empty::after { content: '—'; }
    #barcode-scanner { height: 360px; }
}

.approval-note { display: block; margin-top: 6px; }

.quantity-feedback { position: fixed; z-index: 1000; right: 20px; bottom: 20px; width: min(480px, calc(100vw - 28px)); padding: 16px 20px; background: #fff; color: #253247; border: 1px solid #9cb5c9; border-left: 4px solid #205a82; border-radius: 6px; box-shadow: 0 8px 30px #1b354b33; overflow-wrap: anywhere; }
.quantity-feedback p { margin: 0; line-height: 1.5; }
.quantity-feedback a { margin-left: 6px; }
@media (max-width: 600px) { .quantity-feedback { right: 14px; bottom: 14px; } }

.item-detail-link { display: inline-block; margin-left: .65rem; white-space: nowrap; }
