:root {
  --brand-red: #d50c1f;
  --text-dark: #333333;
  --text-body: #555555;
  --bg-light: #f8f8f8;
  --bg-utility: #fafafa;
  --border: #ececec;
  --footer: #333333;
  --white: #ffffff;
  --container: 1408px;
  --radius: 10px;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 6px 14px rgba(0, 0, 0, 0.08);
  --signal: #d50c1f;
  --success: #2f7a3d;
  --danger: #b3261e;
  --warning: #8d5f00;
  --surface: #ffffff;
  --surface-muted: #f4f4f4;
  --surface-alt: #fbfbfb;
  --table-head: #141414;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Montserrat", "Arial", sans-serif;
  color: var(--text-body);
  background: var(--white);
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.container {
  width: min(var(--container), calc(100% - 2rem));
  margin: 0 auto;
}

.brand-header {
  background: var(--white);
}

.brand-header__inner {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  width: 172px;
  height: auto;
  display: block;
}

.brand-copy .brand-title {
  margin: 0;
  color: var(--text-dark);
  font-size: clamp(20px, 2.6vw, 31px);
  font-weight: 700;
  line-height: 1.15;
}

.brand-copy p:not(.brand-title) {
  margin: 0.35rem 0 0;
  color: #777;
  font-size: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-chip,
.panel-badge,
.hero-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 10px;
  font-weight: 700;
}

.header-chip {
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--brand-red);
}

.main-nav {
  background: var(--brand-red);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 25;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.main-nav__inner {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
}

.nav-item > a {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 0 1rem;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.nav-item > a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.2);
}

.nav-item > a:hover,
.nav-item > a:focus-visible {
  background: rgba(255, 255, 255, 0.13);
}

.page-shell {
  padding: 28px 0 48px;
}

.workspace-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.workspace-panel h2,
.line-items-header h3 {
  margin: 0;
  color: var(--text-dark);
}

.workspace-panel h2 {
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.1;
}

.workspace-panel {
  padding: 1.75rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.panel-badge {
  padding: 0 1rem;
  background: #fff5f6;
  border: 1px solid #f2c9ce;
  color: var(--brand-red);
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 1.05rem;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-1px);
}

.action-button {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #fff;
}

.action-button-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text-dark);
}

.order-board {
  display: grid;
  grid-template-columns: 1.55fr 0.78fr 0.98fr 0.78fr 0.98fr;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.board-label {
  padding: 0.95rem 0.8rem;
  background: var(--brand-red);
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.field-block {
  min-height: 144px;
  padding: 0.95rem;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.field-block:not(.field-block-type) {
  border-left: 1px solid var(--border);
}

.type-select,
.number-input,
.date-input,
.grid-input,
.grid-textarea {
  width: 100%;
  border: 1px solid #d7d7d7;
  border-radius: 10px;
  background: #fff;
  color: var(--text-dark);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.type-select,
.number-input,
.date-input {
  min-height: 54px;
  padding: 0 0.9rem;
  font-weight: 700;
}

.type-select {
  font-size: clamp(1.3rem, 2.3vw, 2rem);
}

.number-input {
  font-size: clamp(1.8rem, 2.4vw, 2.6rem);
  text-align: center;
}

.date-input {
  font-size: 1.15rem;
  text-align: center;
}

.type-select:focus,
.number-input:focus,
.date-input:focus,
.grid-input:focus,
.grid-textarea:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 4px rgba(213, 12, 31, 0.1);
}

.number-input.input-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(179, 38, 30, 0.12);
  color: var(--danger);
}

.field-warning {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.field-warning-empty {
  visibility: hidden;
}

.field-footer {
  margin-top: 0.45rem;
  display: grid;
  grid-template-rows: minmax(18px, auto) minmax(18px, auto);
  row-gap: 0;
}

.field-meta,
.status-list dt {
  min-height: 18px;
  margin: 0;
  color: #9a9aa1;
  font-size: 13px;
  line-height: 1.4;
}

.status-list dt {
  color: #777;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 11px;
}

.status-list dd {
  color: var(--text-dark);
  font-weight: 700;
}

.status-grid,
.line-items-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.15rem;
}

.sync-toolbar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.sync-status {
  margin: 0;
  color: #7d7d84;
  font-size: 13px;
  line-height: 1.4;
}

.sync-status.is-error {
  color: var(--danger);
}

.action-button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.status-card {
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.status-card h3 {
  margin: 0 0 0.9rem;
  color: var(--text-dark);
  font-size: 1rem;
}

.status-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.status-list div {
  padding: 0.8rem;
  border-radius: 10px;
  background: var(--bg-light);
}

.status-list dd {
  margin: 0.35rem 0 0;
  font-size: 1.05rem;
}

.validation-list {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.6;
}

.line-items-panel {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.line-items-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.line-items-copy {
  margin: 0.65rem 0 0;
  max-width: 720px;
  line-height: 1.58;
}

.line-items-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.8rem;
  background: #f3f4f7;
  box-shadow: var(--shadow-soft);
}

.line-items-table {
  width: max-content;
  min-width: 100%;
  min-width: 1820px;
  border-collapse: separate;
  border-spacing: 0 0.8rem;
  table-layout: fixed;
}

.line-items-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0 0.18rem;
  background: transparent;
  color: inherit;
  font-size: 12px;
  text-align: left;
  white-space: normal;
}

.line-items-table tbody td {
  padding: 0.85rem 0.75rem;
  border-top: 1px solid #e6e8ed;
  border-bottom: 1px solid #e6e8ed;
  border-right: 1px solid #eef0f3;
  vertical-align: middle;
  background: #fff;
  overflow: hidden;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.line-items-table tbody td:first-child {
  border-left: 1px solid #e6e8ed;
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
}

.line-items-table tbody td:last-child {
  border-top-right-radius: 16px;
  border-bottom-right-radius: 16px;
}

.line-items-table tbody tr:hover td {
  background: #fffdfd;
  border-top-color: #ead6d9;
  border-bottom-color: #ead6d9;
}

.line-items-table td.cell-model,
.line-items-table td.cell-reason {
  min-width: 260px;
}

.line-items-table td.cell-sku {
  min-width: 110px;
}

.line-items-table td.cell-status {
  min-width: 132px;
}

.line-items-table td.cell-price,
.line-items-table td.cell-money,
.line-items-table td.cell-stock {
  min-width: 126px;
}

.line-items-table td.cell-money,
.line-items-table td.cell-stock,
.line-items-table td.cell-status,
.line-items-table td.cell-qty,
.line-items-table td.cell-row-number {
  text-align: center;
}

.th-content {
  position: relative;
  display: flex;
  align-items: flex-start;
  min-height: 68px;
  padding: 1rem 1.05rem;
  padding-right: 1.2rem;
  border-radius: 16px;
  background: #141416;
  color: #fff;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.line-items-table thead th:nth-child(10) .th-content,
.line-items-table thead th:nth-child(16) .th-content {
  background: #7d1420;
}

.column-resizer {
  position: absolute;
  top: 0;
  right: -0.55rem;
  width: 16px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.column-resizer::after {
  content: "";
  position: absolute;
  top: 0.85rem;
  bottom: 0.85rem;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transition: background-color 140ms ease;
}

.column-resizer:hover::after,
.column-resizer:focus-visible::after,
body.is-resizing-columns .column-resizer::after {
  background: rgba(255, 255, 255, 0.44);
}

.grid-input {
  min-height: 46px;
  padding: 0 0.85rem;
  min-width: 0;
  border-radius: 14px;
  border-color: #e0e3e8;
  background: #f8f9fb;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.grid-input.grid-input-qty,
.grid-input.grid-input-price {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.grid-textarea {
  min-height: 92px;
  padding: 0.8rem 0.9rem;
  resize: vertical;
  min-width: 0;
  border-radius: 14px;
  border-color: #e0e3e8;
  background: #f8f9fb;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.cell-value {
  display: block;
  color: var(--text-dark);
  font-weight: 700;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.cell-row-number .cell-value {
  font-size: 1.45rem;
}

.cell-model .cell-value {
  font-size: 1.02rem;
  line-height: 1.42;
}

.cell-money .cell-value,
.cell-stock .cell-value {
  white-space: nowrap;
}

.cell-value-muted {
  color: #858585;
  font-weight: 600;
}

.cell-value-missing {
  color: #979797;
  font-style: italic;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  min-height: 36px;
  padding: 0 0.85rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
}

.status-pass {
  background: rgba(47, 122, 61, 0.1);
  border-color: rgba(47, 122, 61, 0.18);
  color: var(--success);
}

.status-fail {
  background: rgba(179, 38, 30, 0.1);
  border-color: rgba(179, 38, 30, 0.18);
  color: var(--danger);
}

.status-na {
  background: rgba(85, 85, 85, 0.06);
  border-color: rgba(85, 85, 85, 0.08);
  color: #777;
}

.difference-negative {
  color: var(--danger);
}

.difference-positive {
  color: var(--success);
}

.row-remove-button {
  margin-top: 0.65rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid #f0c8cd;
  border-radius: 999px;
  background: #fff6f7;
  color: var(--brand-red);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.row-remove-button:hover,
.row-remove-button:focus-visible {
  background: #feecee;
  border-color: #e9aab1;
  transform: translateY(-1px);
}

.status-list-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

code {
  padding: 0.08rem 0.32rem;
  border-radius: 6px;
  background: #f5f5f5;
  color: var(--text-dark);
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.92em;
}

@media (max-width: 1100px) {
  .panel-header,
  .line-items-header {
    flex-direction: column;
  }

  .status-grid,
  .line-items-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .brand-header__inner,
  .brand-lockup {
    flex-direction: column;
    align-items: flex-start;
  }

  .order-board {
    grid-template-columns: 1fr;
  }

  .field-block,
  .field-block:not(.field-block-type) {
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .container {
    width: min(var(--container), calc(100% - 1rem));
  }

  .workspace-panel {
    border-radius: 14px;
  }

  .page-shell {
    padding-top: 1rem;
  }

  .nav-item > a {
    padding: 0 0.7rem;
    font-size: 11px;
  }

  .brand-logo {
    width: 140px;
  }
}
