html, body, #root { margin: 0; min-height: 100%; }
body { background: var(--ds-page); }

/* ---------- app header ---------- */
.wh-top {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px 16px;
    background: var(--ds-ink);
    border-radius: 14px;
    margin-block-end: 8px;
}
.wh-top-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wh-top-row .wh-top-title { flex: 1; }
.wh-brand {
    direction: ltr;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: var(--ds-ochre);
    color: var(--ds-ink);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.wh-actor { font-size: 13px; font-weight: 600; line-height: 1.6; color: var(--ds-white); }
.wh-top-title { font-family: var(--ds-font-display); font-size: 18px; white-space: nowrap; line-height: 1.3; color: var(--ds-white); }
.wh-top-sub { font-size: 12px; line-height: 1.6; color: color-mix(in srgb, var(--ds-white) 72%, transparent); }
.wh-chip-sand { background: var(--ds-ochre); color: var(--ds-ink); font-size: 11.5px; padding: 2px 8px; }

/* ---------- tab bar ---------- */
.file-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-block: 0 8px;
    background: color-mix(in srgb, var(--ds-teal) 10%, var(--ds-page));
    border: 1px solid color-mix(in srgb, var(--ds-teal) 22%, var(--ds-page));
    border-radius: 999px;
    overflow-x: auto;
    scrollbar-width: none;
}
.file-nav::-webkit-scrollbar { display: none; }
.file-nav a {
    flex: 1 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 6px 11px;
    border-radius: 999px;
    color: var(--ds-ink-2);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: none;
}
.file-nav a[aria-current="page"] {
    background: var(--ds-teal);
    color: var(--ds-on-primary);
    font-weight: 600;
    box-shadow: var(--ds-shadow-control);
}
@media (max-width: 600px) {
    .file-nav a { min-height: 44px; font-size: 12.5px; padding: 8px 9px; }
}

.wh-top-note {
    font-size: 12px;
    line-height: 1.6;
    color: color-mix(in srgb, var(--ds-white) 72%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--ds-white) 18%, transparent);
    padding-top: 7px;
    margin-top: 4px;
}
.wh-more summary {
    font-size: 11.5px;
    font-weight: 500;
    color: color-mix(in srgb, var(--ds-white) 62%, transparent);
    cursor: pointer;
    width: fit-content;
}
.wh-more p {
    margin: 4px 0 0;
    font-size: 11.5px;
    line-height: 1.7;
    color: color-mix(in srgb, var(--ds-white) 62%, transparent);
}

/* ---------- sections ---------- */
.wh-sec { margin-block-start: 16px; }
.wh-sec:first-child { margin-block-start: 12px; }
.wh-sec-title {
    margin: 0 0 10px;
    font-family: var(--ds-font-display);
    font-size: 19px;
    font-weight: 400;
    line-height: 1.35;
    color: var(--ds-ink);
}

/* ---------- shared ---------- */
.wh-form { display: flex; flex-direction: column; gap: 14px; margin-block-start: 10px; }
.wh-status-ok { color: var(--ds-teal); font-weight: 600; margin: 4px 0 0; font-size: 14px; line-height: 22px; }
.wh-status-error { color: var(--ds-red); font-weight: 600; margin: 4px 0 0; font-size: 14px; line-height: 22px; }
.wh-submit > * { width: 100%; }
.wh-submit button { width: 100%; min-height: 48px; font-size: 15px; }

.wh-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 20px;
    white-space: nowrap;
}
.wh-chip-teal { background: color-mix(in srgb, var(--ds-teal) 14%, var(--ds-page)); color: var(--ds-teal); }
.wh-chip-red { background: var(--ds-danger-wash); color: var(--ds-red); }
.wh-chip-ochre { background: color-mix(in srgb, var(--ds-ochre) 18%, var(--ds-page)); color: color-mix(in srgb, var(--ds-ochre) 75%, var(--ds-ink)); }
.wh-chip-blue { background: color-mix(in srgb, var(--ds-blue) 14%, var(--ds-page)); color: var(--ds-blue); }
.wh-chip-olive { background: color-mix(in srgb, var(--ds-olive) 18%, var(--ds-page)); color: color-mix(in srgb, var(--ds-olive) 75%, var(--ds-ink)); }

/* ---------- summary stat tiles ---------- */
.wh-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-block-start: 10px;
}
.wh-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background: var(--ds-page);
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius);
}
.wh-stat-num { font-size: 24px; font-weight: 600; line-height: 1.15; }
.wh-stat-label { font-size: 12px; line-height: 17px; color: var(--ds-ink-2); }
.wh-stat-teal {
    background: color-mix(in srgb, var(--ds-teal) 12%, var(--ds-page));
    border-color: color-mix(in srgb, var(--ds-teal) 35%, var(--ds-page));
}
.wh-stat-teal .wh-stat-num { color: var(--ds-teal); }
.wh-stat-red { background: var(--ds-danger-wash); border-color: var(--ds-red-border); }
.wh-stat-red .wh-stat-num { color: var(--ds-red); }
.wh-stat-blue {
    background: color-mix(in srgb, var(--ds-blue) 10%, var(--ds-page));
    border-color: color-mix(in srgb, var(--ds-blue) 30%, var(--ds-page));
}
.wh-stat-blue .wh-stat-num { color: var(--ds-blue); }

/* ---------- quick actions ---------- */
.wh-cta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-block-start: 10px;
}
.wh-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 8px;
    border-radius: var(--ds-radius);
    font-size: 16.5px;
    font-weight: 600;
    color: var(--ds-on-primary);
    text-decoration: none;
    box-shadow: var(--ds-shadow-control);
}
.wh-cta-in { background: var(--ds-teal); }
.wh-cta-out { background: var(--ds-red); }

/* ---------- stock item cards ---------- */
.wh-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr));
    gap: 10px;
    margin-block-start: 12px;
}
@media (min-width: 768px) {
    .wh-items { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
}
.wh-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 13px 14px;
    background: var(--ds-page);
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius);
}
.wh-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.wh-item-name { font-weight: 600; font-size: 15.5px; line-height: 1.4; color: var(--ds-ink); }
.wh-item-balance {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 32px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--ds-teal);
}
.wh-item-unit { font-size: 13.5px; font-weight: 500; color: var(--ds-ink-2); }
.wh-item-meta { font-size: 12.5px; color: var(--ds-ink-2); }
.wh-item-low { background: var(--ds-danger-wash); border-color: var(--ds-red-border); }
.wh-item-low .wh-item-balance { color: var(--ds-red); }
.wh-item-low .wh-item-meta { color: var(--ds-ink); }

/* ---------- low stock strip ---------- */
.wh-low-strip {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-block-start: 16px;
    padding: 12px 14px;
    background: var(--ds-danger-wash);
    border: 1px solid var(--ds-red-border);
    border-radius: var(--ds-radius);
}
.wh-low-title { font-size: 14px; font-weight: 600; color: var(--ds-red); }
.wh-low-items { font-size: 13px; line-height: 1.6; color: var(--ds-ink); }
.wh-low-note { font-size: 12px; line-height: 1.6; color: var(--ds-ink-2); }

/* ---------- in/out action buttons ---------- */
.wh-kind {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-block-start: 12px;
}
.wh-kind-btn {
    appearance: none;
    font: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 14px 12px;
    background: var(--ds-page);
    border: 1.5px solid var(--ds-hairline);
    border-radius: var(--ds-radius);
    font-size: 18px;
    font-weight: 600;
    color: var(--ds-ink);
    cursor: pointer;
}
.wh-kind-btn > span { font-size: 12.5px; font-weight: 400; color: var(--ds-ink-2); }
.wh-kind-in.is-on { background: var(--ds-teal); border-color: var(--ds-teal); color: var(--ds-on-primary); box-shadow: var(--ds-shadow-control); }
.wh-kind-out.is-on { background: var(--ds-red); border-color: var(--ds-red); color: var(--ds-on-primary); box-shadow: var(--ds-shadow-control); }
.wh-kind-btn.is-on > span { color: color-mix(in srgb, var(--ds-on-primary) 88%, transparent); }

/* ---------- stocktake ---------- */
.wh-count {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius);
}
.wh-count-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    font-weight: 600;
    font-size: 15px;
    color: var(--ds-ink);
}
.wh-balance-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--ds-teal) 12%, var(--ds-page));
    color: var(--ds-teal);
    font-size: 13px;
    font-weight: 600;
}
.wh-balance-chip bdi { margin-inline: 5px; }

.wh-diffs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-block-start: 12px;
    padding: 12px 14px;
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius);
}
.wh-diff { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.wh-diff-name { font-weight: 600; color: var(--ds-ink); }

/* ---------- history movement cards ---------- */
.wh-movs { display: flex; flex-direction: column; gap: 8px; margin-block-start: 12px; }
.wh-mov {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    background: var(--ds-page);
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius);
}
.wh-mov-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wh-mov-name { font-weight: 600; font-size: 14.5px; line-height: 1.4; color: var(--ds-ink); }
.wh-mov-detail { font-size: 12.5px; line-height: 1.6; color: var(--ds-ink-2); }
.wh-mov-qty { font-size: 17px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.wh-pos { color: var(--ds-teal); }
.wh-neg { color: var(--ds-red); }

.wh-page { margin: 0; }
.wh-head { display: flex; flex-direction: column; gap: 8px; }
.wh-head .file-nav { margin-block: 0; }
.wh-head .wh-top { margin-block-end: 0; }

/* ---------- contrast pass (text, numbers, borders) ---------- */
.wh-head, .wh-page {
    --ds-hairline: #C6C0B3;
    --ds-ink-2: #55504A;
    --ds-teal: #0E5F52;
}
.wh-top-sub { color: color-mix(in srgb, var(--ds-white) 88%, transparent); }
.wh-more summary, .wh-more p { color: color-mix(in srgb, var(--ds-white) 80%, transparent); }
.file-nav a { color: #55504A; }
.wh-item { border-width: 1.5px; }
.wh-item-balance { font-weight: 700; color: #0E5F52; }
.wh-item-low { border-color: #E09992; }
.wh-item-low .wh-item-balance { color: #B42318; }
.wh-stat-num { font-weight: 700; }
.wh-stat-teal .wh-stat-num { color: #0E5F52; }
.wh-stat-red .wh-stat-num { color: #B42318; }
.wh-stat-blue .wh-stat-num { color: #2456B8; }
.wh-chip-teal { color: #0E5F52; }
.wh-chip-red { color: #B42318; }
.wh-chip-blue { color: #2456B8; }
.wh-status-ok { color: #0E5F52; }
.wh-low-title { color: #B42318; }
.wh-low-strip, .wh-low-strip .wh-item { border-color: #E09992; }
.wh-kind-btn { border-color: #C6C0B3; }

/* ---------- searchable item picker (collapsing combobox) ---------- */
.wh-combo { position: relative; display: flex; flex-direction: column; gap: 6px; }
.wh-combo-label { font-size: 13px; font-weight: 600; color: var(--ds-ink); }
.wh-combo-input {
    font: inherit;
    min-height: 44px;
    padding: 8px 12px;
    background: var(--ds-white);
    color: var(--ds-ink);
    border: 1.5px solid #C6C0B3;
    border-radius: 12px;
}
.wh-combo-input::placeholder { color: var(--ds-ink-2); }
.wh-combo-input:focus { outline: 2px solid var(--ds-teal); outline-offset: 1px; }
.wh-combo-list {
    position: absolute;
    inset-block-start: 100%;
    inset-inline: 0;
    z-index: 30;
    margin-block-start: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 232px;
    overflow-y: auto;
    padding: 6px;
    background: var(--ds-page);
    border: 1.5px solid #C6C0B3;
    border-radius: var(--ds-radius);
    box-shadow: 0 8px 24px rgba(43, 38, 32, 0.18);
}
.wh-pick {
    appearance: none;
    font: inherit;
    text-align: start;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: var(--ds-white);
    border: 1px solid var(--ds-hairline);
    border-radius: 12px;
    cursor: pointer;
    color: var(--ds-ink);
    font-size: 14.5px;
    font-weight: 600;
}
.wh-pick-bal { font-size: 12.5px; font-weight: 500; color: var(--ds-ink-2); white-space: nowrap; }
.wh-pick.is-on { background: var(--ds-teal); border-color: var(--ds-teal); color: var(--ds-on-primary); }
.wh-pick.is-on .wh-pick-bal { color: color-mix(in srgb, var(--ds-on-primary) 85%, transparent); }
.wh-pick-empty { padding: 8px; font-size: 13px; color: var(--ds-ink-2); }

/* ---------- history meta lines ---------- */
.wh-mov-meta { font-size: 12.5px; line-height: 1.6; color: var(--ds-ink-2); }
.wh-mov-k { font-weight: 700; color: #3F3A33; }

/* ---------- movement note editing ---------- */
.wh-note-btn {
    appearance: none;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ds-teal);
    background: none;
    border: none;
    padding: 2px 0;
    cursor: pointer;
    width: fit-content;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.wh-note-editor { display: flex; flex-direction: column; gap: 8px; margin-block-start: 4px; }
.wh-note-actions { display: flex; gap: 8px; }
.wh-note-actions > * { flex: 1; }

/* ---------- compact notes + returns ---------- */
.wh-mov-actions { display: flex; gap: 14px; align-items: center; margin-block-start: 2px; }
.wh-note-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ds-red); margin-inline-end: 5px; }
.wh-ret-btn { color: #8A5A13; }
.wh-note-current {
    font-size: 13px;
    line-height: 1.7;
    color: var(--ds-ink);
    background: color-mix(in srgb, var(--ds-teal) 8%, var(--ds-page));
    border: 1px solid color-mix(in srgb, var(--ds-teal) 25%, var(--ds-page));
    border-radius: 10px;
    padding: 8px 10px;
}

/* ---------- reports & print ---------- */
.wh-rep-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 10px 12px; }
.wh-rep-tab {
    appearance: none;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1.5px solid #C6C0B3;
    background: var(--ds-white);
    color: var(--ds-ink);
    cursor: pointer;
}
.wh-rep-tab.is-on { background: var(--ds-teal); border-color: var(--ds-teal); color: var(--ds-on-primary); }
.wh-report {
    background: var(--ds-white);
    border: 1.5px solid #C6C0B3;
    border-radius: var(--ds-radius);
    padding: 14px;
    overflow-x: auto;
    margin-block-end: 12px;
}
.wh-rep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-bottom: 2px solid #2B2620; padding-bottom: 10px; margin-bottom: 10px; }
.wh-rep-head .wh-brand { background: var(--ds-white); color: #2B2620; border: 2px solid #2B2620; width: 38px; height: 38px; font-size: 15px; }
.wh-rep-title { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: #2B2620; }
.wh-rep-title b { font-size: 16px; }
.wh-rep-meta { width: 100%; font-size: 11.5px; color: #55504A; }
.wh-rep-table { border-collapse: collapse; width: 100%; font-size: 12.5px; color: #2B2620; min-width: 340px; }
.wh-rep-table th, .wh-rep-table td { border: 1px solid #8B857A; padding: 6px 8px; text-align: start; vertical-align: top; }
.wh-rep-table thead th { background: #EDEAE4; font-weight: 700; }
@media print {
    html, body { margin: 0 !important; padding: 0 !important; width: auto !important; min-height: 0 !important; background: #fff !important; }
    body *:not(:has(.wh-report)):not(.wh-report):not(.wh-report *) { display: none !important; }
    body *:has(.wh-report):not(.wh-report) { margin: 0 !important; padding: 0 !important; border: none !important; background: none !important; box-shadow: none !important; border-radius: 0 !important; position: static !important; }
    .wh-report { width: auto; margin: 0; border: none; border-radius: 0; overflow: visible; max-width: none; }
    .wh-rep-table { font-size: 11px; }
}

/* ---------- overflow affordances (nav + report tables) ---------- */
/* No edge fade on the nav: the mask was washing out the active tab. Horizontal scroll stays; the partially visible pill at the edge is the scroll hint. */
.file-nav { scroll-padding-inline: 8px; }
.wh-report { overflow: hidden; position: relative; }
.wh-report-scroll { overflow-x: auto; }
.wh-report::after {
    content: '';
    position: absolute;
    inset-block: 0;
    left: 0;
    width: 26px;
    background: linear-gradient(to right, var(--ds-white), transparent);
    pointer-events: none;
}
.wh-report::before {
    content: '';
    position: absolute;
    inset-block: 0;
    right: 0;
    width: 26px;
    background: linear-gradient(to left, var(--ds-white), transparent);
    pointer-events: none;
    z-index: 1;
}
.wh-rep-table td:nth-child(2), .wh-rep-table th:nth-child(2) { white-space: nowrap; }
.wh-scroll-hint { display: block; text-align: center; font-size: 11.5px; color: #55504A; margin-block-start: 6px; }
@media (min-width: 768px) { .wh-scroll-hint { display: none; } }
@media print {
    .wh-report { overflow: visible; }
    .wh-report::after, .wh-report::before { content: none; }
    .wh-scroll-hint { display: none; }
    .wh-report-scroll { overflow: visible; }
}

/* ---------- login + shared-version header ---------- */
.wh-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.wh-field input { font: inherit; min-height: 44px; padding: 8px 12px; border: 1.5px solid var(--ds-hairline); border-radius: 12px; background: var(--ds-white); font-weight: 400; }
.wh-field input:focus-visible { outline: 2px solid var(--ds-teal); outline-offset: 1px; }
.wh-logout {
    margin-inline-start: 10px; font: inherit; font-size: 12px; font-weight: 600;
    padding: 3px 10px; border-radius: 999px; cursor: pointer;
    border: 1px solid color-mix(in srgb, var(--ds-white) 45%, transparent);
    background: transparent; color: var(--ds-white);
}
