:root {
  color-scheme: light;
  --page: #f5f4ef;
  --surface: #fffefa;
  --ink: #232520;
  --muted: #5f6158;
  --line: #e2e0d7;
  --accent: #a73b19;
  --accent-dark: #872d12;
  --accent-soft: #f8e7dd;
  --side: #252822;
  --side-text: #bdbfb5;
  --good: #315c40;
  --good-bg: #e7efe5;
  --danger: #9b2c26;
  --danger-bg: #fff0ea;
  --radius: 14px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.buyer-portal, .login-page {
  --page: #f6f5f6;
  --surface: #fff;
  --ink: #222227;
  --muted: #5f5963;
  --line: #e4e0e3;
  --accent: #782d43;
  --accent-dark: #622336;
  --accent-soft: #f6e8ec;
  --side: #202126;
  --side-text: #c6bfc8;
  --radius: 12px;
}

.login-page { --muted: #65616b; }
.buyer-portal { --good: #325847; --good-bg: #eaf2ed; }

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); min-width: 280px; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.85rem); line-height: 1.13; letter-spacing: -.042em; font-weight: 750; }
h2 { font-size: 1.22rem; line-height: 1.25; letter-spacing: -.023em; font-weight: 710; }
small { font-size: .82rem; }
:focus-visible { outline: 3px solid #d16e43; outline-offset: 3px; }
.buyer-portal :focus-visible { outline-color: #a44f67; }
.login-page :focus-visible { outline-color: var(--accent); }

.skip-link { position: fixed; left: -100vw; top: 8px; z-index: 3; background: white; padding: 8px 14px; }
.skip-link:focus { left: 8px; }
.shell { display: grid; grid-template-columns: 234px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--side);
  color: #f8f7f1;
  padding: 28px 19px 22px;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 740; font-size: 1.04rem; line-height: 1.15; white-space: nowrap; }
.sidebar .brand { margin: 0 6px 42px; }
.brand small { display: block; margin-top: 5px; font-weight: 450; color: var(--side-text); font-size: .77rem; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: block;
  position: relative;
  flex: none;
  overflow: hidden;
}
.brand-mark img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: auto;
  transform: translate(-50%, -50%);
}
.nav { display: grid; gap: 6px; }
.nav a { display: flex; align-items: center; gap: 13px; min-height: 46px; padding: 0 12px; color: var(--side-text); border: 1px solid transparent; border-radius: 8px; font-size: .94rem; font-weight: 560; }
.nav a:hover { color: white; background: #333830; }
.nav a.selected { color: #fff9f1; background: #3c3930; border-color: #51463a; }
.nav a.selected .icon { color: #fc966a; }
.nav-count { margin-inline-start: auto; min-width: 23px; padding: 2px 6px; border-radius: 20px; background: #49463b; color: #fff7e9; font-size: .75rem; text-align: center; font-variant-numeric: tabular-nums; }
.account { margin-top: auto; padding: 18px 0 0; border-top: 1px solid #484a41; display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 33px; height: 33px; flex: 0 0 33px; display: grid; place-items: center; border-radius: 50%; background: #494c3f; color: #f5eedf; font-weight: 650; }
.account-text { min-width: 0; flex: 1; }
.account-text strong, .account-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text strong { font-size: .84rem; }
.account-text small { color: var(--side-text); font-size: .72rem; }
.logout { color: var(--side-text); background: transparent; border: 0; display: grid; place-items: center; border-radius: 7px; width: 34px; height: 38px; padding: 0; }
.logout:hover { background: #3d4137; color: white; }
.workspace { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 65px; padding: 12px clamp(24px, 4vw, 56px); border-bottom: 1px solid var(--line); color: var(--muted); font-size: .88rem; font-weight: 550; }
.environment { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: #5b5a4f; }
.environment i { width: 7px; height: 7px; border-radius: 50%; background: #9b662e; }
.main { max-width: 1470px; margin: 0 auto; padding: 38px clamp(24px, 4vw, 56px) 64px; }
.page-heading { margin-bottom: 28px; }
.page-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.page-heading p { color: var(--muted); margin-top: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .87rem; font-weight: 565; margin-bottom: 14px; }
.back-link:hover { color: var(--accent-dark); text-decoration: underline; }

.buyer-portal .sidebar { padding-top: 24px; color: #faf8fa; box-shadow: inset -1px 0 #2e2e34; }
.buyer-portal .sidebar .brand { margin: 0 4px 30px; gap: 10px; font-size: 1.06rem; }
.buyer-portal .nav a { gap: 11px; }
.buyer-portal .nav a:hover { background: #2d2b32; }
.buyer-portal .nav a.selected { color: #fff; background: #3c2732; border-color: #603645; }
.buyer-portal .nav a.selected .icon { color: #f0afc0; }
.buyer-portal :is(.nav-count, .avatar) { color: #f6f1f5; background: #37343d; }
.buyer-portal .account { border-color: #3c3b43; }
.buyer-portal .logout:hover { background: #38353d; }
.buyer-portal .topbar { background: var(--surface); }
.catalog-page .topbar { min-height: 61px; padding-inline: 42px; }
.catalog-page .main { padding: 31px 42px 58px; }
.catalog-page .page-heading { margin-bottom: 16px; }
.catalog-page .page-heading h1 { letter-spacing: -.05em; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; box-shadow: 0 2px 5px #302b1e07; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(248px, 1fr); gap: 18px; margin-bottom: 22px; align-items: start; }
.dashboard-aside { display: grid; gap: 16px; }
.upload-panel { padding: 22px; }
.compact-panel { padding: 17px 18px 13px; }
.panel-heading { display: flex; align-items: flex-start; gap: 11px; padding-bottom: 15px; }
.panel-heading > .icon { color: var(--accent); margin-top: 2px; }
.panel-heading p { margin-top: 5px; color: var(--muted); font-size: .88rem; }
.compact-panel .panel-heading { align-items: center; padding-bottom: 9px; }
.compact-panel .panel-heading > .icon { margin-top: 0; }
.compact-panel h2 { font-size: 1.07rem; }
.file-link { display: flex; align-items: center; justify-content: space-between; gap: 9px; min-height: 61px; border-top: 1px solid #ece9e1; padding: 8px 2px; }
.file-link:hover { color: var(--accent); }
.file-link strong, .file-link small { display: block; }
.file-link strong { font-size: .90rem; font-weight: 650; }
.file-link small { color: var(--muted); margin-top: 1px; }
.file-link .icon { color: var(--accent); }

.form-stack { display: grid; gap: 15px; }
.field { min-width: 0; display: block; font-weight: 620; font-size: .86rem; }
.field input, .field textarea {
  appearance: none;
  display: block;
  width: 100%;
  min-height: 43px;
  margin-top: 6px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid #d6d4cb;
  border-radius: 8px;
  line-height: 1.35;
  font-weight: 450;
  font-size: .94rem;
}
.field input::placeholder { color: #6e7167; opacity: 1; }
.field textarea { resize: vertical; }
.field .optional { font-size: .77rem; font-weight: 450; color: var(--muted); margin-left: 3px; }
.upload-zone {
  border: 1.5px dashed #c9b3a3;
  border-radius: 11px;
  min-height: 138px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  background: #faf6ef;
  text-align: center;
}
.upload-zone:hover, .upload-zone.dragging { background: #f9eee4; border-color: var(--accent); }
.upload-zone:focus-within { outline: 3px solid #d16e43; outline-offset: 3px; }
.upload-zone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-zone small { color: var(--muted); }
.file-icon { display: grid; place-items: center; width: 37px; height: 37px; border: 1px solid #edcbb9; border-radius: 9px; background: #f8e7dd; color: var(--accent); margin-bottom: 2px; }
.upload-prompt { font-weight: 650; overflow-wrap: anywhere; }
.upload-fields { display: grid; grid-template-columns: 1fr 1.2fr; gap: 13px; }
.form-actions, .action-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 11px; }
.form-actions > small { color: var(--muted); }
.action-bar { justify-content: flex-end; margin-top: 18px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  white-space: nowrap;
  font-size: .88rem;
  font-weight: 660;
  line-height: 1.3;
}
.button-primary { background: var(--accent); color: white; border-color: var(--accent); }
.button-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: #d8d6cd; }
.button-secondary:hover { background: #eeece4; }
.button-danger { color: white; background: var(--danger); border-color: var(--danger); }
.button-danger:hover { background: #7d211c; }
.button-text { color: var(--accent-dark); }
.button-text:hover { text-decoration: underline; }

.details { margin: 0; display: grid; gap: 0; font-size: .87rem; }
.details > div { padding: 6px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 5px 15px; border-top: 1px solid #ece9e1; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 615; overflow-wrap: anywhere; }
.details time { white-space: nowrap; }
.table-panel + .table-panel, .summary-panel + .table-panel, .table-panel + .summary-panel { margin-top: 18px; }
.section-heading { min-height: 62px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 13px 18px; }
.section-heading > span:not(.tag) { color: var(--muted); font-size: .82rem; }
.summary-panel { overflow: hidden; }
.summary-panel .details { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); padding: 0 18px 16px; gap: 8px 18px; }
.summary-panel .details > div { display: block; min-width: 0; padding-top: 8px; }
.summary-panel .details dt { margin-bottom: 4px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--line); background: #f8f7f2; }
.metric { display: flex; flex-direction: column; gap: 3px; padding: 11px 16px 13px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); font-size: .8rem; }
.metric strong { font-size: 1.48rem; font-variant-numeric: tabular-nums; line-height: 1.22; }
.metric-warm { background: #f9ecdc; }
.metric-error { background: var(--danger-bg); }
.metric-error strong { color: var(--danger); }
.table-scroll { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: .91rem; font-variant-numeric: tabular-nums; }
thead { background: #f1f0e9; color: #53554b; }
th, td { padding: 11px 15px; border-top: 1px solid #eeece5; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
th { font-weight: 620; font-size: .78rem; white-space: nowrap; }
tbody tr:hover { background: #fbfaf5; }
tbody tr.zero-row { background: #fff8f1; }
td time { white-space: nowrap; }
.cell-stacked { display: grid; gap: 2px; }
.cell-stacked small { color: var(--muted); }
.cell-stacked strong { font-weight: 670; }
.sku { font-family: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace; font-size: .83rem; color: #4f5047; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 4px 8px; border-radius: 7px; font-size: .78rem; line-height: 1.35; font-weight: 640; white-space: nowrap; }
.tag i { height: 6px; width: 6px; background: currentColor; opacity: .75; border-radius: 50%; }
.tag-muted { color: #55584e; background: #ededE6; }
.tag-good { color: var(--good); background: var(--good-bg); }
.tag-zero { color: #824c2c; background: #f7eadc; }
.tag-bad { color: var(--danger); background: var(--danger-bg); }
.table-link { text-decoration: underline; text-underline-offset: 2px; color: var(--accent-dark); font-weight: 630; overflow-wrap: anywhere; }
.table-link:hover { color: var(--accent); }
.empty { padding: 0 18px 18px; color: var(--muted); }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 12px 6px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.pagination > div { display: flex; gap: 2px; }
.notice { display: flex; gap: 11px; align-items: baseline; padding: 11px 14px; margin-bottom: 13px; border: 1px solid var(--line); border-radius: 9px; background: #efece4; font-size: .91rem; overflow-wrap: anywhere; }
.notice > .icon { align-self: center; }
.notice-bad { background: var(--danger-bg); color: var(--danger); border-color: #f0cfc7; }
.notice-good { background: var(--good-bg); color: var(--good); border-color: #d5e1d4; }
.notice-warm { background: #fff0da; color: #75451b; border-color: #edcead; }
.rollback-panel { padding: 18px; }
.rollback-panel .form-actions { justify-content: flex-end; }
.message-panel { padding: 20px; }
.message-panel p + a { margin-top: 14px; }
.message-page { max-width: 650px; margin: 10vh auto; padding: 18px; }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: 46% minmax(0, 1fr); }
.login-brand {
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  padding: 47px clamp(34px, 4vw, 64px);
  background: var(--side);
  color: #f9f7f8;
}
.login-brand .brand { position: relative; z-index: 1; align-self: flex-start; gap: 14px; font-size: 1.14rem; letter-spacing: -.02em; }
.login-brand .brand small { color: #c4bbc3; font-size: .78rem; letter-spacing: .01em; }
.login-brand .brand-mark { width: 46px; height: 35px; }
.login-brand .brand-mark img { width: 121%; }
.login-crest {
  position: absolute;
  top: 53%;
  left: max(-535px, -40vw);
  width: min(1110px, 83vw);
  height: auto;
  transform: translateY(-50%);
  pointer-events: none;
}
.login-panel { min-height: 100vh; display: grid; place-items: center; padding: 48px 44px; }
.login-content { width: min(100%, 392px); }
.login-title { margin-bottom: 32px; }
.login-title h1 { font-size: clamp(2.22rem, 3.4vw, 3.2rem); }
.login-title p, .login-help { color: var(--muted); }
.login-title p { margin-top: 11px; }
.login-help { margin-top: 24px; font-size: .87rem; }
.login-content .form-stack { gap: 17px; }
.login-content input { min-height: 51px; border-color: #d8d3d8; }
.login-content .button { min-height: 50px; margin-top: 7px; font-size: 1rem; }

.icon { position: relative; width: 17px; height: 17px; display: inline-block; flex: 0 0 17px; }
.icon::before, .icon::after { position: absolute; display: block; content: ""; }
.icon-grid::before { inset: 1px; border: 1.6px solid currentColor; border-radius: 3px; background: linear-gradient(currentColor,currentColor) center / 1.5px 100% no-repeat, linear-gradient(currentColor,currentColor) center / 100% 1.5px no-repeat; }
.icon-history::before { inset: 1px; border: 1.6px solid currentColor; border-radius: 50%; }
.icon-history::after { width: 5px; height: 6px; left: 8px; top: 4px; border: solid currentColor; border-width: 0 0 1.6px 1.6px; }
.icon-sheet::before { inset: 0 2px; border: 1.6px solid currentColor; border-radius: 3px; }
.icon-sheet::after { top: 6px; left: 5px; width: 7px; height: 5px; border: solid currentColor; border-width: 1.5px 0; }
.icon-cart::before { inset: 6px 1px 1px; border: 1.6px solid currentColor; border-radius: 3px; }
.icon-cart::after { width: 7px; height: 8px; left: 5.5px; top: 1px; border: solid currentColor; border-width: 1.6px 1.6px 0; border-radius: 5px 5px 0 0; }
.icon-download::before, .icon-upload::before { inset: 8px 1px 1px; border: solid currentColor; border-width: 0 1.6px 1.6px; border-radius: 0 0 3px 3px; }
.icon-download::after, .icon-upload::after { top: 4px; left: 5px; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.icon-upload::after { transform: rotate(225deg); top: 3px; }
.icon-back::before, .icon-forward::before { width: 12px; height: 1.5px; background: currentColor; top: 8px; left: 3px; }
.icon-back::after, .icon-forward::after { top: 5px; width: 7px; height: 7px; border: solid currentColor; border-width: 0 0 1.6px 1.6px; transform: rotate(45deg); left: 3px; }
.icon-forward::after { transform: rotate(225deg); left: 8px; }
.icon-info::before { inset: 1px; border: 1.6px solid currentColor; border-radius: 50%; }
.icon-info::after { width: 1.7px; height: 5px; left: 8px; top: 7px; background: currentColor; border-radius: 2px; box-shadow: 0 -3px 0 -0.2px currentColor; }
.icon-logout::before { inset: 1px 7px 1px 1px; border: solid currentColor; border-width: 1.5px 0 1.5px 1.5px; border-radius: 3px 0 0 3px; background: linear-gradient(currentColor,currentColor) 5px 6px / 8px 1.5px no-repeat; }
.icon-logout::after { top: 5px; right: 2px; width: 7px; height: 7px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); }

@media (max-width: 1120px) {
  .shell { grid-template-columns: 198px minmax(0, 1fr); }
  .sidebar { padding-inline: 13px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.55fr) minmax(220px, 1fr); }
}
@media (max-width: 960px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { height: auto; position: static; padding: 14px 18px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 12px; }
  .sidebar .brand { margin: 0; }
  .nav { grid-row: 2; grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
  .nav a { min-height: 40px; }
  .account { margin: 0; padding: 0; border: 0; }
  .account .avatar { display: none; }
  .account-text { max-width: 140px; }
  .topbar { min-height: 41px; padding: 8px 18px; }
  .main { padding: 27px 18px 39px; }
  .page-heading { margin-bottom: 20px; }
  .page-heading-row { align-items: flex-start; flex-wrap: wrap; }
  .buyer-portal .sidebar { padding: 11px 13px 8px; gap: 8px 10px; }
  .buyer-portal .sidebar .brand { margin: 0; gap: 7px; }
  .buyer-portal .sidebar .brand-mark { width: 34px; height: 34px; }
  .buyer-portal .sidebar .brand small { margin-top: 3px; }
  .buyer-portal .nav a { min-height: 36px; gap: 7px; padding-inline: 9px; font-size: .86rem; }
  .catalog-page .topbar { display: none; }
  .catalog-page .main { padding: 18px 13px 40px; }
  .catalog-page .page-heading { margin-bottom: 6px; }
}
@media (max-width: 740px) {
  .login-layout { grid-template-columns: 1fr; align-content: start; }
  .login-brand {
    min-height: 96px;
    padding: 28px 24px;
    background: radial-gradient(ellipse at 12% 75%, #322730 0%, #24232a 52%, #1e1f24 100%);
  }
  .login-brand .brand { gap: 11px; font-size: 1rem; }
  .login-brand .brand small { margin-top: 4px; font-size: .73rem; }
  .login-brand .brand-mark { width: 39px; height: 29px; }
  .login-crest { display: none; }
  .login-panel { min-height: 0; padding: 46px 24px 40px; }
  .login-title { margin-bottom: 27px; }
  .login-title p { margin-top: 7px; font-size: .94rem; }
  .login-help { max-width: 290px; }
}
@media (max-width: 480px) {
  .account-text { max-width: 80px; }
  .account-text small { display: none; }
  .sidebar, .topbar, .main { padding-left: 13px; padding-right: 13px; }
  .upload-panel, .compact-panel, .rollback-panel { padding: 14px; }
  .upload-fields, .dashboard-aside { grid-template-columns: 1fr; }
  .dashboard-grid, .dashboard-aside { gap: 11px; }
  .section-heading { min-height: 52px; padding: 10px 14px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 9px 10px; border-bottom: 1px solid var(--line); }
  .form-actions .button, .action-bar .button { white-space: normal; }
}
@media (max-width: 350px) {
  .account-text { display: none; }
}
