:root {
    color-scheme: light;
    --background: #f4f7f8;
    --surface: #fff;
    --text: #0e2330;
    --muted: #536b7b;
    --line: #d8e2e7;
    --accent: #008579;
    --accent-hover: #006d65;
    --sidebar: #0b202d;
    --danger: #9f273a;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }
body { margin: 0; color: var(--text); background: var(--background); }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.25rem); line-height: 1.15; letter-spacing: -.035em; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .68; }
a { color: var(--accent-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
.account { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.account-content { width: min(100%, 456px); display: grid; gap: 20px; }
.account-setup { width: min(100%, 620px); }
.brand { display: flex; align-items: center; gap: 12px; text-transform: uppercase; }
.brand-mark {
    display: grid; place-items: center; width: 46px; height: 46px;
    flex: 0 0 auto; background: var(--accent); color: white; border-radius: 15px;
}
.brand strong, .brand small { display: block; font-weight: 800; letter-spacing: .06em; }
.brand small { color: var(--accent-hover); font-size: .7rem; letter-spacing: .17em; }
.card {
    padding: clamp(20px, 4vw, 32px); border: 1px solid var(--line); border-radius: 18px;
    background: var(--surface); box-shadow: 0 2px 6px rgb(15 37 47 / 7%);
}
.eyebrow { margin-bottom: 8px; color: var(--accent-hover); text-transform: uppercase; letter-spacing: .14em; font-size: .74rem; font-weight: 750; }
.form-stack { display: grid; gap: 15px; margin-top: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 15px; }
label { display: grid; gap: 7px; font-size: .92rem; font-weight: 650; }
input, select, textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
    min-height: 42px; background: var(--surface); color: var(--text); font-weight: 400;
}
.primary, .secondary {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
    padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
    background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; font-size: .9rem;
}
.primary:hover { background: var(--accent-hover); }
.secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
.link { background: transparent; border: 0; color: var(--accent-hover); text-align: left; font-weight: 650; padding: 6px 0; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: .9rem; line-height: 1.5; }
h1 + p, .muted + a { margin-top: 12px; }
.feedback { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: .9rem; }
.error { color: var(--danger); border-color: #f0c5cd; }
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark; --background: #0d1922; --surface: #142630; --text: #e3edf4;
        --muted: #9eb3bf; --line: #334752; --accent: #008579; --accent-hover: #61cec0;
        --danger: #ffabba;
    }
    .primary:hover { background: #006d65; }
}

:root { --sidebar-width: 260px; }
:root[data-theme="light"] {
    color-scheme: light; --background: #f4f7f8; --surface: #fff; --text: #0e2330;
    --muted: #536b7b; --line: #d8e2e7; --accent-hover: #006d65; --danger: #9f273a;
}
:root[data-theme="dark"] {
    color-scheme: dark; --background: #0d1922; --surface: #142630; --text: #e3edf4;
    --muted: #9eb3bf; --line: #334752; --accent-hover: #61cec0; --danger: #ffabba;
}
.workspace { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
    position: sticky; top: 0; height: 100dvh; padding: 20px 14px;
    display: flex; flex-direction: column; gap: 16px; background: var(--sidebar); color: #e3eff7;
}
.brand-link { color: inherit; text-decoration: none; }
.sidebar .brand small { color: #65dbcb; }
.company {
    display: flex; align-items: center; gap: 9px; padding: 12px;
    border: 1px solid #324953; border-radius: 10px; overflow-wrap: anywhere;
}
.company .sidebar-icon { color: #65dbcb; }
.sidebar nav { overflow: auto; flex: 1; scrollbar-width: thin; scrollbar-color: #58707a transparent; }
.sidebar nav h2 { color: #97adbf; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; margin: 16px 8px 6px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: #e3eff7;
    text-decoration: none; border-radius: 9px; font-size: .88rem; min-height: 40px;
}
.sidebar nav a:focus-visible { outline-offset: -2px; }
.sidebar-icon {
    inline-size: 17px; block-size: 17px; flex: none; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.sidebar-indicator { margin-inline-start: auto; inline-size: 14px; block-size: 14px; }
.sidebar nav a:hover { background: #213744; }
.sidebar nav a[aria-current="page"] { background: #008579; color: #fff; font-weight: 700; }
.account-summary { border-top: 1px solid #324953; padding-top: 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.account-summary small { display: block; color: #97adbf; }
.account-summary button { min-height: 34px; padding: 6px 9px; background: transparent; color: #fff; border-color: #58707a; }
.topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px clamp(14px, 3vw, 32px); min-height: 64px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.topbar-actions, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.topbar .secondary { min-height: 36px; padding: 6px 10px; }
.menu-toggle { display: none; }
.workspace-content { width: min(100%, 1550px); margin: auto; padding: clamp(16px, 4vw, 36px); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 16px; }
.stats .card { padding: 15px; }
.stats dt { color: var(--muted); font-weight: 650; font-size: .85rem; }
.stats dd { margin: 5px 0 0; font-size: 1.5rem; font-weight: 800; }
.workspace-content h2, dialog h2 { font-size: 1.06rem; }
.history { margin-top: 18px; }
.table-scroll, .label-preview { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 10px 9px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); white-space: nowrap; }
.label-preview { display: grid; gap: 10px; }
.label-preview .pcl-lbl { border: 1px solid var(--line); }
.notice-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.notice-body { white-space: pre-line; margin-top: 8px; }
.notice-unread { border-color: #bd8d3e; }
.quick-weights button { min-height: 32px; padding: 5px 9px; }
dialog.card { width: min(calc(100vw - 32px), 560px); color: var(--text); }
dialog::backdrop { background: rgb(10 30 44 / 65%); }
dialog video { display: block; width: 100%; margin-top: 12px; border-radius: 9px; }
#label-print-root { display: none; }
@media (max-width: 1000px) {
    .workspace-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
    .workspace { display: block; }
    .sidebar { display: none; position: fixed; inset: 0 auto 0 0; z-index: 10; width: min(85vw, var(--sidebar-width)); }
    .menu-open .sidebar { display: flex; top: 54px; height: calc(100dvh - 54px); }
    .menu-toggle { display: inline-flex; }
    .topbar { min-height: 54px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}
@media print {
    body.printing-labels > :not(#label-print-root) { display: none !important; }
    body.printing-labels #label-print-root { display: block; }
    body.printing-labels { margin: 0; background: white; }
}

.dashboard-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.dashboard-links { display: flex; flex-wrap: wrap; gap: 12px; }
.dashboard-links a { padding: 12px 16px; text-decoration: none; font-weight: 700; }
.chart-group { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 10px; }
.donut { width: min(100%, 154px); font-size: 26px; font-weight: 750; }
.chart-legend, .bar-chart { list-style: none; padding: 0; margin: 0; }
.chart-legend { flex: 1; min-width: min(100%, 160px); }
.chart-legend li { margin: 5px 0; border-left: 4px solid var(--line); padding-left: 7px; font-size: .83rem; }
.bar-chart { display: grid; gap: 10px; margin-top: 10px; }
.bar-chart li { display: grid; gap: 4px; font-size: .9rem; }
.bar-chart meter { width: 100%; height: 12px; accent-color: var(--accent); }

.module-content { display: grid; gap: 15px; }
.module-content .card { min-width: 0; }
.check-field { display: flex; align-items: center; align-self: center; gap: 8px; }
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; min-height: 0; }
select[multiple] { min-height: 130px; }
select option { padding: 3px 0; }
details > summary { cursor: pointer; font-weight: 700; margin-bottom: 10px; }
.specification { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
dialog.card { max-height: calc(100dvh - 40px); overflow: auto; }
.module-content .actions { margin-block: 3px; }
#access .form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
#access .form-grid > label { min-width: 0; }
#access td:nth-child(2) { overflow-wrap: anywhere; }
#access td .actions { min-inline-size: 12rem; }
#access td .actions button { min-height: 36px; padding: 6px 10px; font-size: .82rem; }
.module-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 14px; }
.stock-grid { display: grid; gap: 6px; overflow: auto; }
.stock-grid-row { display: flex; gap: 5px; }
.stock-cell { flex: 0 0 112px; padding: 7px; border: 1px solid var(--line); border-radius: 6px; min-height: 46px; font-size: .81rem; }
.stock-cell[data-occupied="true"] { background: color-mix(in srgb, var(--surface), var(--accent) 16%); }
.span-form { grid-column: 1 / -1; min-width: 0; }
