:root {
  color-scheme: light;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: #f6f7fb;
  color: #1b1f24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
}

.header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.auth {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-status {
  max-width: min(520px, 100%);
  font-size: 12px;
  color: #4b5563;
  line-height: 1.4;
  text-align: right;
  overflow-wrap: anywhere;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #111827;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
}

button:hover {
  opacity: 0.92;
}

button.secondary {
  background: #ffffff;
  color: #111827;
}

button.warn-action {
  border-color: #d97706;
  background: #d97706;
  color: #ffffff;
}

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

.auth-status.success {
  color: #047857;
}

.auth-status.warn {
  color: #b45309;
}

.auth-status.error {
  color: #b91c1c;
}

.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(380px, 0.95fr);
  align-items: start;
  gap: 20px;
  padding: 24px 32px;
}

.panel {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  min-height: 200px;
  min-width: 0;
}

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

.panel-header h2 {
  margin: 0 0 3px;
  font-size: 16px;
}

.panel-header p {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.4;
}

.operations-panel {
  grid-column: 1 / -1;
  min-height: 0;
}

.utility-body,
.manual-order-body {
  margin-top: 14px;
  min-width: 0;
}

.client-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.client-form label,
.manual-order-form label {
  font-size: 12px;
  color: #4b5563;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.client-form input,
.manual-order-form input,
.manual-order-form select {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}

.manual-order-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.manual-size-grid {
  grid-column: 1 / -1;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 10px;
}

.manual-size-grid legend {
  font-size: 12px;
  color: #4b5563;
  padding: 0 4px;
}

.manual-full {
  grid-column: 1 / -1;
}

.manual-submit {
  justify-self: start;
}

.checkbox-field {
  align-self: center;
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}

.checkbox-field input {
  width: auto;
}

.credentials {
  margin-top: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 12px;
  background: #f9fafb;
}

.credentials pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  color: #111827;
}

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

.operation-drawer {
  min-width: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}

.operation-drawer summary {
  cursor: pointer;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #111827;
}

.operation-drawer[open] summary {
  border-bottom: 1px solid #e5e7eb;
}

.operation-drawer > .manual-order-body,
.operation-drawer > .utility-body {
  margin-top: 0;
  padding: 12px;
}

.orders-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.orders-table th,
.orders-table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
  line-height: 1.35;
}

.orders-col-order {
  width: 360px;
}

.orders-col-customer {
  width: 280px;
}

.orders-col-status {
  width: 120px;
}

.orders-col-fulfillment {
  width: 150px;
}

.orders-col-sync {
  width: 120px;
}

.orders-col-created {
  width: 150px;
}

.orders-table .clip,
.orders-table .status,
.orders-table .fulfillment,
.orders-table .sync,
.orders-table .date {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-main,
.table-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-main {
  color: #111827;
  font-weight: 700;
}

.table-sub {
  margin-top: 2px;
  color: #6b7280;
  font-size: 11px;
}

.orders-table tbody tr {
  cursor: pointer;
}

.orders-table tbody tr:hover {
  background: #f8fafc;
}

.orders-table tbody tr.selected {
  background: #edf6ff;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.detail-glance {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.glance-card {
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.detail-summary,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.detail-summary {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
}

.detail-full {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 13px;
  color: #111827;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.detail-value a {
  color: #1d4ed8;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.detail-value a:hover {
  text-decoration: underline;
}

.address-block {
  white-space: pre-line;
  line-height: 1.45;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.sync-ok {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.sync-failed {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.sync-unknown {
  border-color: #d1d5db;
  background: #f3f4f6;
  color: #4b5563;
}

.fulfillment-unsent {
  border-color: #d1d5db;
  background: #f3f4f6;
  color: #4b5563;
}

.fulfillment-sent {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.fulfillment-reply {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.fulfillment-failed {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.status-submitted {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.status-in_progress {
  border-color: #c4b5fd;
  background: #f5f3ff;
  color: #6d28d9;
}

.status-ready {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.status-shipped {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.status-delivered {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.status-blocked {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.status-cancelled {
  border-color: #d1d5db;
  background: #f3f4f6;
  color: #4b5563;
}

.detail-section {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #111827;
}

.compact-header {
  margin-bottom: 12px;
}

.compact-header h3 {
  margin: 0;
}

.fulfillment-thread {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fulfillment-empty {
  margin: 0;
}

.fulfillment-thread-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  padding: 10px;
}

.fulfillment-thread-title {
  font-size: 12px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.fulfillment-email-message {
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
  margin-top: 8px;
}

.fulfillment-email-message:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.fulfillment-email-meta {
  color: #6b7280;
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.fulfillment-email-subject {
  margin-top: 3px;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.fulfillment-email-body {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 6px 0 0;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #ffffff;
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
}

.preview {
  max-width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  background: #f9fafb;
}

.svg-preview {
  display: block;
  width: min(280px, 100%);
  max-height: 240px;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.asset-warning {
  font-size: 12px;
  margin: 2px 0 8px;
}

.asset-warning.warn {
  color: #b45309;
}

.response-body {
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #f9fafb;
}

.action-section {
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

.status-control {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.status-control label {
  font-size: 12px;
  color: #4b5563;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-control select {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  min-height: 34px;
  max-width: 100%;
}

.status-message {
  font-size: 12px;
  margin-top: 8px;
}

.status-message.success {
  color: #047857;
}

.status-message.warn {
  color: #b45309;
}

.status-message.error {
  color: #b91c1c;
}

.status-message.info {
  color: #1d4ed8;
}

.empty {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 12px;
}

.hidden {
  display: none;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .header {
    align-items: flex-start;
  }

  .auth {
    justify-content: flex-start;
  }

  .auth-status {
    text-align: left;
  }

  .layout {
    padding: 20px;
  }

  .client-form {
    grid-template-columns: 1fr;
  }

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

  .manual-size-grid {
    grid-template-columns: repeat(2, minmax(80px, 1fr));
  }

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

@media (max-width: 560px) {
  .header {
    padding: 16px;
    gap: 14px;
  }

  .header > div:first-child,
  .auth {
    width: 100%;
  }

  h1 {
    font-size: 19px;
  }

  .auth {
    gap: 8px;
  }

  .auth-status {
    flex-basis: 100%;
  }

  .auth button {
    flex: 1 1 120px;
  }

  .layout {
    gap: 14px;
    padding: 14px;
  }

  .panel {
    padding: 12px;
    border-radius: 8px;
  }

  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-glance {
    grid-template-columns: minmax(0, 1fr);
  }

  .status-control {
    align-items: stretch;
  }

  .status-control label,
  .status-control button {
    width: 100%;
  }

  .status-control select {
    width: 100%;
  }
}
