:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f3f6fb;
  --navy: #102843;
  --blue: #1769dd;
  --blue-dark: #1058be;
  --red: #db2e39;
  --green: #159b64;
  --amber: #d98709;
  --muted: #68758b;
  --border: #d9e1ec;
  --panel: #fff;
  --shadow: 0 14px 38px rgba(16, 40, 67, .10);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #f3f6fb; }
body { min-height: 100vh; margin: 0; background: #f3f6fb; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; color: #101c31; font-size: clamp(1.7rem, 2.7vw, 2.25rem); line-height: 1.15; }
h2 { margin-bottom: 0; color: #182238; font-size: 1.25rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: #0961d3; font-size: .73rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }

.auth-screen { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 12%, #e5efff, transparent 30%), linear-gradient(145deg, #f7f9fd, #eaf0f8); }
.auth-card { width: min(430px, 100%); padding: 38px; border: 1px solid rgba(217, 225, 236, .92); border-radius: 22px; background: rgba(255, 255, 255, .96); box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 10px; }
.auth-card > .muted { margin-bottom: 24px; line-height: 1.55; }
.brand-mark { display: grid; width: 82px; height: 48px; place-items: center; margin-bottom: 25px; border-radius: 9px; background: var(--red); color: #fff; font-size: 1.3rem; font-style: italic; font-weight: 950; letter-spacing: -.04em; box-shadow: 0 8px 20px rgba(219, 46, 57, .22); }
.brand-mark.small { width: 50px; height: 34px; margin: 0; font-size: .95rem; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 24px 16px 18px; background: var(--navy); color: #fff; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; font-weight: 900; }
.sidebar nav { display: grid; gap: 7px; }
.nav-item { display: flex; min-height: 49px; align-items: center; gap: 13px; padding: 0 15px; border: 0; border-radius: 10px; background: transparent; color: #dbe6f5; font-weight: 750; text-align: left; cursor: pointer; }
.nav-item span { width: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { background: rgba(255, 255, 255, .11); color: #fff; }
.mobile-only { display: none; }
.user-panel { display: grid; align-items: center; gap: 10px; grid-template-columns: 39px minmax(0, 1fr) 36px; margin-top: auto; padding: 18px 5px 0; border-top: 1px solid rgba(255, 255, 255, .13); }
.user-panel strong, .user-panel small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel small { margin-top: 3px; color: #b9c9dd; text-transform: capitalize; }
.avatar { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 50%; background: var(--blue); font-weight: 900; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 1.25rem; cursor: pointer; }
.icon-button:hover { background: rgba(255, 255, 255, .12); }

.content { width: 100%; max-width: 1260px; min-width: 0; margin: 0 auto; padding: 50px 44px 70px; }
.view { display: none; }
.view.active { display: block; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-header .muted { margin: 8px 0 0; }
.panel { border: 1px solid var(--border); border-radius: 16px; background: var(--panel); box-shadow: 0 4px 14px rgba(16, 40, 67, .035); }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 0 20px; border: 1px solid transparent; border-radius: 9px; font-weight: 850; line-height: 1.1; cursor: pointer; transition: background .14s ease, border-color .14s ease, transform .14s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(23, 105, 221, .22); outline-offset: 1px; }
.button:disabled { cursor: not-allowed; opacity: .46; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.secondary { border-color: #ccd7e6; background: #fff; color: #25334a; }
.button.secondary:hover:not(:disabled) { background: #f4f7fb; }
.button.success { background: var(--green); color: #fff; }
.button.danger { border-color: #f0c4c8; background: #fff5f5; color: #bd202b; }
.button.compact { min-height: 34px; padding: 0 12px; font-size: .78rem; }
.button.wide { width: 100%; }
.text-button { width: fit-content; margin: -5px auto 0; padding: 4px 7px; border: 0; background: transparent; color: var(--blue); font-size: .82rem; font-weight: 800; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.password-control { position: relative; display: block; width: 100%; }
.password-control input { padding-right: 66px; }
.password-toggle { position: absolute; top: 50%; right: 6px; min-width: 53px; min-height: 34px; padding: 0 8px; border: 0; border-radius: 7px; background: #edf3fb; color: #185cb9; font-size: .74rem; font-weight: 850; cursor: pointer; transform: translateY(-50%); }
.password-toggle:hover { background: #e0ebfa; }

.status-pill, .table-status { display: inline-flex; align-items: center; border-radius: 999px; font-size: .75rem; font-weight: 850; white-space: nowrap; }
.status-pill { min-height: 32px; padding: 0 13px; }
.status-pill.success, .table-status.completed, .table-status.active { background: #e6f7ee; color: #087446; }
.status-pill.warning, .table-status.in_progress { background: #fff2d9; color: #915802; }
.table-status.inactive { background: #edf0f4; color: #637085; }
.table-status.reset-requested { background: #fff0d5; color: #965b00; }
.table-status { padding: 5px 9px; text-transform: capitalize; }

.scan-hero { padding: clamp(35px, 6vw, 70px) 28px; text-align: center; }
.scanner-illustration { display: grid; width: 76px; height: 76px; place-items: center; margin: 0 auto 20px; border-radius: 50%; background: #e8f1ff; color: var(--blue); font-size: 2.5rem; font-weight: 900; }
.scan-hero h2 { font-size: 1.55rem; }
.scan-hero p { max-width: 620px; margin: 10px auto 25px; color: var(--muted); line-height: 1.55; }
.scan-hero small { display: block; margin-top: 13px; color: #7b8799; }
.scan-form { display: flex; max-width: 720px; gap: 10px; margin: 0 auto; }
.scan-input, .product-scan input { min-width: 0; min-height: 48px; flex: 1; padding: 0 14px; border: 1.5px solid #bfcce0; border-radius: 9px; background: #fff; color: #15233b; }

.order-summary { display: grid; align-items: center; gap: 24px; grid-template-columns: minmax(180px, .8fr) minmax(300px, 1.5fr) auto; margin-bottom: 18px; padding: 22px 24px; }
.order-summary h2 { font-size: 1.75rem; }
.order-summary .muted { margin: 7px 0 0; }
.progress-area { min-width: 0; }
.progress-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.progress-copy strong { font-size: 1.08rem; }
.progress-copy span { color: var(--muted); font-size: .83rem; }
.progress-track { height: 10px; overflow: hidden; border-radius: 999px; background: #e8edf4; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #38a0ee); transition: width .25s ease; }
.product-scan { display: grid; align-items: center; gap: 13px; grid-template-columns: auto minmax(155px, auto) minmax(180px, 1fr) auto; padding: 16px 18px; border-color: #a9ccfb; }
.product-scan span { display: block; margin-top: 3px; color: var(--muted); font-size: .76rem; }
.live-dot { width: 13px; height: 13px; border: 3px solid #cdf0df; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #e8f7ef; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin: 30px 0 14px; }
.item-grid { display: grid; gap: 12px; }
.item-card { display: grid; min-height: 108px; align-items: center; gap: 18px; grid-template-columns: 78px minmax(0, 1fr) auto; padding: 15px 16px; border: 1px solid var(--border); border-radius: 13px; background: #fff; }
.item-card.done { border-color: #b6dfce; background: #f8fdfb; }
.item-image, .image-placeholder { width: 78px; height: 78px; border-radius: 8px; background: #f0f3f7; object-fit: contain; }
.image-placeholder { display: grid; place-items: center; color: #7e8998; font-size: 1.8rem; }
.item-copy { min-width: 0; }
.item-copy strong { display: block; margin-bottom: 7px; overflow-wrap: anywhere; }
.item-copy small { display: block; margin-top: 4px; color: var(--muted); }
.qty-badge { display: grid; min-width: 70px; min-height: 58px; place-items: center; border-radius: 12px; background: #eaf2fd; color: #0b2851; font-size: 1.2rem; font-weight: 900; }
.item-card.done .qty-badge { background: #dff5ea; color: #087446; }
.complete-row { display: flex; justify-content: flex-end; margin-top: 22px; }

.table-panel { overflow: hidden; }
.table-panel table { width: 100%; border-collapse: collapse; }
.table-panel th, .table-panel td { padding: 15px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table-panel th { background: #f8fafd; color: #66738a; font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.table-panel tbody tr:last-child td { border-bottom: 0; }
.table-panel tbody tr:hover { background: #fafcff; }
.empty { margin: 0; padding: 38px 20px; color: var(--muted); text-align: center; }
.two-column { display: grid; align-items: start; gap: 22px; grid-template-columns: minmax(300px, .7fr) minmax(520px, 1.3fr); }
#view-users .two-column { grid-template-columns: 1fr; }
#view-users .form-stack.compact { width: min(560px, 100%); }
#view-users .table-panel { width: 100%; max-width: 100%; }
#view-users .email-cell { display: grid; gap: 7px; min-width: 190px; }
#view-users .email-cell .text-button { margin: 0; padding: 0; }
.form-stack { display: grid; gap: 17px; }
.form-stack.compact { padding: 24px; }
.form-stack label { display: grid; gap: 7px; color: #3d4b61; font-size: .8rem; font-weight: 800; }
.form-stack input, .form-stack select { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #cbd4e0; border-radius: 9px; background: #fff; }
.form-stack small { color: var(--muted); font-weight: 500; line-height: 1.4; }
.settings-layout { display: grid; gap: 22px; }
.settings-card { max-width: 820px; padding: 27px; }
.settings-card h2 { margin: 0; }
.form-grid { display: grid; gap: 15px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.info-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-radius: 10px; background: #edf5ff; color: #16487f; }
.info-banner span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.button-row { display: flex; justify-content: flex-end; gap: 10px; }
.user-actions { display: flex; min-width: 220px; flex-wrap: wrap; gap: 7px; }
.modal-form { text-align: left; }
.modal-form .notice-icon, .modal-form .eyebrow, .modal-form h2, .modal-form .notice-message { text-align: center; }
.password-security-note { margin: -3px 0 0; padding: 10px 12px; border-radius: 8px; background: #fff6df; color: #79510d; font-size: .77rem; line-height: 1.45; }
.available-packing-card { width: min(760px, 100%); border-top-color: var(--amber); }
.available-packing-list { display: grid; gap: 12px; margin-top: 20px; text-align: left; }
.available-order { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: #f9fbfe; }
.available-order-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.available-order-header h3 { margin: 0; font-size: 1.1rem; }
.available-order-meta { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.available-item-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.available-item-list li { display: flex; justify-content: space-between; gap: 14px; padding: 8px 10px; border-radius: 8px; background: #fff; font-size: .82rem; }
.available-item-list span:first-child { overflow-wrap: anywhere; }
.available-item-list strong { white-space: nowrap; }
.available-order .button { justify-self: end; }
.idle-card { border-top-color: var(--amber); }
.idle-card .notice-icon, .available-packing-card .notice-icon { background: #fff1d5; color: var(--amber); }
.reset-card { display: grid; gap: 16px; }
.reset-card h1, .reset-card p { margin: 0; }
.auth-success, .auth-error { padding: 12px 13px; border-radius: 9px; line-height: 1.5; }
.auth-success { background: #e7f7ef; color: #087344; }
.auth-error { background: #fff0f1; color: #a71922; }

.modal { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15, 27, 46, .64); backdrop-filter: blur(5px); }
.result-card, .notice-card { width: min(540px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 30px; border-top: 7px solid var(--green); border-radius: 18px; background: #fff; text-align: center; box-shadow: 0 26px 70px rgba(8, 18, 34, .32); }
.result-card.wrong { border-top-color: var(--red); }
.result-card.duplicate, .notice-card.in-progress, .notice-card.completed { border-top-color: var(--amber); }
.notice-card.invoice-first { border-top-color: var(--red); }
.result-icon, .notice-icon { display: grid; width: 66px; height: 66px; place-items: center; margin: 0 auto 18px; border-radius: 50%; background: #e5f7ee; color: var(--green); font-size: 2rem; font-weight: 900; }
.result-card.wrong .result-icon, .notice-card.invoice-first .notice-icon { background: #ffe8e9; color: var(--red); }
.result-card.duplicate .result-icon, .notice-card.in-progress .notice-icon, .notice-card.completed .notice-icon { background: #fff1d5; color: var(--amber); }
.result-card h2, .notice-card h2 { margin-bottom: 18px; font-size: 1.65rem; }
.result-image { width: 105px; height: 105px; margin: 0 auto 16px; border: 1px solid var(--border); border-radius: 10px; object-fit: contain; }
.result-details { margin: 0 0 18px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; text-align: left; }
.result-details div { display: grid; align-items: center; gap: 12px; grid-template-columns: 100px minmax(0, 1fr); padding: 12px 13px; border-bottom: 1px solid var(--border); }
.result-details div:last-child { border-bottom: 0; }
.result-details dt { color: var(--muted); font-size: .69rem; font-weight: 900; text-transform: uppercase; }
.result-details dd { margin: 0; overflow-wrap: anywhere; font-weight: 750; }
.result-message, .notice-message { color: var(--muted); line-height: 1.55; }
.notice-details { margin: 18px 0; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; text-align: left; }
.notice-details div { display: flex; justify-content: space-between; gap: 15px; padding: 12px 13px; border-bottom: 1px solid var(--border); }
.notice-details div:last-child { border-bottom: 0; }
.notice-details span { color: var(--muted); }
.modal-actions { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; }
.modal-actions .button:only-child, .modal-actions .button.hidden + .button { grid-column: 1 / -1; }

.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(430px, calc(100vw - 44px)); padding: 14px 17px; border-radius: 10px; background: #142944; color: #fff; font-weight: 750; box-shadow: 0 13px 34px rgba(12, 25, 43, .28); }
.toast.error { background: #a8232d; }
.loading { position: fixed; z-index: 60; inset: 0; display: flex; align-items: center; justify-content: center; gap: 13px; background: rgba(248, 250, 253, .8); color: #1c2a40; font-weight: 800; backdrop-filter: blur(2px); }
.spinner { width: 30px; height: 30px; border: 4px solid #cdddf3; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .content { padding: 38px 27px 60px; }
  .two-column { grid-template-columns: 1fr; }
  .order-summary { grid-template-columns: 1fr 1.4fr; }
  .order-summary > .button { grid-column: 1 / -1; }
  .product-scan { grid-template-columns: auto minmax(150px, 1fr) auto; }
  .product-scan > div:nth-child(2) { display: none; }
}

@media (max-width: 760px) {
  .app-shell { display: block; padding-bottom: 74px; }
  .sidebar { position: fixed; z-index: 20; top: auto; right: 0; bottom: 0; left: 0; height: 66px; flex-direction: row; align-items: center; padding: 7px 8px; box-shadow: 0 -8px 28px rgba(11, 29, 50, .18); }
  .side-brand, .user-panel { display: none; }
  .sidebar nav { display: flex; width: 100%; align-items: stretch; justify-content: space-around; gap: 2px; }
  .mobile-only { display: flex; }
  .nav-item { min-width: 0; min-height: 52px; flex: 1; flex-direction: column; justify-content: center; gap: 3px; padding: 4px; font-size: .67rem; text-align: center; }
  .nav-item span { height: 17px; }
  .content { padding: 25px 15px 35px; }
  .page-header { align-items: flex-start; }
  .page-header .button { min-height: 38px; padding: 0 12px; }
  .order-summary { grid-template-columns: 1fr; gap: 18px; }
  .order-summary > .button { grid-column: auto; }
  .product-scan { grid-template-columns: auto minmax(0, 1fr) auto; padding: 13px; }
  .product-scan .button { min-height: 48px; padding: 0 13px; }
  .scan-form { flex-direction: column; }
  .item-card { gap: 12px; grid-template-columns: 58px minmax(0, 1fr) auto; padding: 12px; }
  .item-image, .image-placeholder { width: 58px; height: 58px; }
  .qty-badge { min-width: 52px; min-height: 50px; font-size: 1rem; }
  .responsive-table { overflow-x: auto; }
  .responsive-table table { min-width: 720px; }
  #view-users .responsive-table table { min-width: 980px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-actions { grid-template-columns: 1fr; }
  .modal-actions .button { grid-column: auto !important; }
}

@media (max-width: 460px) {
  .auth-card { padding: 28px 22px; }
  .page-header { flex-direction: column; }
  .status-pill { align-self: flex-start; }
  .product-scan { grid-template-columns: auto minmax(0, 1fr); }
  .product-scan .button { grid-column: 1 / -1; }
  .result-card, .notice-card { padding: 24px 18px; }
  .result-details div { grid-template-columns: 82px minmax(0, 1fr); }
  .item-card { grid-template-columns: 52px minmax(0, 1fr); }
  .item-image, .image-placeholder { width: 52px; height: 52px; }
  .qty-badge { grid-column: 1 / -1; width: 100%; min-height: 38px; }
}
