:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #17202a;
  --muted: #65717e;
  --line: #dfe4e8;
  --primary: #175cd3;
  --primary-dark: #0f47a8;
  --danger: #b42318;
  --danger-bg: #fff0ee;
  --success: #067647;
  --success-bg: #ecfdf3;
  --warning-bg: #fff8e1;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { min-height: 62px; background: #101828; color: white; display: flex; align-items: center; gap: 24px; padding: 10px 24px; position: sticky; top: 0; z-index: 10; }
.brand { color: white; font-size: 18px; font-weight: 750; white-space: nowrap; }
.topbar nav { display: flex; gap: 15px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #d0d5dd; }
.topbar nav a:hover { color: white; text-decoration: none; }
.account { display: flex; align-items: center; gap: 12px; color: #d0d5dd; white-space: nowrap; }
.account form, .actions form, .undo-bar form { margin: 0; display: inline; }
.link-button { border: 0; background: transparent; color: white; cursor: pointer; padding: 0; }
.container { max-width: 1500px; margin: 0 auto; padding: 24px; }
.container.narrow { max-width: 460px; padding-top: 10vh; }
h1, h2 { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 26px; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(16,24,40,.04); margin-bottom: 18px; }
.login-card { padding: 28px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.page-heading, .section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.page-heading p { margin: 0; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px; border-radius: 7px; border: 1px solid transparent; font-weight: 650; cursor: pointer; text-decoration: none; background: white; color: var(--text); }
.button:hover { text-decoration: none; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { border-color: #b8c2cc; background: #fff; }
.button.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.button.danger { background: var(--danger-bg); border-color: #f3b5ae; color: var(--danger); }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: #344054; }
input, select, textarea { width: 100%; border: 1px solid #c8d0d8; border-radius: 7px; padding: 9px 10px; font: inherit; color: var(--text); background: white; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b2ccff; border-color: var(--primary); }
small { font-weight: 400; color: var(--muted); }
.checkbox { flex-direction: row; align-items: center; gap: 7px; font-weight: 500; }
.checkbox input { width: auto; }
.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr)) auto; gap: 12px; align-items: end; }
.filters.compact { grid-template-columns: minmax(220px, 2fr) 1fr auto auto; }
.filter-actions { display: flex; gap: 6px; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi span { color: var(--muted); font-weight: 600; }
.kpi strong { font-size: 24px; }
.kpi.danger { background: var(--danger-bg); border-color: #f3b5ae; }
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.actions { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.negative-row { background: var(--danger-bg); }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.badge { display: inline-block; padding: 3px 7px; border-radius: 999px; font-weight: 750; font-size: 11px; }
.badge.in { color: var(--success); background: var(--success-bg); }
.badge.out { color: var(--danger); background: var(--danger-bg); }
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--line); background: white; }
.flash.success { color: var(--success); background: var(--success-bg); border-color: #a6f4c5; }
.flash.error { color: var(--danger); background: var(--danger-bg); border-color: #f3b5ae; }
.undo-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; background: var(--warning-bg); border: 1px solid #f2d68a; padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
legend { font-weight: 700; padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 8px; }
.inline-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.inline-form label { min-width: 220px; flex: 1; }
.inline-form .button { margin-bottom: 1px; }
.row-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(150px, 2fr) auto auto; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
code { background: #eef2f6; padding: 2px 5px; border-radius: 4px; }
@media (max-width: 1050px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .account { margin-left: auto; }
  .filters, .filters.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .container { padding: 14px; }
  .topbar { padding: 12px 14px; }
  .topbar nav { order: 3; width: 100%; }
  .page-heading { flex-direction: column; }
  .filters, .filters.compact, .form-grid, .grid-2 { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .row-form { grid-template-columns: 1fr; }
}
.global-search { display: flex; align-items: center; gap: 7px; min-width: 330px; }
.global-search input { min-width: 210px; padding: 7px 9px; }
.global-search .button { white-space: nowrap; }
.zero-row { background: #fafafa; color: #59636e; }
.existing-file { margin-top: 8px; font-weight: 500; }
@media (max-width: 1250px) {
  .global-search { order: 3; width: 100%; }
  .global-search input { flex: 1; }
}
.badge.warehouse { color: #6941c6; background: #f4f3ff; }

.request-rows { margin-top: 16px; }
.request-rows table input, .request-rows table select { min-width: 120px; }
.request-rows table td:first-child input[type="checkbox"] { min-width: 0; width: auto; }
.request-actions { margin-top: 16px; }
.badge.request-pending { color: #b54708; background: #fffaeb; }
.badge.request-approved { color: #027a48; background: #ecfdf3; }
.badge.request-partial { color: #6941c6; background: #f4f3ff; }
.badge.request-rejected, .badge.request-cancelled { color: #b42318; background: #fef3f2; }

.product-picker input[type="text"], .product-picker input[list], .product-picker-cell input[list] { min-width: 260px; }
.product-picker-cell { min-width: 310px; }
.product-picker-cell input[list] { width: 100%; }
.request-rows table .product-picker-cell input[list] { min-width: 280px; }
