:root {
    color-scheme: light;
    font-family: 'Segoe UI', system-ui, sans-serif;
    --canvas: #f4f6f0;
    --white: #fff;
    --ink: #152a29;
    --muted: #50625f;
    --green: #156153;
    --green-dark: #10483e;
    --line: #d7e0da;
    --lime: #dff2bd;
    --radius: .9rem;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
a { color: var(--green-dark); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: .13em; }
button, input, select, textarea { font: inherit; }
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: .65rem;
    min-height: 2.75rem; padding: .59rem 1rem; border: 1px solid transparent; border-radius: .6rem;
    background: var(--green); color: var(--white); font-weight: 650; text-align: center; text-decoration: none; cursor: pointer;
}
button:hover, .button:hover { background: var(--green-dark); }
:focus-visible { outline: 3px solid #479e78; outline-offset: 3px; }
button:disabled { cursor: wait; opacity: .65; }
.button.secondary, button.secondary { color: var(--green-dark); background: var(--white); border-color: #a7c0b4; }
.button.quiet, button.quiet { color: var(--green-dark); background: transparent; }
.button.quiet:hover, button.quiet:hover, .button.secondary:hover, button.secondary:hover { background: #ecf4ee; }

h1, h2, h3, p { margin: 0; }
h1, h2, h3, p, dd, strong, .ref { overflow-wrap: anywhere; }
h1 { font-size: clamp(1.65rem, 4vw, 2.75rem); line-height: 1.05; letter-spacing: -.035em; }
h2 { font-size: clamp(1.1rem, 2.25vw, 1.35rem); line-height: 1.25; letter-spacing: -.015em; }
h3 { font-size: 1.05rem; }
p { line-height: 1.5; }
.muted { color: var(--muted); }

.wrap, .topbar-inner { width: min(100% - 2rem, 69rem); margin-inline: auto; }
.topbar { background: #122c2b; color: var(--white); }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; min-height: 4.3rem; gap: .7rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--white); font-size: 1.3rem; font-weight: 750; text-decoration: none; }
.brand-icon {
    width: 1.85rem; height: 1.85rem; border-radius: .36rem; position: relative; background: var(--lime); flex: none;
}
.brand-icon::before {
    content: ''; position: absolute; inset: .42rem; border: 2px solid #1c4133; border-radius: .14rem;
    background: linear-gradient(#1c4133, #1c4133) center 37% / 100% 2px no-repeat;
}
.account { min-width: 0; display: flex; align-items: center; gap: .75rem; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e0eae5; }
.signout { min-height: 2.65rem; background: transparent; color: var(--white); border-color: #5a736e; font-size: .9rem; }
.tabs { background: var(--white); border-bottom: 1px solid var(--line); }
.tabs .wrap { display: flex; align-items: stretch; gap: clamp(.85rem, 3.5vw, 2.25rem); }
.tabs a { display: flex; align-items: center; min-height: 3rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; padding-top: 3px; }
.tabs a[aria-current] { color: var(--green-dark); border-color: var(--green); }
.skip-link { position: fixed; z-index: 4; top: .5rem; left: .5rem; transform: translateY(-160%); background: var(--white); padding: .7rem; }
.skip-link:focus { transform: none; }
.content { padding-block: clamp(1.1rem, 3vw, 2.3rem) 4rem; }
.hero {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
    padding: clamp(1.15rem, 4vw, 2rem); border: 1px solid #c5ddcc; border-radius: var(--radius);
    background: linear-gradient(120deg, #e4f1e7 30%, #edf4dc); margin-bottom: 1rem;
}
.hero p { color: #354d44; margin-top: .55rem; }
.hero p a { margin-left: .35rem; }
.scan-button { min-height: 3.15rem; padding-inline: 1.2rem; }
.scan-icon {
    height: 1.23rem; width: 1.23rem; flex: 0 0 auto; border: 1px solid currentColor; border-radius: .18rem;
    background: repeating-linear-gradient(90deg, transparent 0 2px, currentColor 2px 3px, transparent 3px 5px) center / 70% 52% no-repeat;
}

.panel { min-width: 0; padding: clamp(.95rem, 2.75vw, 1.45rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.panel > p { margin-block: .45rem .7rem; }
.panel > p:last-child { margin-bottom: 0; }
.panel > .button { margin-top: .5rem; }
.search-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; align-items: end; gap: .8rem; }
label { display: grid; gap: .3rem; font-size: .92rem; font-weight: 650; }
input:not([type=hidden]), select, textarea {
    width: 100%; min-width: 0; min-height: 2.75rem; border: 1px solid #a9bab1; border-radius: .55rem;
    color: var(--ink); background: var(--white); padding: .5rem .65rem; font-size: 1rem; font-weight: 400;
}
textarea { display: block; resize: vertical; }
input::placeholder, textarea::placeholder { color: #667570; }
.stack { display: grid; gap: .8rem; margin-top: .8rem; }
.stack > button { justify-self: start; }
.login-content { min-height: 72vh; display: grid; align-content: center; justify-items: center; gap: .8rem; }
.login-panel, .login-content .notice { width: min(100%, 27rem); }
.login-panel { padding: clamp(1.25rem, 4vw, 2.25rem); }
.login-panel h1 { font-size: clamp(1.55rem, 4vw, 2.15rem); }
.login-panel .stack { margin-top: 1.15rem; }
.login-panel .stack > button { justify-self: stretch; }
.notice { padding: .8rem 1rem; background: #e3f4dd; color: #235139; border: 1px solid #aac9a3; border-radius: .65rem; margin-bottom: 1rem; }
.notice.error { background: #fff1e6; color: #772b14; border-color: #ddab98; }

.section-title { margin: 1.35rem 0 .65rem; display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.empty { background: #f9fbf8; border: 1px dashed #a9bcb1; padding: 1.2rem; border-radius: var(--radius); }
.empty p { margin-top: .4rem; color: var(--muted); }
.empty .button { margin-top: .8rem; }
.product-list { display: grid; gap: .5rem; list-style: none; padding: 0; margin: 0; }
.product-row {
    display: flex; align-items: center; gap: .75rem; min-height: 4.15rem; padding: .75rem .95rem;
    border: 1px solid var(--line); border-radius: .73rem; color: var(--ink); background: var(--white); text-decoration: none;
}
a.product-row:hover { border-color: #75a591; background: #fafffa; }
.item-main { flex: 1; display: grid; gap: .12rem; min-width: 0; }
.ref { color: var(--green-dark); font-size: .82rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.quantity { min-width: 3.2rem; display: flex; flex-direction: column; align-items: flex-end; }
.quantity span, .location-change dd { font-weight: 670; font-variant-numeric: tabular-nums; }
.quantity small, .location-change dt { color: var(--muted); }
.arrow { color: var(--green); font-size: 1.45rem; }
.badge { display: inline-flex; padding: .23rem .55rem; border-radius: .35rem; color: #2e5746; background: #e7f0e8; font-size: .82rem; font-weight: 650; }
.pagination, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
.pagination { justify-content: center; margin-top: 1rem; }
.back { display: inline-block; margin-bottom: .85rem; }
.product-header h1 { margin-top: .35rem; }
.product-header { display: flex; flex-wrap: wrap; align-items: center; gap: clamp(.7rem, 3vw, 1.25rem); }
.product-header > div { flex: 1; min-width: 0; }
.product-preview-toggle, .product-preview-toggle:hover { display: block; flex: none; padding: 0; min-height: 0; background: transparent; border: 0; cursor: zoom-in; }
.product-preview { display: block; width: clamp(4.75rem, 24vw, 7.5rem); height: auto; aspect-ratio: 1; object-fit: contain; border: 1px solid var(--line); border-radius: .6rem; }
.product-preview-toggle[aria-expanded="true"] { flex-basis: 100%; cursor: zoom-out; }
.product-preview-toggle[aria-expanded="true"] .product-preview { width: min(100%, 32rem); margin-inline: auto; max-height: 65vh; aspect-ratio: auto; }
.product-header .ref { font-size: .93rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 1rem; }
.edit-panel, .count-panel { margin-top: .75rem; }
summary { cursor: pointer; font-weight: 650; line-height: 1.45; }
.field-list { padding: 0; }
.field { padding: .65rem 1rem; }
.field + .field { border-top: 1px solid var(--line); }
.field summary { padding-block: .05rem; }
.field summary > span { display: inline-grid; align-items: baseline; grid-template-columns: minmax(7rem, .8fr) minmax(0, 1.2fr); gap: .45rem; width: calc(100% - 1.4rem); vertical-align: top; }
.field-value { font-weight: 400; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.count-form { display: flex; flex-wrap: wrap; align-items: end; gap: .65rem; }
.count-form label { flex: 1 1 11rem; }
.switcher { display: flex; gap: .45rem; margin: 0 0 .85rem; }
.switcher a[aria-current] { background: var(--lime); }
.event-list { display: grid; gap: .75rem; }
.event-meta { display: flex; align-items: center; justify-content: space-between; gap: .55rem; color: var(--muted); font-size: .86rem; margin-bottom: .65rem; }
.event > .ref { margin-top: .2rem; }
.event .actions { margin-top: .8rem; }
.event-note, .location-change dd { white-space: pre-wrap; }
.photo-list { display: grid; gap: .35rem; list-style: none; margin: .7rem 0; padding: 0; }
.photo-list li { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; padding: .55rem .65rem; background: #f3f7f3; border-radius: .4rem; }
.photo-list strong { margin-right: auto; }
.location-change { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin: .7rem 0; }
.location-change > div { background: #f3f7f3; padding: .55rem .65rem; border-radius: .4rem; }
.location-change dt { font-size: .85rem; }
.location-change dd { margin: .2rem 0 0; }
.inventory-line { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: .65rem; }
.inventory-line .location-change { margin: 0; }

dialog { width: min(100% - 1.5rem, 39rem); max-height: 90dvh; padding: clamp(.9rem, 3vw, 1.4rem); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
dialog::backdrop { background: rgb(16 36 35 / .73); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .55rem; margin-bottom: .55rem; }
.camera { position: relative; background: #13201e; margin-bottom: .6rem; border-radius: .55rem; overflow: hidden; }
.camera video { display: block; width: 100%; max-height: 45vh; object-fit: contain; }
.camera-guide { position: absolute; top: 50%; inset-inline: 7%; border-top: 2px dashed #dff2bd; filter: drop-shadow(0 1px 2px #122c2b); pointer-events: none; }
.scan-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-block: .8rem; }
#camera-zoom-picker { display: block; margin-top: .65rem; }
#camera-zoom { display: block; accent-color: var(--green); padding-inline: 0; }
#ocr-options { display: grid; gap: .55rem; }
#ocr-options button { justify-self: start; }

@media (max-width: 740px) {
    .search-form { grid-template-columns: minmax(0, 1fr) auto; }
    .search-form > label:first-of-type { grid-column: 1 / -1; }
    .detail-grid, .inventory-line { grid-template-columns: 1fr; }
    .scan-button { width: 100%; }
}
@media (max-width: 380px) {
    .tabs a { font-size: .86rem; }
    .topbar-inner, .wrap { width: calc(100% - 1.35rem); }
    .location-change { gap: .35rem; }
    .scan-actions button { width: 100%; }
}
