:root {
    --ink: #2f2926;
    --muted: #756a65;
    --line: #e5ddd8;
    --line-strong: #c8baa9;
    --surface: #ffffff;
    --canvas: #f7f3f0;
    --teal: #998780;
    --teal-dark: #998780;
    --teal-soft: #f1ece8;
    --blue-soft: #eee7e2;
    --orange-soft: #f5ece8;
    --red: #8f1111;
    --red-soft: #f8eaea;
    --green: #177245;
    --shadow: 0 18px 50px rgba(79, 59, 51, .10);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; color-scheme: light; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--red); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 38px); line-height: 1.15; letter-spacing: -.035em; }
h2 { margin-bottom: 6px; font-size: 21px; line-height: 1.25; letter-spacing: -.02em; }
code { color: #514742; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
[hidden] { display: none !important; }

.topbar { position: sticky; z-index: 20; top: 0; border-bottom: 1px solid rgba(200, 186, 169, .72); background: rgba(255, 255, 255, .93); backdrop-filter: blur(14px); }
.topbar__inner { display: flex; width: min(1480px, calc(100% - 40px)); min-height: 72px; margin: auto; align-items: center; gap: 32px; }
.brand, .login-brand { display: inline-flex; flex: 0 0 auto; color: var(--ink); align-items: center; gap: 11px; }
.brand:hover { color: var(--ink); }
.brand__mark { display: grid; width: 38px; height: 38px; border-radius: 12px; color: #fff; background: linear-gradient(145deg, #998780 0%, #c8baa9 100%); box-shadow: 0 8px 20px rgba(153, 135, 128, .20); font-weight: 800; place-items: center; }
.brand__mark--large { width: 48px; height: 48px; border-radius: 15px; color: var(--teal-dark); background: #fff; box-shadow: none; font-size: 22px; }
.brand > span:last-child, .login-brand > span:last-child, .account__button > span:last-child, .user-cell > span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.brand small, .login-brand small, .account small, .user-cell small { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.main-nav { display: flex; align-self: stretch; align-items: center; gap: 4px; }
.main-nav a { position: relative; display: flex; height: 100%; padding: 0 13px; color: #665b56; align-items: center; font-size: 14px; font-weight: 650; }
.main-nav a:hover, .main-nav a.active { color: var(--ink); }
.main-nav a.active::after { position: absolute; right: 13px; bottom: -1px; left: 13px; height: 3px; border-radius: 3px 3px 0 0; background: var(--teal-dark); content: ""; }
.account { display: flex; margin-left: auto; align-items: center; gap: 8px; }
.account form { margin: 0; }
.account__button { display: flex; border: 0; color: inherit; background: none; align-items: center; gap: 9px; cursor: pointer; text-align: left; }
.avatar { display: grid; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; color: var(--teal-dark); background: var(--teal-soft); font-size: 13px; font-weight: 800; place-items: center; }
.avatar--large { width: 46px; height: 46px; font-size: 17px; }
.nav-toggle { display: none; margin-left: auto; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 7px 10px; }

.page { width: min(1320px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 70px; }
.page-heading { display: flex; margin-bottom: 26px; align-items: flex-end; justify-content: space-between; gap: 24px; }
.page-heading p { margin-bottom: 0; color: var(--muted); }
.page-heading__actions { display: flex; flex: 0 0 auto; gap: 10px; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--teal-dark); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.eyebrow--light { color: #f3e9e4; }
.muted { color: var(--muted); }
.optional { color: var(--muted); font-size: 12px; font-weight: 450; }

.button { display: inline-flex; min-height: 42px; padding: 9px 17px; border: 1px solid var(--teal); border-radius: 10px; color: #fff; background: var(--teal); align-items: center; justify-content: center; gap: 10px; cursor: pointer; font-weight: 720; transition: .15s ease; }
.button:hover { border-color: var(--red); color: #fff; background: var(--red); transform: translateY(-1px); }
.button:disabled { opacity: .46; cursor: not-allowed; transform: none; }
.button--secondary { border-color: var(--line-strong); color: var(--ink); background: #fff; }
.button--secondary:hover, .button--outline:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.button--outline { border-color: var(--line-strong); color: var(--teal-dark); background: transparent; }
.button--soft { border-color: transparent; color: var(--teal-dark); background: var(--teal-soft); }
.button--soft:hover { border-color: transparent; color: #fff; background: var(--red); }
.button--ghost { border-color: transparent; color: #665b56; background: transparent; }
.button--ghost:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.button--small { min-height: 34px; padding: 6px 11px; border-radius: 8px; font-size: 12px; }
.button--large { min-height: 50px; font-size: 15px; }
.button--wide { width: 100%; justify-content: space-between; }
.icon-button { display: inline-grid; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: #665b56; background: #fff; cursor: pointer; place-items: center; transition: .15s ease; }
.icon-button:hover { border-color: #d9b7b3; color: var(--red); background: var(--red-soft); }
.icon-button--danger:hover { border-color: #efb4af; color: var(--red); background: var(--red-soft); }
.icon-button--success:hover { border-color: #a7d7bb; color: var(--green); background: #eaf8ef; }
.icon-button svg, .stat__icon svg, .empty-state__icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.stat__icon svg { width: 20px; height: 20px; }
.empty-state__icon svg { width: 24px; height: 24px; }

.stats { display: grid; margin-bottom: 22px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.stat { display: flex; min-height: 106px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); align-items: center; gap: 17px; }
.stat__icon { display: grid; width: 48px; height: 48px; border-radius: 14px; font-size: 20px; font-weight: 800; place-items: center; }
.stat__icon--teal { color: var(--teal); background: var(--teal-soft); }
.stat__icon--blue { color: #75655e; background: var(--blue-soft); }
.stat__icon--orange { color: var(--teal-dark); background: var(--orange-soft); }
.stat div { display: flex; flex-direction: column; }
.stat small { color: var(--muted); font-size: 12px; }
.stat strong { margin-top: 2px; font-size: 27px; letter-spacing: -.04em; }
.stat--alert { border-color: #dfaaa5; background: #fff7f6; }

.panel { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 4px 18px rgba(20, 47, 51, .025); }
.panel__toolbar { display: flex; min-height: 72px; padding: 15px 18px; border-bottom: 1px solid var(--line); align-items: center; justify-content: space-between; gap: 18px; }
.panel__footer { padding: 13px 19px; border-top: 1px solid var(--line); color: var(--muted); background: #faf7f5; font-size: 12px; }
.search { display: flex; width: min(570px, 100%); align-items: center; gap: 8px; }
.search > span { margin-right: -37px; z-index: 1; color: #8b7d76; font-size: 22px; pointer-events: none; }
.search input { padding-left: 38px; }
.toolbar-links { display: flex; flex: 0 0 auto; gap: 16px; font-size: 13px; font-weight: 650; }
.filter-form { display: flex; width: 100%; align-items: center; gap: 10px; }
.filter-form select { width: min(380px, 70vw); }

input, select, textarea { width: 100%; min-height: 43px; margin-top: 7px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; color: var(--ink); background: #fff; transition: .15s ease; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(153, 135, 128, .16); }
label { display: block; color: #4f4540; font-size: 13px; font-weight: 690; }
label small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 450; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-note { margin: 4px 0 0; padding: 10px 12px; border-radius: 9px; color: #685d57; background: #f4efec; font-size: 12px; }
.form-note--warning { color: var(--teal-dark); background: var(--orange-soft); }
.check { display: flex; min-height: 42px; margin-top: 5px; align-items: center; gap: 9px; }
.check input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--teal-dark); }
.checkbox { display: flex; align-items: center; gap: 9px; }
.checkbox input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--teal-dark); }
.inline-form { display: inline-flex; margin: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 17px; color: #756a65; background: #faf7f5; font-size: 10px; letter-spacing: .065em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 17px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fcf9f7; }
tbody tr.row--expiration-unknown { background: #fffdf5; box-shadow: inset 4px 0 #d7aa49; }
tbody tr.row--expiring { background: #fff7ea; box-shadow: inset 4px 0 #c97619; }
tbody tr.row--expired { background: #fff0f0; box-shadow: inset 4px 0 var(--red); }
tbody tr.row--expiration-unknown:hover { background: #fff9e8; }
tbody tr.row--expiring:hover { background: #ffefd7; }
tbody tr.row--expired:hover { background: #ffe7e7; }
td strong { font-weight: 720; }
.number { text-align: right; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.actions > * { margin-left: 4px; vertical-align: middle; }
.table-subtitle { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 450; }
.quantity { color: var(--green); font-size: 17px; }
.quantity--empty { color: var(--red); }
.delta--positive { color: var(--green); }
.delta--negative { color: var(--red); }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge--in, .badge--active { color: #146c43; background: #e8f7ee; }
.badge--out { color: #a43c34; background: var(--red-soft); }
.badge--writeoff { color: #7b4c18; background: #fff1d9; }
.badge--inventory { color: #75655e; background: var(--blue-soft); }
.badge--inactive { color: #756a65; background: #eee9e6; }

.empty-state { display: flex; min-height: 280px; padding: 42px 20px; align-items: center; justify-content: center; flex-direction: column; text-align: center; }
.empty-state p { color: var(--muted); }
.empty-state__icon { display: grid; width: 52px; height: 52px; margin-bottom: 14px; border-radius: 15px; color: var(--teal-dark); background: var(--teal-soft); font-size: 23px; font-weight: 800; place-items: center; }
.error-state { min-height: 70vh; }
.error-state h1 { max-width: 660px; margin-bottom: 24px; }
.callout { display: flex; margin: -8px 0 20px; padding: 13px 16px; border: 1px solid var(--line-strong); border-radius: 12px; color: #655952; background: var(--teal-soft); align-items: flex-start; gap: 12px; }
.callout > span { display: grid; width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--teal-dark); font-size: 12px; font-weight: 800; place-items: center; }
.callout p { margin: 0; }

.dialog { width: min(520px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 18px; color: var(--ink); background: var(--surface); box-shadow: 0 25px 90px rgba(47, 33, 28, .28); }
.dialog--compact { width: min(440px, calc(100% - 28px)); }
.dialog::backdrop { background: rgba(47, 33, 28, .55); backdrop-filter: blur(3px); }
.dialog form { display: flex; padding: 25px; flex-direction: column; gap: 15px; }
.dialog__header { display: flex; margin-bottom: 3px; align-items: flex-start; justify-content: space-between; gap: 15px; }
.dialog__header h2, .dialog__header p { margin-bottom: 0; }
.dialog__close { width: 32px; height: 32px; flex: 0 0 auto; border: 0; border-radius: 50%; color: #756a65; background: #f3eeeb; cursor: pointer; font-size: 20px; }
.dialog__actions { display: flex; margin-top: 5px; padding-top: 15px; border-top: 1px solid var(--line); justify-content: flex-end; gap: 8px; }
.dialog__actions--split .button { flex: 1; }

.inventory-list { display: flex; flex-direction: column; }
.inventory-row { display: grid; min-height: 94px; padding: 15px 18px; border-top: 1px solid var(--line); align-items: end; grid-template-columns: minmax(160px, 1.1fr) minmax(100px, .45fr) 115px minmax(140px, .75fr) minmax(145px, .75fr) minmax(150px, .8fr) auto; gap: 12px; }
.inventory-row:first-child { border-top: 0; }
.inventory-row > div:first-child, .inventory-current { display: flex; align-self: center; flex-direction: column; }
.inventory-row small, .inventory-row label span { color: var(--muted); font-size: 11px; font-weight: 550; }
.inventory-row input { min-height: 38px; margin-top: 5px; }
.inventory-current strong { font-size: 17px; }
.inventory-actions { display: flex; align-items: center; gap: 7px; }
.batch-expiration-form { display: flex; min-width: 255px; align-items: flex-end; gap: 8px; }
.batch-expiration-form input { min-height: 34px; margin: 0; }
.warning-text { color: #9a5c16; }
.row--expired .expiration-cell strong { color: var(--red); }
.row--expiring .expiration-cell strong { color: #9a5c16; }

.card-grid { display: grid; padding: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.record-card { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.record-card--inactive { opacity: .67; background: #faf7f5; }
.record-card__header, .record-card__actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.record-card h2 { margin: 15px 0 3px; font-size: 17px; }
.record-card p { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.record-card > small { color: var(--muted); font-size: 11px; }
.record-card__actions { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); justify-content: flex-start; }
.record-card__actions form { margin: 0; }
.record-card__cost { display: flex; margin-top: 14px !important; padding: 10px 12px; border-radius: 9px; background: var(--teal-soft); flex-direction: column; }
.record-card__cost strong { margin-top: 2px; color: var(--ink); font-size: 18px; }

.role-guide { display: grid; margin-bottom: 20px; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.role-guide article { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.role-guide strong { color: var(--teal-dark); }
.role-guide p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.user-cell { display: flex; align-items: center; gap: 10px; }

.flash-stack { position: fixed; z-index: 50; top: 88px; right: 22px; display: flex; width: min(420px, calc(100% - 32px)); flex-direction: column; gap: 9px; }
.flash { display: flex; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); align-items: center; gap: 10px; }
.flash > span { display: grid; width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; color: #fff; font-weight: 800; place-items: center; }
.flash p { margin: 0; flex: 1; font-size: 13px; }
.flash button { border: 0; color: var(--muted); background: none; cursor: pointer; font-size: 20px; }
.flash--success > span { background: var(--green); }
.flash--error > span { background: var(--red); }

.login-shell { background: #f1ece8; }
.login-page { display: grid; min-height: 100vh; padding: 34px; place-items: center; }
.login-page .flash-stack { top: 22px; }
.login-card { display: grid; overflow: hidden; width: min(1000px, 100%); min-height: 630px; border-radius: 24px; background: #fff; box-shadow: 0 28px 90px rgba(79, 59, 51, .16); grid-template-columns: 1.08fr .92fr; }
.login-card__visual { position: relative; display: flex; overflow: hidden; padding: 46px; color: #fff; background: linear-gradient(145deg, #998780 0%, #c8baa9 100%); flex-direction: column; justify-content: space-between; }
.login-card__visual::before, .login-card__visual::after { position: absolute; border: 1px solid rgba(200, 186, 169, .45); border-radius: 50%; content: ""; }
.login-card__visual::before { right: -170px; bottom: -160px; width: 430px; height: 430px; }
.login-card__visual::after { right: -85px; bottom: -75px; width: 260px; height: 260px; }
.login-card__visual > * { position: relative; z-index: 1; }
.login-card__visual .login-brand { color: #fff; }
.login-card__visual .login-brand small { color: #f1e8e3; }
.login-card__visual h1 { max-width: 440px; margin: 12px 0 20px; font-size: clamp(42px, 5vw, 62px); line-height: 1.02; letter-spacing: -.055em; }
.login-card__visual p { max-width: 430px; color: #f5ece8; font-size: 17px; }
.login-card__visual > small { color: #eadfd9; }
.login-card__form { display: flex; padding: 60px 58px; flex-direction: column; justify-content: center; }
.login-card__form h2 { font-size: 33px; }
.login-card__form form { display: flex; margin-top: 26px; flex-direction: column; gap: 18px; }
.login-card__form .button { margin-top: 5px; }
.login-help { margin: 25px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.sr-only { position: absolute !important; overflow: hidden; width: 1px; height: 1px; padding: 0; border: 0; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 1120px) {
    .topbar__inner { gap: 17px; }
    .main-nav a { padding: 0 8px; font-size: 13px; }
    .account__button > span:last-child { display: none; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .inventory-row { grid-template-columns: 1.2fr .6fr 120px 1fr; }
    .inventory-row .inventory-note { grid-column: span 2; }
    .inventory-actions { grid-column: span 2; justify-self: end; }
}

@media (max-width: 860px) {
    .topbar__inner { position: relative; width: calc(100% - 28px); min-height: 64px; }
    .nav-toggle { display: block; }
    .main-nav { position: absolute; top: 57px; right: 0; left: 0; display: none; height: auto; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); align-items: stretch; flex-direction: column; }
    .main-nav.open { display: flex; }
    .main-nav a { min-height: 42px; padding: 0 12px; border-radius: 8px; }
    .main-nav a.active { color: var(--teal-dark); background: var(--teal-soft); }
    .main-nav a.active::after { display: none; }
    .account { margin-left: 0; }
    .account__button { padding: 0; }
    .page { width: calc(100% - 28px); padding-top: 28px; }
    .stats { grid-template-columns: 1fr; }
    .stat { min-height: 84px; }
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inventory-row { align-items: end; grid-template-columns: 1fr 1fr 1fr; }
    .inventory-row .inventory-note { grid-column: span 2; }
    .inventory-actions { grid-column: 3; }
    .login-page { padding: 18px; }
    .login-card { grid-template-columns: 1fr; }
    .login-card__visual { min-height: 250px; padding: 32px; }
    .login-card__visual > div:nth-child(2) { margin-top: 50px; }
    .login-card__visual h1 { font-size: 42px; }
    .login-card__visual > small { display: none; }
    .login-card__form { padding: 42px 32px; }
}

@media (max-width: 680px) {
    h1 { font-size: 29px; }
    .page-heading { align-items: stretch; flex-direction: column; }
    .page-heading__actions { width: 100%; }
    .page-heading__actions .button { flex: 1; }
    .panel__toolbar { align-items: stretch; flex-direction: column; }
    .search { width: 100%; }
    .toolbar-links { justify-content: space-between; }
    .form-grid { grid-template-columns: 1fr; }
    .role-guide { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .inventory-row { align-items: stretch; grid-template-columns: 1fr 1fr; }
    .inventory-row > div:first-child { grid-column: span 2; }
    .inventory-row .inventory-note { grid-column: span 2; }
    .inventory-actions { grid-column: span 2; width: 100%; }
    .inventory-actions .button { flex: 1; }
    .table-wrap { overflow: visible; }
    table, thead, tbody, tr, th, td { display: block; }
    thead { display: none; }
    tbody tr { padding: 12px 14px; border-top: 1px solid var(--line); }
    tbody tr:first-child { border-top: 0; }
    td { display: flex; min-height: 39px; padding: 7px 0; border: 0; align-items: center; justify-content: space-between; gap: 16px; text-align: right !important; white-space: normal !important; }
    td::before { color: var(--muted); content: attr(data-label); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
    td.actions { flex-wrap: wrap; justify-content: flex-end; }
    td.actions::before { margin-right: auto; }
    .user-cell { text-align: left; }
    .dialog form { padding: 20px; }
    .dialog__actions { flex-wrap: wrap; }
    .dialog__actions .button { flex: 1; }
    .filter-form { align-items: stretch; flex-wrap: wrap; }
    .filter-form select { width: 100%; }
    .login-card__visual { min-height: 215px; }
    .login-card__visual > div:nth-child(2) { margin-top: 35px; }
    .login-card__visual h1 { margin-bottom: 0; font-size: 34px; }
    .login-card__visual p { display: none; }
    .login-card__form { padding: 36px 25px; }
}
