/* ==========================================================================
   ARDesign Editorial Spatial Management — Trade Application Portal (/trade/style.css)
   Palette: Warm Cream (#FEFCF7) × Warm Sand (#F7F3EA) × Charcoal Ink (#4C4C4C)
            × Signature Orange (#EA5504) × Hairline (#E5E0D8)
   ========================================================================== */
:root {
  --bg-canvas: #FEFCF7;
  --bg-surface: #FFFFFF;
  --bg-Warm: #F7F3EA;
  --bg-soft: #F6F2E9;
  --text-ink: #4C4C4C;
  --text-strong: #262625;
  --text-muted: #888888;
  --accent-orange: #EA5504;
  --accent-orange-hover: #D14800;
  --accent-orange-soft: #FDF3EB;
  --stage-closed: #217A50;
  --line-hair: #E5E0D8;
  --line-strong: #D5CFC4;
  font-family: "Plus Jakarta Sans", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--text-ink);
  background: var(--bg-canvas);
  font-size: 14px;
  letter-spacing: 0.015em;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--text-ink);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-orange);
  color: #FFFFFF;
}

@media (pointer: fine) and (hover: hover) {
  body {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Ccircle cx='14' cy='14' r='11' fill='none' stroke='%23EA5504' stroke-width='1.4' stroke-opacity='0.85'/%3E%3Ccircle cx='14' cy='14' r='3' fill='%23EA5504'/%3E%3C/svg%3E") 14 14, auto;
  }
  a, button, label.drop-zone, input[type="checkbox"], select {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36' viewBox='0 0 36 36'%3E%3Ccircle cx='18' cy='18' r='15' fill='%23EA5504' fill-opacity='0.15' stroke='%23EA5504' stroke-width='1.6'/%3E%3Ccircle cx='18' cy='18' r='4' fill='%23EA5504'/%3E%3C/svg%3E") 18 18, pointer;
  }
}

button, input, select {
  font: inherit;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-orange); }

/* Editorial Top Header */
header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 64px;
  background: rgba(254, 252, 247, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 40px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  font-weight: 800;
  background: var(--bg-Warm);
  color: var(--text-strong);
  border: 1px solid var(--line-hair);
  border-top: 2.5px solid var(--accent-orange);
  padding: 8px 11px;
  font-size: 17px;
  letter-spacing: -0.03em;
}

.brand-copy {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-strong);
}

.brand-copy strong span {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.brand b {
  padding-left: 12px;
  border-left: 1px solid var(--line-hair);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-ink);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.online {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.online i,
.status-dot {
  display: inline-block;
  background: var(--accent-orange);
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line-hair);
  background: var(--bg-Warm);
  color: var(--accent-orange);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.22s ease;
}

.back-link:hover {
  border-color: var(--accent-orange);
  background: var(--accent-orange);
  color: #FFFFFF;
}

/* Main Container & Heading */
main {
  max-width: 1440px;
  margin: auto;
  padding: 24px 40px 48px;
}

.heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-hair);
}

.eyebrow {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  color: var(--accent-orange);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 0 0 6px;
}

h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

h1 span {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* Buttons */
button {
  border: 1px solid var(--accent-orange);
  background: var(--accent-orange);
  color: #FFFFFF;
  padding: 10px 20px;
  border-radius: 5px;
  font-weight: 700;
  white-space: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.22s ease, border-color 0.22s ease, transform 0.22s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-orange-hover);
  border-color: var(--accent-orange-hover);
  transform: translateY(-1px);
}

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

button.quiet {
  background: var(--bg-surface);
  color: var(--text-ink);
  border-color: var(--line-hair);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12.5px;
}

button.quiet:hover:not(:disabled) {
  background: var(--accent-orange-soft);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Step Progress Strip */
.steps {
  padding: 0;
  list-style: none;
  display: flex;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--line-hair);
  gap: 36px;
}

.steps li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 0 13px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2.5px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.steps li.active {
  color: var(--accent-orange);
  font-weight: 800;
  border-bottom-color: var(--accent-orange);
}

.steps li span {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  border: 1px solid currentColor;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.steps li.active span {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: #FFFFFF;
}

/* Split Editorial Workspace */
.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  background: var(--bg-surface);
  border: 1px solid var(--line-hair);
  border-top: 3px solid var(--accent-orange);
}

.input-section {
  padding: 22px 24px;
  background: var(--bg-Warm);
  border-right: 1px solid var(--line-hair);
}

.review-section {
  padding: 24px 28px;
  background: var(--bg-surface);
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-hair);
}

h2 {
  font-size: 14.5px;
  margin: 0;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: 0.02em;
}

.muted {
  font-size: 12px;
  color: var(--text-muted);
}

.tag {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-orange);
  background: var(--bg-surface);
  border: 1px solid rgba(234, 85, 4, 0.3);
  border-radius: 999px;
  padding: 2px 9px;
}

/* Drop Zone */
.drop-zone {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  min-height: 136px;
  border: 1.5px dashed var(--line-strong);
  background: var(--bg-surface);
  cursor: pointer;
  text-align: center;
  padding: 16px;
  gap: 6px;
  margin-bottom: 18px;
  overflow-wrap: anywhere;
  transition: border-color 0.22s ease, background-color 0.22s ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--accent-orange);
  background: var(--accent-orange-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone strong {
  font-weight: 800;
  color: var(--text-strong);
}

.drop-zone span:last-child {
  font-size: 11.5px;
  color: var(--text-muted);
}

.drop-zone .file-symbol {
  width: 27px;
  height: 27px;
  margin-bottom: 4px;
  color: var(--accent-orange);
}

/* Form Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-ink);
  margin-bottom: 13px;
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  background: var(--bg-surface);
  border: 1px solid var(--line-hair);
  border-radius: 4px;
  padding: 7px 10px;
  color: var(--text-strong);
  font-weight: 500;
  transition: border-color 0.2s ease;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(234, 85, 4, 0.2);
  border-color: var(--accent-orange);
}

input:disabled,
select:disabled {
  background: var(--bg-soft);
  color: var(--text-muted);
}

.form-heading {
  margin-top: 24px;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

fieldset {
  padding: 0;
  border: 0;
  margin: 0;
  min-width: 0;
}

.template-info {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line-hair);
  margin-top: 8px;
  font-size: 12px;
}

.template-info .status-dot {
  margin-top: 5px;
}

.template-info strong {
  font-weight: 700;
  color: var(--text-strong);
}

.template-info small {
  display: block;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Items Table & Totals Strip */
.table-wrap {
  overflow-x: auto;
  min-height: 260px;
  max-height: 480px;
  border: 1px solid var(--line-hair);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: 12.5px;
}

th {
  background: var(--bg-Warm);
  padding: 11px 10px;
  text-align: right;
  font-weight: 700;
  color: var(--text-ink);
  border-bottom: 1px solid var(--line-hair);
  white-space: nowrap;
}

th:first-child,
th:nth-child(2),
th:last-child {
  text-align: left;
}

td {
  padding: 13px 10px;
  text-align: right;
  border-bottom: 1px solid var(--line-hair);
  vertical-align: top;
  overflow-wrap: anywhere;
}

td:first-child,
td:nth-child(2),
td:last-child {
  text-align: left;
}

td:nth-child(2) {
  min-width: 160px;
  max-width: 280px;
  font-weight: 600;
  color: var(--text-strong);
}

td small {
  display: block;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 4px;
  line-height: 1.45;
}

.empty td {
  text-align: center;
  height: 220px;
  vertical-align: middle;
  color: var(--text-muted);
}

.empty-sheet {
  width: 48px;
  height: 55px;
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--accent-orange);
  margin: 0 auto 12px;
  padding: 10px;
  background: var(--bg-Warm);
}

.empty-sheet i {
  display: block;
  height: 1px;
  background: var(--line-strong);
  margin: 6px 0;
}

.totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 20px 0;
  border: 1px solid var(--line-hair);
  background: var(--bg-canvas);
}

.totals div {
  border-right: 1px solid var(--line-hair);
  border-top: 3px solid var(--line-strong);
  padding: 13px 15px;
  min-width: 0;
}

.totals div:last-child {
  border-right: 0;
}

.totals span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.totals strong {
  display: block;
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

.totals .grand {
  background: var(--accent-orange-soft);
  border-top-color: var(--accent-orange);
  color: var(--accent-orange);
}

.totals .grand strong {
  color: var(--accent-orange);
}

.calcs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  background: var(--bg-Warm);
  border: 1px solid var(--line-hair);
  padding: 12px 16px;
  font-size: 11.5px;
  margin: 0;
}

.calcs div {
  display: flex;
  gap: 10px;
}

.calcs dt {
  color: var(--text-muted);
  font-weight: 600;
}

.calcs dd {
  margin: 0;
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.output-heading {
  margin-top: 26px;
}

.checks {
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  font-size: 12px;
}

.checks li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line-hair);
  padding: 0 0 10px;
}

.checks span {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.checks.passed span {
  color: var(--stage-closed);
  font-weight: 700;
}

.sheet-order {
  font-family: ui-monospace, "IBM Plex Mono", "Noto Sans TC", monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-ink);
  margin-top: 16px;
  padding: 9px 13px;
  background: var(--bg-Warm);
  border: 1px solid var(--line-hair);
  border-left: 3px solid var(--accent-orange);
  overflow-wrap: anywhere;
}

.sheet-order span {
  margin: 0 8px;
  color: var(--accent-orange);
}

.actions {
  margin-top: 24px;
  border-top: 1px solid var(--line-hair);
  padding-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.actions #progress {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: auto;
}

.actions button {
  min-height: 40px;
}

footer {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-family: ui-monospace, "IBM Plex Mono", "Noto Sans TC", monospace;
  font-size: 11px;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line-hair);
}

.warnings {
  background: #FFF8EC;
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-left: 3.5px solid #D97706;
  padding: 14px 18px;
  margin-top: 20px;
  font-size: 12px;
  color: #78350F;
}

.warnings h3 {
  font-size: 13px;
  margin: 0 0 8px;
}

.warnings ul {
  padding-left: 18px;
  line-height: 1.75;
}

.warnings label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.6;
  font-weight: 700;
}

#error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-left: 3.5px solid #DC2626;
  padding: 13px 16px;
  margin-bottom: 18px;
  line-height: 1.65;
  font-weight: 600;
}

input[type=checkbox] {
  accent-color: var(--accent-orange);
}

button:focus-visible,
.drop-zone:focus-visible {
  outline: 2px solid var(--accent-orange);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  main { padding: 20px; }
  .workspace { grid-template-columns: 290px minmax(0, 1fr); }
  .review-section { padding: 20px 18px; }
  .totals { grid-template-columns: 1fr 1fr; }
  .checks { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  header { padding: 10px 16px; min-height: 56px; }
  .brand b { display: none; }
  .online { display: none; }
  main { padding: 18px 12px; }
  .heading { gap: 12px; align-items: center; }
  h1 { font-size: 21px; }
  .heading button { padding: 7px 11px; font-size: 12px; }
  .steps { gap: 0; justify-content: space-between; font-size: 12px; }
  .steps li { gap: 6px; }
  .workspace { display: block; }
  .input-section { border-right: 0; border-bottom: 1px solid var(--line-hair); padding: 18px; }
  .review-section { padding: 20px 14px; }
  .drop-zone { min-height: 116px; }
  .actions { flex-wrap: wrap; }
  .actions #progress { width: 100%; }
  .actions button { flex: 1; }
  .totals strong { font-size: 19px; }
  footer { gap: 10px; line-height: 1.5; flex-wrap: wrap; }
  .table-wrap { max-height: 400px; }
}
