:root {
  color-scheme: light;
  --ink: #1b2925;
  --muted: #61716a;
  --green: #153c35;
  --green-2: #21634f;
  --green-soft: #e9f1ed;
  --surface: #ffffff;
  --canvas: #f3f6f3;
  --line: #dce5df;
  --amber: #9a5c05;
  --amber-bg: #fff5df;
  --red: #a3312b;
  --red-bg: #fff0ee;
  --shadow: 0 12px 35px rgb(24 57 45 / 7%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar { min-height: 72px; padding: 12px max(20px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 18px; background: var(--green); color: white; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 11px; }
.brand-icon { width: 42px; height: 42px; border: 1px solid rgb(255 255 255 / 32%); border-radius: 13px; display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .01em; }
.brand small { margin-top: 2px; color: #c5d8cf; font-size: 12px; }
.account-area { display: flex; align-items: center; gap: 13px; }
.account-name { font-size: 13px; color: #e5eee9; }

.page-shell { width: min(1180px, calc(100% - 36px)); min-height: calc(100vh - 132px); margin: 30px auto 46px; }
.login-card { width: min(460px, 100%); margin: 9vh auto 0; padding: 34px; }
.card { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.eyebrow { margin-bottom: 9px; color: var(--green-2); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(25px, 4vw, 34px); line-height: 1.12; letter-spacing: -.035em; }
h2 { margin-bottom: 6px; font-size: 19px; letter-spacing: -.02em; }
h3 { margin-bottom: 13px; font-size: 15px; }
.muted, .lead { color: var(--muted); }
.login-card > p { margin: 0 0 25px; font-size: 14px; line-height: 1.55; }
.form-stack { display: grid; gap: 17px; }
label { display: grid; align-content: start; gap: 7px; color: #34443d; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid #cbd8d0; border-radius: 10px; outline: none; background: white; color: var(--ink); font-size: 14px; font-weight: 450; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #2a8060; box-shadow: 0 0 0 3px rgb(42 128 96 / 13%); }
input::placeholder, textarea::placeholder { color: #97a39d; }
.optional { color: #819088; font-size: 10px; font-weight: 500; }
.field-help, .unit-inline { color: var(--muted); font-size: 11px; font-weight: 500; }
.setup-note { padding: 11px 13px; margin: 15px 0 0 !important; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 12px !important; }
.button { min-height: 41px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 750; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: #205446; }
.button-secondary { border-color: #c7d8ce; background: #f7faf8; color: var(--green); }
.button-secondary:hover { background: var(--green-soft); }
.button-quiet { border-color: transparent; background: transparent; color: var(--green); }
.topbar .button-quiet { color: white; }
.button-quiet:hover { background: rgb(21 60 53 / 7%); }
.topbar .button-quiet:hover { background: rgb(255 255 255 / 10%); }
.button-wide { width: 100%; margin-top: 3px; }
.button-small { min-height: 32px; padding: 6px 10px; border-radius: 8px; font-size: 11px; }
.form-message { min-height: 0; margin-top: 8px; color: var(--red); font-size: 12px; line-height: 1.4; }
.form-message:empty { display: none; }
.form-message.is-success { color: #23744d; }
.form-message.is-info { color: var(--muted); }

.notice { display: flex; gap: 12px; padding: 15px 17px; margin-bottom: 22px; border: 1px solid; border-radius: 13px; font-size: 13px; line-height: 1.45; }
.notice p { margin: 3px 0 0; }
.notice-test { border-color: #edd9a6; background: var(--amber-bg); color: #66430c; }
.notice-error { border-color: #f1c6c1; background: var(--red-bg); color: #822923; }
.notice-success { border-color: #c4dfce; background: #edf8f0; color: #245b39; }
.notice-icon { width: 22px; height: 22px; flex: 0 0 22px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-weight: 800; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 13px; }
.section-heading h1 { margin: 0; }
.section-heading h2 { margin: 0; }
.section-heading .muted { margin: 5px 0 0; font-size: 12px; }
.compact-heading { align-items: center; margin: 25px 0 15px; }
.lead { margin-bottom: 19px; font-size: 14px; }
.role-pill, .status-pill, .type-pill { display: inline-flex; align-items: center; width: fit-content; padding: 6px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 800; white-space: nowrap; }
.role-admin { background: #eeeaf7; color: #51447b; }
.stock-strip, .stock-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stock-strip { margin-bottom: 17px; }
.stock-card { min-height: 132px; padding: 14px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 5px 20px rgb(24 57 45 / 4%); }
.stock-card.is-low { border-color: #ead39e; background: #fffdfa; }
.stock-card-top { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.stock-dot { width: 8px; height: 8px; border-radius: 50%; background: #559477; }
.dot-diesel_white { background: #c79642; }
.dot-diesel_red { background: #bb5b45; }
.dot-oil { background: #6383a3; }
.dot-filters { background: #785e99; }
.stock-amount { margin-top: auto; font-size: 25px; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stock-amount small { font-size: 12px; letter-spacing: 0; color: var(--muted); }
.stock-product { font-size: 12px; font-weight: 750; }
.stock-alert { color: var(--amber); font-size: 10px; font-weight: 750; }
.stock-alert.is-empty { color: var(--red); }
.stock-meter { height: 4px; overflow: hidden; border-radius: 4px; background: #e7ede9; }
.stock-meter span { display: block; height: 100%; border-radius: inherit; }
.meter-empty { width: 3%; background: var(--red); }
.meter-low { width: 42%; background: #dfaa42; }
.meter-ok { width: 83%; background: #4a9872; }
.form-card { padding: 21px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 18px; }
.auto-time { color: var(--muted); font-size: 11px; }
.admin-nav { position: sticky; top: 8px; z-index: 2; display: flex; width: fit-content; max-width: 100%; gap: 3px; padding: 4px; margin: 19px 0 10px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: rgb(255 255 255 / 94%); box-shadow: 0 5px 17px rgb(24 57 45 / 5%); }
.nav-button { min-height: 36px; padding: 7px 14px; border: 0; border-radius: 8px; background: transparent; color: #65746c; font-size: 12px; font-weight: 750; white-space: nowrap; }
.nav-button.is-active { background: var(--green); color: white; }
.settings-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 25px; padding: 19px; margin-top: 14px; }
.settings-card > div { min-width: 190px; }
.settings-card .muted { margin: 6px 0 0; font-size: 12px; line-height: 1.45; }
.inline-form { display: flex; flex: 1; align-items: flex-end; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.inline-form label { min-width: 130px; }
.inline-form .reason-field { flex: 1 1 180px; }
.unit-inline { padding: 0 0 12px; }
.filter-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; padding: 15px; margin: 15px 0 12px; }
.filter-row label { min-width: 145px; flex: 1; }
.filter-row label:first-child { flex: 2; }
.table-card { overflow: hidden; }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 1050px; border-collapse: collapse; font-size: 12px; text-align: left; }
th, td { padding: 12px 11px; border-bottom: 1px solid #edf1ee; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: #f8faf8; color: #66746d; font-size: 10px; font-weight: 800; letter-spacing: .04em; }
td small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfb; }
.quantity-cell { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.type-pill { padding: 5px 8px; font-size: 9px; }
.type-consumption { background: #fff1e7; color: #9a4e1b; }
.type-restock { background: #e8f5ec; color: #28603d; }
.type-adjustment { background: #edf0f6; color: #4a5f7b; }
.empty-state { padding: 25px; margin: 0; color: var(--muted); text-align: center; font-size: 13px; }
.users-list { display: grid; gap: 14px; padding: 18px; margin-top: 15px; }
.user-row { padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.user-row.is-inactive { background: #f7f8f7; opacity: .75; }
.user-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.user-heading strong, .user-heading small { display: block; }
.user-heading small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-pill { padding: 5px 8px; background: #e8f5ec; color: #28603d; }
.status-pill.is-off { background: #ecefed; color: #65716a; }
.user-edit-form { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto auto; align-items: end; gap: 10px; }
.user-edit-form label { font-size: 10px; }
.user-edit-form .checkbox-label { display: flex; align-items: center; min-height: 42px; white-space: nowrap; }
.checkbox-label input { width: 16px; min-height: 16px; accent-color: var(--green); }
.edit-dialog { width: min(720px, calc(100vw - 28px)); max-height: min(90vh, 850px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 25px 100px rgb(0 0 0 / 24%); }
.edit-dialog::backdrop { background: rgb(13 31 25 / 55%); backdrop-filter: blur(3px); }
.edit-dialog form { padding: 23px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dialog-heading h2 { margin: 0; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--muted); font-size: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 19px; }
.edit-direction-field { grid-column: 1 / -1; }
.page-footer { min-height: 60px; padding: 15px 20px; display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); background: #edf2ee; color: #66746d; font-size: 11px; }

@media (max-width: 850px) {
  .stock-strip, .stock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-card { flex-direction: column; gap: 15px; }
  .settings-card > div { min-width: 0; }
  .inline-form { justify-content: flex-start; }
  .user-edit-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-edit-form .checkbox-label { grid-column: 1; }
}

@media (max-width: 560px) {
  .topbar { min-height: 64px; padding: 10px 15px; }
  .brand-icon { width: 37px; height: 37px; }
  .brand strong { font-size: 14px; }
  .brand small { font-size: 10px; }
  .account-area { gap: 5px; }
  .account-name { max-width: 120px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
  .page-shell { width: calc(100% - 24px); margin: 19px auto 30px; }
  .login-card { padding: 24px 20px; margin-top: 7vh; }
  .section-heading { align-items: flex-start; }
  .section-heading h1 { font-size: 27px; }
  .role-pill { margin-top: 4px; font-size: 9px; }
  .stock-strip, .stock-grid { gap: 8px; }
  .stock-card { min-height: 119px; padding: 11px; }
  .stock-amount { font-size: 22px; }
  .form-card { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; gap: 13px; }
  .span-2 { grid-column: auto; }
  .form-footer { align-items: stretch; flex-direction: column; gap: 12px; }
  .form-footer .button { width: 100%; }
  .admin-nav { position: static; width: 100%; }
  .nav-button { flex: 1; padding-inline: 10px; }
  .compact-heading { margin-top: 20px; }
  .filter-row { align-items: stretch; flex-direction: column; }
  .filter-row label, .filter-row label:first-child { width: 100%; }
  .filter-row .button { width: 100%; }
  .inline-form { display: grid; width: 100%; grid-template-columns: 1fr; }
  .inline-form label { min-width: 0; }
  .unit-inline { display: none; }
  .user-edit-form { grid-template-columns: 1fr 1fr; }
  .user-edit-form label:first-child { grid-column: 1 / -1; }
  .user-edit-form label:nth-child(3) { grid-column: 1 / -1; }
  .user-edit-form button { grid-column: 1 / -1; }
  .edit-dialog form { padding: 18px; }
  .page-footer { flex-direction: column; gap: 5px; padding-inline: 14px; }
}
