:root {
    color-scheme: light;
    --ink: #172c30;
    --muted: #4c636a;
    --petrol: #12535c;
    --deep: #0a424a;
    --paper: #fff;
    --ground: #f1f5f7;
    --tint: #dcecee;
    --line: #d3dee1;
    --error: #963724;
    font-family: "Source Sans 3", "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--ground);
    font-size: 16px;
    line-height: 1.45;
}
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
a { color: var(--petrol); text-underline-offset: .2em; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #257caa; outline-offset: 3px; }
main:focus { outline: none; }
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.skip-link:focus {
    position: fixed;
    top: .5rem;
    left: .5rem;
    padding: .7rem 1rem;
    background: white;
    z-index: 10;
}
.workspace { min-height: 100vh; display: grid; grid-template-columns: clamp(13.5rem, 20vw, 18rem) minmax(0, 1fr); }
.sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    padding: 1.45rem 1rem 1rem;
    border-right: 1px solid var(--line);
    background: var(--paper);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    width: fit-content;
    color: var(--ink);
    font-size: clamp(1.14rem, 1.6vw, 1.5rem);
    font-weight: 740;
    letter-spacing: -.035em;
    text-decoration: none;
    white-space: nowrap;
}
.brand img { display: block; object-fit: contain; }
.sidebar > .brand { margin-left: .25rem; }
.sidebar nav { display: grid; gap: .35rem; margin-top: 2.1rem; }
.sidebar nav a {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: .65rem .9rem;
    border-radius: .5rem;
    color: var(--ink);
    font-weight: 560;
    text-decoration: none;
}
.sidebar nav a:hover, .sidebar nav a[aria-current] { background: var(--tint); color: var(--deep); }
.sidebar nav a[aria-current] { font-weight: 700; }
.signout { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem .25rem 0; border-top: 1px solid var(--line); }
.user-name { overflow-wrap: anywhere; font-size: .9rem; color: var(--muted); }
.text-button { border: 0; background: transparent; color: var(--petrol); font-weight: 600; min-height: 42px; padding: .3rem .45rem; }
.text-button:hover { text-decoration: underline; }
.page-body { min-width: 0; }
.topbar { padding: 1rem clamp(1.2rem, 3vw, 3rem); border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: stretch; width: min(100%, 42rem); border: 1px solid #afbec3; border-radius: .5rem; background: white; }
.search input { color: var(--ink); flex: 1; min-width: 0; padding: .6rem .9rem; border: 0; border-radius: .5rem 0 0 .5rem; background: transparent; }
.search button { color: var(--petrol); font-weight: 650; background: transparent; border: 0; border-left: 1px solid var(--line); border-radius: 0 .5rem .5rem 0; padding: .5rem 1rem; }
.search button:hover { background: #eef5f5; }
main { max-width: 94rem; padding: clamp(1.3rem, 3vw, 3rem); }
h1, h2, h3 { line-height: 1.16; overflow-wrap: anywhere; }
h1 { font-size: clamp(2rem, 3.15vw, 3rem); font-weight: 740; letter-spacing: -.045em; }
h2 { font-size: clamp(1.35rem, 2vw, 1.85rem); font-weight: 720; letter-spacing: -.028em; }
h3 { font-size: 1.1rem; font-weight: 650; }
.page-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.page-heading { margin-bottom: 1.35rem; }
.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: .5rem;
    padding: .6rem 1.1rem;
    font-weight: 650;
    line-height: 1.25;
    text-decoration: none;
}
.primary { background: var(--petrol); color: white; }
.primary:hover { background: var(--deep); }
.secondary { background: white; color: var(--petrol); border-color: var(--petrol); }
.secondary:hover { background: #eef5f5; }
.panel, .intake-form, .login-card { border-radius: .95rem; background: var(--paper); border: 1px solid var(--line); }
.panel { padding: clamp(1rem, 2vw, 1.7rem); }
.panel-heading { margin-bottom: 1.6rem; }
.count-line { color: var(--muted); margin-top: .45rem; }
.count-line strong { color: var(--ink); }
.inline-count { display: inline-block; margin-left: .35em; color: var(--petrol); font-variant-numeric: tabular-nums; }
.table-intro { margin-bottom: .75rem; color: var(--muted); font-size: .95rem; }
.lot-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .95rem; }
.lot-table th { padding: .55rem .7rem; color: #365158; background: #e8f0f2; font-weight: 600; }
.lot-table th:first-child { border-radius: .35rem 0 0 .35rem; }
.lot-table th:last-child { border-radius: 0 .35rem .35rem 0; }
.lot-table td { padding: .75rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lot-table tr:last-child td { border-bottom: 0; }
.lot-name { display: flex; align-items: center; gap: .75rem; overflow-wrap: anywhere; }
.lot-name strong { font-weight: 620; }
.lot-name img { flex: 0 0 auto; object-fit: cover; border-radius: .4rem; background: var(--ground); }
.lot-code, .numeric, .added { font-variant-numeric: tabular-nums; }
.numeric, .lot-code { white-space: nowrap; }
.added { color: var(--muted); font-size: .9rem; }
.mobile-label { display: none; }
.empty { padding: 1.3rem 1rem; background: #f4f8f8; border-radius: .55rem; }
.empty p { margin-top: .4rem; color: var(--muted); }
.pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; font-size: .95rem; color: var(--muted); }
.pagination a { padding: .6rem 0; font-weight: 650; }
.messages { margin-bottom: 1.25rem; }
.notice { padding: .85rem 1rem; border-left: 3px solid var(--petrol); background: #dfefea; color: #174839; border-radius: .25rem; }
.notice.error, .form-error { background: #fff1eb; color: var(--error); }
.intake { max-width: 47rem; }
.intake-form, .field-stack { display: grid; gap: 1.3rem; }
.intake-form { padding: clamp(1.2rem, 2.7vw, 2rem); }
.field { min-width: 0; display: flex; flex-direction: column; gap: .45rem; }
.field label { font-weight: 650; }
.field input, .field select, .field textarea, .code-preview {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: .65rem .8rem;
    color: var(--ink);
    background: white;
    border: 1px solid #a4b4ba;
    border-radius: .45rem;
}
.field textarea { resize: vertical; min-height: 5.5rem; height: 5.5rem; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--error); }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.category-row { grid-template-columns: minmax(0, 1.35fr) minmax(0,1fr); }
.code-preview { background: #e7edef; border-color: #c7d3d7; font-variant-numeric: tabular-nums; }
.stepper { display: flex; min-width: 0; }
.stepper.enhanced { border: 1px solid #a4b4ba; border-radius: .45rem; }
.stepper.enhanced input { text-align: center; flex: 1; padding: .5rem .1rem; border: 0; appearance: textfield; border-radius: 0; }
.stepper.enhanced input::-webkit-inner-spin-button, .stepper.enhanced input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper button { flex: 0 0 44px; border: 0; color: var(--ink); background: #eef3f4; border-radius: .45rem 0 0 .45rem; font-size: 1.25rem; }
.stepper button:last-child { border-radius: 0 .45rem .45rem 0; }
.stepper button:hover { background: var(--tint); }
.help { color: var(--muted); font-size: .94rem; }
.preview-message:empty { display: none; }
.field input[type=file] { padding: .4rem; border-color: var(--line); }
.field input::file-selector-button { min-height: 38px; margin-right: .6rem; padding: .4rem .8rem; border-radius: .35rem; border: 0; background: var(--tint); color: var(--deep); font: inherit; font-weight: 600; cursor: pointer; }
.photo-picker.enhanced { position: relative; }
.photo-picker.enhanced input { position: absolute; inset: 0; height: 100%; opacity: 0; z-index: 1; cursor: pointer; }
.picker-face { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; padding: .35rem; border: 1px solid var(--line); border-radius: .45rem; }
.picker-action { display: inline-block; padding: .45rem .8rem; background: var(--tint); color: var(--deep); border-radius: .35rem; font-weight: 600; }
.picker-status { color: var(--muted); font-size: .9rem; }
.photo-picker.enhanced input:focus-visible + .picker-face { outline: 3px solid #257caa; outline-offset: 3px; }
.photo-preview { display: flex; background: white; width: min(100%, 32rem); aspect-ratio: 2 / 1; overflow: hidden; border: 1px solid var(--line); border-radius: .55rem; }
.photo-preview img { display: block; flex: 1 1 0; width: 0; height: 100%; object-fit: contain; }
.submit-bar { display: flex; justify-content: flex-end; padding-top: .35rem; }
.submit-bar button { min-width: 14rem; }
.errorlist { margin: 0; padding-left: 1.25rem; color: var(--error); font-size: .95rem; }
.form-error { padding: .85rem 1rem; border-left: 3px solid var(--error); border-radius: .25rem; }
.form-error p { margin-top: .25rem; }
.guest { min-height: 100vh; display: grid; place-items: center; }
.guest .page-body { width: min(100%, 29rem); }
.guest main { padding: 1rem; }
.login-card { padding: clamp(1.25rem, 4vw, 2.25rem); }
.login-card h1 { margin: 1.6rem 0 1.35rem; font-size: 2rem; }
@media (max-width: 900px) {
    .workspace { grid-template-columns: 12.75rem minmax(0,1fr); }
    .sidebar { padding-inline: .7rem; }
    .lot-table th, .lot-table td { padding-inline: .45rem; }
    .lot-name img { width: 44px; height: 44px; }
}
@media (max-width: 760px) {
    .workspace { display: block; }
    .sidebar { position: static; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .4rem 1rem; height: auto; padding: .55rem 1rem .4rem; border: 0; border-bottom: 1px solid var(--line); }
    .sidebar > .brand { margin: 0; }
    .brand img { width: 35px; height: 35px; }
    .sidebar nav { grid-column: 1/-1; grid-row: 2; display: flex; margin: 0; gap: .25rem; }
    .sidebar nav a { padding: .4rem .75rem; min-height: 40px; font-size: .94rem; }
    .signout { margin: 0; padding: 0; border: 0; justify-content: flex-end; }
    .user-name { display: none; }
    .topbar { padding: .7rem 1rem; }
    main { padding: 1.2rem 1rem; }
    .panel { padding: 1rem; }
    .page-heading { gap: .7rem; }
    .page-new_lot .topbar { display: none; }
    .page-new_lot { background: white; }
    .intake { max-width: 38rem; margin: 0 auto; }
    .intake-form { padding: 0; border: 0; border-radius: 0; }
    .submit-bar { background: white; padding: .35rem 0 max(.65rem, env(safe-area-inset-bottom)); }
    .submit-bar button { width: 100%; min-height: 49px; }
}
@media (max-width: 650px), (min-width: 761px) and (max-width: 1050px) {
    .lot-table, .lot-table tbody { display: block; }
    .lot-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .lot-table tbody tr { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .45rem 1rem; padding: .95rem 0; border-top: 1px solid var(--line); }
    .lot-table td { padding: 0; border: 0; white-space: normal; }
    .lot-table .lot-name { grid-column: 1 / -1; margin-bottom: .25rem; }
    .mobile-label { display: block; font-size: .8rem; color: var(--muted); }
}
@media (max-width: 420px) {
    .field-pair { gap: .65rem; }
    .category-row { grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); }
    .stepper button { flex-basis: 35px; }
    .panel-heading { margin-bottom: 1rem; }
    .panel-heading .button { width: 100%; }
}
