:root {
  --brand-red: #d50c1f;
  --text-dark: #333333;
  --text-body: #555555;
  --bg-light: #f8f8f8;
  --border: #ececec;
  --white: #ffffff;
  --container: 1360px;
  --radius: 10px;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 6px 14px rgba(0, 0, 0, 0.08);
  --success: #2f7a3d;
  --danger: #b3261e;
  --surface: #ffffff;
  --surface-alt: #fbfbfb;
}

* {
  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;
  -webkit-text-size-adjust: 100%;
}

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

input,
select,
textarea {
  font-size: 16px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

h1, h2, h3, p {
  margin-top: 0;
}

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

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

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

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

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

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

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

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

.header-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--brand-red);
  font-weight: 700;
  font-size: 13px;
}

.status-chip {
  color: var(--text-dark);
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #c6c1b8;
  flex-shrink: 0;
}

.status-dot.ready {
  background: var(--success);
}

.status-dot.error {
  background: var(--danger);
}

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

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

.workspace-section + .workspace-section {
  margin-top: 1.75rem;
}

.workspace-panel h3 {
  margin: 0;
  color: var(--text-dark);
  font-size: 18px;
}

/* Buttons */
.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;
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #fff;
  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:disabled {
  cursor: not-allowed;
  opacity: 0.68;
  transform: none;
}

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

.action-button-secondary:hover {
  border-color: var(--brand-red);
  color: var(--brand-red);
}

/* Order board */
.order-board {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr 0.95fr 0.85fr 0.95fr;
  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: 128px;
  min-width: 0;
  padding: 0.95rem;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

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

.type-select,
.number-input,
.date-input,
.grid-textarea,
.email-input {
  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;
  max-width: 100%;
  overflow: hidden;
}

.type-select {
  font-size: clamp(1.1rem, 1.8vw, 1.5rem);
}

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

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

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

.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 {
  min-height: 18px;
  margin: 0;
  color: #9a9aa1;
  font-size: 13px;
  line-height: 1.4;
}

.sync-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.data-note {
  margin: 0;
  color: #7d7d84;
  font-size: 12px;
  max-width: 560px;
}

.update-info-table {
  border-collapse: collapse;
  font-size: 12px;
  color: #7d7d84;
  line-height: 1.4;
}

.update-info-table td {
  padding: 1px 6px 1px 0;
  vertical-align: middle;
}

.update-info-label {
  white-space: nowrap;
  color: #aaa;
}

.update-info-time {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
}

/* Items table */
.line-items-panel {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

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

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

.row-summary {
  color: #7d7d84;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

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

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

.items-table .col-index { width: 54px; }
.items-table .col-sku { width: 14%; }
.items-table .col-model { width: 32%; }
.items-table .col-qty { width: 10%; }
.items-table .col-stock { width: 18%; }
.items-table .col-status { width: 18%; }
.items-table .col-remove { width: 52px; }

.items-table thead th {
  padding: 0 0.18rem;
  background: transparent;
  text-align: left;
  font-size: 12px;
}

.th-content {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: #141416;
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 11px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.items-table tbody td {
  padding: 0.8rem 0.75rem;
  border-top: 1px solid #e6e8ed;
  border-bottom: 1px solid #e6e8ed;
  border-right: 1px solid #eef0f3;
  vertical-align: middle;
  background: #fff;
  font-size: 13px;
}

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

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

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

.row-number {
  color: #9a9aa1;
  font-weight: 700;
  font-size: 14px;
}

.row-input {
  width: 100%;
  min-height: 46px;
  padding: 0 0.85rem;
  border: 1px solid #e0e3e8;
  border-radius: 12px;
  background: #f8f9fb;
  color: var(--text-dark);
  outline: none;
}

.row-qty {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

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

.stock-value.empty {
  color: #9a9aa1;
  font-weight: 500;
  font-style: italic;
}

.model-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.sku-thumb {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: #f5f5f5;
  border: 1px solid #ebebeb;
}

.model-value {
  display: block;
  min-width: 0;
  color: var(--text-dark);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.model-value-missing {
  color: #9a9aa1;
  font-weight: 500;
  font-style: italic;
}

.row-status {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #8a8a92;
  font-size: 11px;
  font-weight: 700;
}

.row-status.ok {
  border-color: #add1bd;
  color: var(--success);
  background: #f0faf4;
}

.row-status.warn {
  border-color: #f0c8cd;
  color: var(--danger);
  background: #fff6f7;
}

.remove-row {
  width: 30px;
  height: 30px;
  border: 1px solid #f0c8cd;
  border-radius: 999px;
  background: #fff6f7;
  color: var(--brand-red);
  line-height: 1;
  font-size: 16px;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

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

/* Output panel */
.output-panel {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.output-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}


.output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.output-card {
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: var(--shadow-soft);
}

.output-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.output-card__actions .action-button {
  flex: 1 1 auto;
}

.output-card__label {
  color: var(--brand-red);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.output-card__filename {
  color: var(--text-dark);
  font-size: 1.05rem;
  line-height: 1.45;
  word-break: break-word;
  min-height: 38px;
}

.validation-list {
  margin: 0.9rem 0 0;
  padding-left: 1.1rem;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.6;
}

.sync-status {
  color: #7d7d84;
  font-size: 12px;
}

/* Email panel */
.email-send-panel {
  margin-top: 1.5rem;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fcfcfc;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  box-shadow: var(--shadow-soft);
}

.email-send-col {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.email-send-field {
  min-width: 0;
}

.email-send-label {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--text-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.email-file-picker {
  display: grid;
  gap: 0.75rem;
}

.email-file-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.email-file-option input {
  width: 18px;
  height: 18px;
  margin: 0.1rem 0 0;
  accent-color: var(--brand-red);
}

.email-file-option__copy {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.email-file-option__copy strong {
  color: var(--text-dark);
  font-size: 14px;
  font-weight: 700;
}

.email-recipient-picker {
  margin-bottom: 0.6rem;
}

.email-input {
  min-height: 52px;
  padding: 0 0.9rem;
}

.grid-textarea {
  min-height: 88px;
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  resize: vertical;
  width: 100%;
  display: block;
}

.email-send-action {
  display: flex;
  align-items: flex-end;
}

.email-send-btn {
  white-space: nowrap;
}

.email-status {
  min-height: 17px;
  margin: 0.75rem 0 0;
  color: #7d7d84;
  font-size: 12px;
}

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

.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;
}

/* Responsive */
@media (max-width: 1100px) {
  .output-grid {
    grid-template-columns: 1fr;
  }
}

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

  .order-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    padding: 1px;
    background: var(--border);
    border-radius: 16px;
    overflow: hidden;
  }

  .board-label {
    display: none;
  }

  .field-block,
  .field-block:not(.field-block-type) {
    min-height: auto;
    border: 0;
    background: #fff;
  }

  .field-block::before {
    content: attr(data-mobile-label);
    color: #7e7e86;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
  }

  .field-block-type {
    grid-column: 1 / -1;
  }
}

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

  .brand-header__inner {
    min-height: auto;
    padding: 1rem 0;
  }

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

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

  .brand-logo {
    width: 140px;
  }

  .brand-copy h1 {
    font-size: 24px;
  }

  .workspace-section + .workspace-section {
    margin-top: 1.1rem;
  }

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

  .action-button {
    width: 100%;
    min-height: 46px;
    font-size: 12px;
  }

  .line-items-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .table-shell {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .items-table,
  .items-table tbody,
  .items-table tr,
  .items-table td {
    display: block;
  }

  .items-table {
    width: 100%;
    min-width: 0;
    border-spacing: 0;
  }

  .items-table colgroup,
  .items-table thead {
    display: none;
  }

  .items-table tbody {
    display: grid;
    gap: 0.9rem;
  }

  .items-table tbody tr {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
  }

  .items-table tbody td,
  .items-table tbody td:first-child,
  .items-table tbody td:last-child {
    padding: 0.75rem 0.9rem;
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid #f0f1f4;
  }

  .items-table tbody td:last-child {
    border-bottom: 0;
  }

  .items-table tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.35rem;
    color: #7e7e86;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
  }

  .output-grid {
    grid-template-columns: 1fr;
  }

  .email-send-panel {
    grid-template-columns: 1fr;
  }

  .email-send-btn {
    width: 100%;
    min-height: 52px;
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .workspace-panel {
    padding: 0.85rem;
  }

  .brand-copy h1 {
    font-size: 20px;
  }
}
