:root {
    --ink: #182230;
    --muted: #62748a;
    --line: #dce4ee;
    --surface: #ffffff;
    --surface-soft: #f6f8fb;
    --canvas: #edf2f7;
    --primary: #146c94;
    --primary-dark: #0d4f70;
    --success: #16855b;
    --warning: #a76800;
    --danger: #c53d43;
    --info: #276bba;
    --radius: 14px;
    --shadow: 0 10px 30px rgb(24 34 48 / 8%);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Tahoma, "Noto Sans Thai", "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px clamp(16px, 4vw, 44px);
    color: #fff;
    background: #102a3b;
    box-shadow: 0 2px 12px rgb(0 0 0 / 18%);
}
.brand { display: inline-flex; align-items: center; gap: 9px; flex: 0 0 auto; color: #fff; font-weight: 800; font-size: 19px; }
.brand:hover { color: #fff; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #35b9dc; color: #082131; font-size: 16px; }
.topnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; flex-wrap: wrap; }
.topnav-link, .topnav-dropdown > summary { display: inline-flex; align-items: center; min-height: 36px; padding: 9px 10px; border-radius: 8px; color: #d7e4eb; font-size: 13px; line-height: 1.2; white-space: nowrap; }
.topnav .topnav-link:hover, .topnav .topnav-link.active, .topnav .topnav-dropdown > summary:hover, .topnav .topnav-dropdown > summary.active, .topnav .topnav-dropdown[open] > summary { color: #fff; background: rgb(255 255 255 / 14%); }
.topnav-dropdown { position: relative; flex: 0 0 auto; }
.topnav-dropdown > summary { gap: 7px; cursor: pointer; list-style: none; }
.topnav-dropdown > summary::-webkit-details-marker { display: none; }
.topnav-dropdown > summary:focus-visible, .topnav-submenu a:focus-visible { outline: 3px solid rgb(116 211 241 / 65%); outline-offset: 2px; }
.topnav-dropdown-caret { width: 7px; height: 7px; margin-top: -3px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); transition: transform .16s ease; }
.topnav-dropdown[open] .topnav-dropdown-caret { margin-top: 3px; transform: rotate(225deg); }
.topnav-submenu { position: absolute; z-index: 60; top: calc(100% + 7px); left: 0; display: grid; min-width: 205px; padding: 6px; border: 1px solid #c6d4df; border-radius: 10px; background: #fff; box-shadow: 0 12px 28px rgb(4 21 34 / 22%); }
.topnav-submenu a { display: flex; align-items: center; min-height: 36px; padding: 8px 10px; border-radius: 7px; color: #274359; font-size: 13px; font-weight: 600; line-height: 1.25; }
.topnav-submenu a:hover, .topnav-submenu a.active { color: #0b4f70; background: #e7f5fb; }
.user-menu { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; font-size: 13px; color: #d7e4eb; }
.user-menu a { color: #fff; font-weight: 700; }
.user-menu .button-link { color: #fff; font-weight: 700; }
.inline-form { display: inline; margin: 0; }

.page-shell { width: min(1420px, calc(100% - 36px)); margin: 30px auto 48px; }
.page-shell-auth { width: min(480px, calc(100% - 32px)); margin-top: 7vh; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 0; font-size: clamp(23px, 3vw, 31px); line-height: 1.2; }
.page-heading p { margin: 6px 0 0; color: var(--muted); }
.heading-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card { padding: 22px; }
.panel { overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 17px; }
.panel-body { padding: 20px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dashboard-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card { padding: 18px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 6px 18px rgb(24 34 48 / 6%); }
.stat-card .label { display: block; color: var(--muted); font-size: 13px; }
.stat-card .value { display: block; margin-top: 5px; font-size: 28px; font-weight: 800; }
.stat-card .hint { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 15px; }
.field { grid-column: span 12; min-width: 0; }
.field.col-6 { grid-column: span 6; }
.field.col-4 { grid-column: span 4; }
.field.col-3 { grid-column: span 3; }
.field.col-8 { grid-column: span 8; }
.field.col-2 { grid-column: span 2; }
.field label { display: block; margin-bottom: 6px; font-weight: 700; font-size: 13px; }
.field label .required { color: var(--danger); }
.field small { display: block; margin-top: 4px; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], input[type="date"], select, textarea {
    width: 100%; min-height: 40px; border: 1px solid #b8c6d5; border-radius: 9px; outline: 0; background: #fff; color: var(--ink); padding: 9px 11px;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgb(20 108 148 / 15%); }
input[readonly] { color: #62748a; background: #eef3f7; }
.password-input-wrap { position: relative; min-width: 0; }
.password-input-wrap input[type="password"], .password-input-wrap input[type="text"] { padding-right: 49px; }
.password-visibility-toggle {
    position: absolute;
    top: 50%;
    right: 3px;
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 8px;
    color: #52677f;
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);
}
.password-visibility-toggle:hover { color: var(--primary); background: #edf6fa; }
.password-visibility-toggle:focus-visible { outline: 3px solid rgb(20 108 148 / 22%); outline-offset: 1px; }
.password-eye { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.password-eye-slash { opacity: 0; transition: opacity .12s ease; }
.password-visibility-toggle[aria-pressed="true"] .password-eye-slash { opacity: 1; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 21px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-actions.start { justify-content: flex-start; }

/* The settings page keeps its primary save action in view, including long forms. */
.settings-save-bar {
    position: sticky;
    top: 78px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid #8db9cc;
    border-radius: 11px;
    background: rgb(239 250 254 / 97%);
    box-shadow: 0 8px 18px rgb(24 34 48 / 13%);
    backdrop-filter: blur(8px);
}
.settings-save-bar strong, .settings-save-bar span { display: block; }
.settings-save-bar strong { color: var(--ink); font-size: 14px; }
.settings-save-bar span { margin-top: 1px; color: var(--muted); font-size: 12px; }
.settings-save-bar .button { flex: 0 0 auto; box-shadow: 0 2px 5px rgb(13 79 112 / 20%); }

.button { display: inline-flex; justify-content: center; align-items: center; min-height: 39px; gap: 6px; padding: 8px 13px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; font-size: 14px; transition: background .12s ease, border .12s ease, transform .12s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { color: #fff; background: var(--primary-dark); }
.button-secondary { color: var(--ink); background: #edf2f7; border-color: #ccd6e0; }
.button-secondary:hover { color: var(--ink); background: #dfe9f1; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { color: #fff; background: #a92f35; }
.button-outline { color: var(--primary); background: #fff; border-color: #99bfce; }
.button-small { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.button-link { padding: 0; color: var(--primary); background: none; border: 0; }

.alert { margin-bottom: 17px; border-radius: 10px; padding: 12px 15px; border: 1px solid; font-weight: 600; }
.alert-success { background: #e7f7ef; border-color: #8bd3ad; color: #105f3f; }
.alert-warning { background: #fff6dc; border-color: #e4c46f; color: #785000; }
.alert-danger { background: #ffedf0; border-color: #e5a5ae; color: #8d1e2a; }
.alert-info { background: #eaf4ff; border-color: #9fc9ed; color: #155286; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #52677f; background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover { background: #fbfdff; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.employee-invite-actions { min-width: 230px; flex-wrap: wrap; white-space: normal; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.break-all { overflow-wrap: anywhere; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.pill-info { background: #e7f3fb; color: #13577a; }
.pill-success { background: #e5f7ed; color: #0f6641; }
.pill-warning { background: #fff3d8; color: #875800; }
.pill-danger { background: #ffe6e9; color: #a32331; }
.pill-neutral { background: #edf1f5; color: #55697d; }

.filter-bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.filter-bar .field { flex: 1 1 180px; margin: 0; }
.filter-bar .field label { margin-bottom: 4px; }
.filter-bar .button { margin-bottom: 0; }
.record-photo { width: 46px; height: 46px; display: block; border: 1px solid var(--line); border-radius: 9px; object-fit: cover; background: #eef3f7; }
.record-photo-large { width: 100%; max-width: 250px; aspect-ratio: 1.25; object-fit: cover; border-radius: 11px; border: 1px solid var(--line); background: #eef3f7; }
.photo-placeholder { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 9px; color: #7690a5; background: #e9eff4; font-size: 20px; }
.map-picker-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.map-picker { min-height: 330px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #e9eff4; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(154px, 1fr)); gap: 13px; }
.image-card { padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.image-card img { display: block; width: 100%; aspect-ratio: 1.2; border-radius: 7px; object-fit: cover; background: #eef3f7; }
.image-card .image-caption { display: block; margin: 8px 2px 0; color: var(--muted); font-size: 12px; }

.detail-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 18px; margin-bottom: 18px; }
.detail-key { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.detail-key h1 { margin: 0; font-size: 27px; }
.detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.detail-meta dt { color: var(--muted); font-size: 12px; }
.detail-meta dd { margin: 2px 0 0; font-weight: 700; }
.section-stack { display: grid; gap: 18px; }
#repair-details, #repair-status { scroll-margin-top: 88px; }
.timeline { position: relative; display: grid; gap: 13px; padding-left: 20px; }
.timeline::before { position: absolute; left: 5px; top: 7px; bottom: 7px; width: 2px; content: ''; background: #cad8e4; }
.timeline-item { position: relative; padding: 1px 0 0 10px; }
.timeline-item::before { position: absolute; left: -19px; top: 7px; width: 11px; height: 11px; border: 2px solid #fff; border-radius: 50%; content: ''; background: var(--primary); box-shadow: 0 0 0 2px #9dc6d8; }
.timeline-item p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.timeline-item small { color: #8293a3; }
.totals { display: grid; gap: 7px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand-total { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 18px; font-weight: 800; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 9px; }
.check-item { display: flex; align-items: center; gap: 8px; min-height: 39px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.check-item input { width: 17px; height: 17px; accent-color: var(--primary); }
.login-remember-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 2px 0;
}
.login-remember-toggle {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 9px;
    min-width: 0;
    min-height: 36px;
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
}
.login-remember-label {
    display: inline-block;
    flex: 0 0 auto;
    white-space: nowrap;
}
.login-remember-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}
.login-remember-control {
    display: grid;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    place-items: center;
    border: 1.5px solid #9aabba;
    border-radius: 6px;
    background: #fff;
    box-shadow: inset 0 1px 1px rgb(24 34 48 / 5%);
    transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.login-remember-control::after {
    width: 9px;
    height: 5px;
    margin-top: -2px;
    border: solid #fff;
    border-width: 0 0 2px 2px;
    content: '';
    opacity: 0;
    transform: rotate(-45deg) scale(.7);
    transition: opacity .12s ease, transform .12s ease;
}
.login-remember-toggle input:checked + .login-remember-control {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: 0 2px 5px rgb(20 108 148 / 24%);
}
.login-remember-toggle input:checked + .login-remember-control::after { opacity: 1; transform: rotate(-45deg) scale(1); }
.login-remember-toggle input:focus-visible + .login-remember-control { outline: 3px solid rgb(20 108 148 / 22%); outline-offset: 2px; }
.login-remember-toggle:hover .login-remember-control { border-color: var(--primary); }
.login-remember-toggle input:disabled + .login-remember-control { border-color: #c7d2dc; background: #edf2f6; box-shadow: none; }
.login-remember-toggle:has(input:disabled) { color: #8494a2; cursor: not-allowed; }
.login-remember-help { grid-column: span 12; margin-top: -8px; color: var(--muted); }
.empty-state { padding: 55px 24px; text-align: center; border: 1px dashed #b6c7d7; border-radius: var(--radius); color: var(--muted); background: rgb(255 255 255 / 66%); }
.empty-state h2 { margin: 0 0 6px; color: var(--ink); font-size: 20px; }
.empty-state p { margin: 0 0 18px; }
.pagination { display: flex; justify-content: center; gap: 5px; padding: 18px; }
.pagination a { display: grid; place-items: center; min-width: 32px; height: 32px; border-radius: 7px; color: var(--ink); background: #edf2f7; }
.pagination a.active { color: #fff; background: var(--primary); }

.auth-card { padding: clamp(24px, 5vw, 38px); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 27px; text-align: center; }
.auth-brand .brand-mark { display: inline-grid; width: 47px; height: 47px; margin-bottom: 8px; font-size: 23px; }
.auth-brand h1 { margin: 0; font-size: 25px; }
.auth-brand p { margin: 5px 0 0; color: var(--muted); }

@media (max-width: 1120px) {
    .topbar { gap: 14px; }
    .topnav { order: 3; width: 100%; flex-basis: 100%; }
    .topbar { flex-wrap: wrap; padding-bottom: 8px; }
    .user-menu { margin-left: auto; }
    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .settings-save-bar { top: 122px; }
}
@media (max-width: 800px) {
    .page-shell { width: min(100% - 22px, 1420px); margin-top: 18px; }
    .grid-2, .grid-3, .grid-4, .detail-hero { grid-template-columns: 1fr; }
    .detail-meta { grid-template-columns: 1fr; }
    .page-heading { flex-direction: column; }
    .heading-actions { width: 100%; }
    .heading-actions .button { flex: 1; }
    .field.col-8, .field.col-6, .field.col-4, .field.col-3, .field.col-2 { grid-column: span 12; }
    .map-picker { min-height: 270px; }
    .panel-header { padding: 14px; }
    .panel-body, .card { padding: 15px; }
    th, td { padding: 10px; }
    .hide-mobile { display: none; }
    .settings-save-bar { align-items: stretch; flex-direction: column; gap: 9px; }
    .settings-save-bar .button { width: 100%; }
    .topnav { gap: 4px; }
    .topnav-dropdown[open] { flex-basis: 100%; }
    .topnav-dropdown[open] .topnav-submenu { position: static; width: 100%; min-width: 0; margin-top: 5px; }
    .employee-invite-actions { min-width: 155px; flex-direction: column; align-items: stretch; }
    .employee-invite-actions .inline-form,
    .employee-invite-actions .button { width: 100%; }
}
@media (max-width: 540px) {
    .topbar { padding: 9px 12px; }
    .brand { font-size: 17px; }
    .user-menu span { display: none; }
    .topnav-link, .topnav-dropdown > summary { min-height: 34px; padding: 8px 9px; font-size: 12px; }
    .dashboard-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .value { font-size: 24px; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .button { width: 100%; }
    .filter-bar { padding: 12px; }
    .filter-bar .button { width: 100%; }
}
/* Enhanced image picker: works with a normal file input when JavaScript is unavailable. */
.paste-image-field--ready .paste-image-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}
.paste-image-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.paste-image-reset[hidden] { display: none; }
.paste-image-dropzone {
    display: grid;
    gap: 3px;
    min-height: 112px;
    place-content: center;
    padding: 18px;
    border: 2px dashed #9db9cb;
    border-radius: 11px;
    color: #43677d;
    text-align: center;
    background: #f7fbfd;
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.paste-image-dropzone strong { color: var(--ink); font-size: 14px; }
.paste-image-dropzone span { color: var(--muted); font-size: 12px; }
.paste-image-dropzone:hover, .paste-image-dropzone:focus, .paste-image-dropzone.is-dragging {
    border-color: var(--primary);
    background: #ecf7fb;
    box-shadow: 0 0 0 3px rgb(20 108 148 / 14%);
    outline: 0;
}
.paste-image-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; margin-top: 11px; }
.paste-image-preview:empty { display: none; }
.paste-image-preview-item { position: relative; min-width: 0; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.paste-image-preview-item img { display: block; width: 100%; aspect-ratio: 1.2; object-fit: cover; border-radius: 6px; background: #edf2f7; }
.paste-image-preview-item span { display: block; margin: 5px 2px 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.paste-image-remove { position: absolute; top: 10px; right: 10px; width: 27px; height: 27px; padding: 0; border: 1px solid #fff; border-radius: 50%; color: #fff; background: rgb(110 30 38 / 85%); box-shadow: 0 1px 4px rgb(0 0 0 / 25%); font-size: 0; }
.paste-image-remove::before { content: '×'; font-size: 21px; line-height: 22px; }
.paste-image-remove:hover, .paste-image-remove:focus { background: var(--danger); outline: 2px solid #fff; }
.paste-image-feedback { min-height: 18px; margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.paste-image-feedback.is-error { color: var(--danger); }
.paste-image-camera-overlay { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 20px; background: rgb(15 23 42 / 76%); }
.paste-image-camera-dialog { width: min(100%, 680px); padding: 20px; border-radius: 14px; background: #fff; box-shadow: 0 22px 70px rgb(0 0 0 / 38%); }
.paste-image-camera-dialog h2 { margin: 0 0 12px; }
.paste-image-camera-video { display: block; width: 100%; max-height: 65vh; border-radius: 10px; background: #101827; object-fit: contain; }
.paste-image-camera-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* Goods-received serials are collected in a scan-friendly list. */
.intake-serial-section { margin-top: 24px; padding-top: 21px; border-top: 1px solid var(--line); }
.intake-serial-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.intake-serial-heading h2 { margin: 0; font-size: 17px; }
.intake-serial-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.intake-serial-heading .required { color: var(--danger); }
.intake-serial-list { display: grid; gap: 9px; }
.intake-serial-row { display: grid; grid-template-columns: 37px minmax(0, 1fr) auto; align-items: center; gap: 9px; }
.intake-serial-number { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #155286; background: #eaf4ff; font-size: 13px; font-weight: 800; }
.intake-serial-actions { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-top: 11px; }
.intake-serial-feedback { color: var(--muted); font-size: 12px; }
.intake-serial-feedback.is-error { color: var(--danger); }

/* The product picker remains a normal <select> until JavaScript enhances it. */
.product-search-picker { position: relative; }
.product-search-controls {
    display: grid;
    grid-template-columns: minmax(155px, .42fr) minmax(0, 1fr);
    align-items: end;
    gap: 8px;
}
.product-search-type-field { min-width: 0; }
.product-search-type-label {
    display: block;
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.product-search-type-select { width: 100%; }
.product-search-picker--ready .product-search-select {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.product-search-results {
    position: absolute;
    z-index: 30;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    max-height: 290px;
    overflow-y: auto;
    border: 1px solid #8db9cc;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 10px 22px rgb(24 34 48 / 18%);
}
.product-search-option {
    display: block;
    width: 100%;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid #e6edf3;
    color: var(--ink);
    background: #fff;
    text-align: left;
}
.product-search-option:last-child { border-bottom: 0; }
.product-search-option:hover, .product-search-option.is-active, .product-search-option[aria-selected="true"] { background: #eaf4ff; }
.product-search-option-code { display: block; color: #155286; font-size: 12px; font-weight: 800; }
.product-search-option-name { display: block; margin-top: 1px; font-size: 13px; }
.product-search-option-type { display: block; margin-top: 2px; color: #39708a; font-size: 11px; font-weight: 700; }
.product-search-option-detail { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.product-search-empty { padding: 11px; color: var(--muted); font-size: 13px; }

/* Deletion audit details stay readable without exposing private storage keys. */
.audit-details { min-width: 150px; }
.audit-details > summary { display: inline-flex; list-style: none; cursor: pointer; }
.audit-details > summary::-webkit-details-marker { display: none; }
.audit-details[open] { min-width: min(620px, 75vw); }
.audit-details pre {
    max-width: min(760px, 78vw);
    max-height: 430px;
    margin: 10px 0 0;
    padding: 13px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: #dbeafe;
    background: #172033;
    font: 12px/1.55 Consolas, "Courier New", monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Shared mobile product/serial scanner. Camera access starts only with the scan button. */
.product-scan-feedback {
    margin: 7px 0 0;
    color: #105f3f;
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.product-scan-feedback.is-error { color: #8d1e2a; }
.product-scan-feedback[hidden] { display: none; }
.serial-scanner-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
}
.serial-scanner-control > input {
    width: 100%;
    min-width: 0;
}
.serial-scanner-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 74px;
    min-height: 44px;
    padding: 7px 10px;
    border: 1px solid #78aabd;
    border-radius: 9px;
    color: #0d4f70;
    background: #eaf7fb;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}
.serial-scanner-button:hover { color: #083f5b; background: #d8f0f8; }
.serial-scanner-button:focus-visible {
    outline: 3px solid rgb(20 108 148 / 25%);
    outline-offset: 2px;
}
.serial-scanner-button-icon { font-size: 18px; line-height: 1; }
.serial-scanner-button-label { font-size: 13px; }
.intake-serial-row > .serial-scanner-control { min-width: 0; }

body.serial-scanner-open { overflow: hidden; }
.serial-scanner-modal[hidden] { display: none; }
.serial-scanner-modal {
    position: fixed;
    z-index: 1200;
    inset: 0;
    display: grid;
    align-items: center;
    justify-items: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgb(4 19 28 / 78%);
    backdrop-filter: blur(3px);
}
.serial-scanner-dialog {
    width: min(560px, 100%);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow: auto;
    border: 1px solid #a9c5d1;
    border-radius: 16px;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 24px 70px rgb(0 0 0 / 34%);
}
.serial-scanner-dialog:focus { outline: 0; }
.serial-scanner-dialog:focus-visible {
    outline: 3px solid rgb(83 194 230 / 70%);
    outline-offset: 3px;
}
.serial-scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 12px 18px;
    border-bottom: 1px solid var(--line);
}
.serial-scanner-header h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.serial-scanner-close {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: #42586d;
    background: #eef3f7;
    font-size: 29px;
    font-weight: 400;
    line-height: 1;
}
.serial-scanner-close:hover { color: #8d1e2a; background: #ffedf0; }
.serial-scanner-close:focus-visible {
    outline: 3px solid rgb(20 108 148 / 25%);
    outline-offset: 2px;
}
.serial-scanner-viewport {
    position: relative;
    min-height: 240px;
    overflow: hidden;
    background: #050b0f;
}
.serial-scanner-video {
    display: block;
    width: 100%;
    min-height: 240px;
    max-height: min(58vh, 460px);
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #050b0f;
}
.serial-scanner-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(78%, 390px);
    height: min(48%, 190px);
    border: 3px solid #67ddf6;
    border-radius: 15px;
    box-shadow: 0 0 0 999px rgb(0 0 0 / 20%), inset 0 0 0 1px rgb(255 255 255 / 55%);
    pointer-events: none;
    transform: translate(-50%, -50%);
}
.serial-scanner-frame::after {
    position: absolute;
    top: 50%;
    right: 10px;
    left: 10px;
    height: 2px;
    content: "";
    background: #ff5964;
    box-shadow: 0 0 8px #ff5964;
}
.serial-scanner-status {
    min-height: 48px;
    margin: 0;
    padding: 12px 18px;
    color: #31526a;
    background: #f4f8fb;
    font-size: 13px;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.serial-scanner-status[data-state="success"] { color: #105f3f; background: #e7f7ef; }
.serial-scanner-status[data-state="error"] { color: #8d1e2a; background: #ffedf0; }
.serial-scanner-actions {
    display: flex;
    justify-content: flex-end;
    align-items: stretch;
    gap: 9px;
    padding: 14px 18px 18px;
}
.serial-scanner-actions .button { min-height: 44px; }
.serial-scanner-photo-button {
    position: relative;
    overflow: hidden;
    cursor: pointer;
}
.serial-scanner-photo-button input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}
.serial-scanner-photo-button:focus-within {
    outline: 3px solid rgb(20 108 148 / 25%);
    outline-offset: 2px;
}

@media (max-width: 540px) {
    .product-search-controls { grid-template-columns: 1fr; }
    .intake-serial-heading { align-items: stretch; flex-direction: column; }
    .intake-serial-heading .pill { align-self: flex-start; }
    .intake-serial-row { grid-template-columns: 32px minmax(0, 1fr); }
    .intake-serial-row [data-remove-serial] { grid-column: 2; width: max-content; }
    .intake-serial-actions { align-items: stretch; flex-direction: column; }
    .intake-serial-actions .button { width: 100%; }
    .serial-scanner-button { width: 44px; min-width: 44px; padding: 0; }
    .serial-scanner-button-label { display: none; }
    .serial-scanner-modal { align-items: end; padding: 0; }
    .serial-scanner-dialog {
        width: 100%;
        max-height: 96vh;
        max-height: 96dvh;
        border-width: 1px 0 0;
        border-radius: 18px 18px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .serial-scanner-viewport, .serial-scanner-video { min-height: 230px; }
    .serial-scanner-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .72fr); }
    .serial-scanner-actions .button { width: 100%; }
}
