* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: #231d15;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(183, 164, 130, 0.22), transparent 34%),
    linear-gradient(180deg, #f8f4ee 0%, #efe7da 100%);
}

#app {
  min-height: 100vh;
  padding-bottom: 48px;
}

.top-shell {
  position: sticky;
  top: 0;
  z-index: 120;
  padding: 20px 16px 0;
}

.top-bar {
  width: min(1240px, 100%);
  margin: 0 auto;
  display: flex;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 18px 20px;
  border: 1px solid rgba(160, 141, 110, 0.28);
  border-radius: 24px;
  background: rgba(255, 251, 245, 0.9);
  box-shadow: 0 20px 48px rgba(72, 56, 30, 0.12);
  backdrop-filter: blur(14px);
}

.top-bar-search {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.top-bar-label {
  color: #6a5a42;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-bar input {
  width: min(360px, 100%);
  height: 52px;
  padding: 0 16px;
  border: 1px solid #cfc3b1;
  border-radius: 16px;
  background: #fffdf9;
  color: #221b14;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.top-bar input:focus {
  border-color: #3f2f18;
  box-shadow: 0 0 0 4px rgba(111, 91, 60, 0.1);
  transform: translateY(-1px);
}

.top-bar-hint {
  color: #73644d;
  font-size: 12px;
  line-height: 1.5;
}

.top-mode-switch {
  display: inline-flex;
  gap: 8px;
  margin-top: 4px;
}

.mode-btn {
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(130, 110, 76, 0.32);
  border-radius: 999px;
  background: rgba(255, 251, 246, 0.88);
  color: #6e593c;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  transform: translateY(-1px);
}

.mode-btn-active {
  border-color: rgba(67, 45, 20, 0.78);
  background: linear-gradient(135deg, #3c2c1a 0%, #5a4026 100%);
  color: #fffaf3;
}

.top-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  color: #f8f3ec;
  background: linear-gradient(135deg, #271c12 0%, #46311e 100%);
  box-shadow: 0 12px 24px rgba(55, 37, 17, 0.18);
}

.btn-device-preview {
  color: #3f2d1a;
  border-color: rgba(137, 108, 68, 0.38);
  background: linear-gradient(135deg, #fffaf2 0%, #eadcc8 100%);
  box-shadow: 0 10px 22px rgba(92, 66, 31, 0.12);
}

.btn-secondary {
  color: #fffaf5;
  background: linear-gradient(135deg, #8b6840 0%, #b28758 100%);
  box-shadow: 0 12px 24px rgba(121, 84, 41, 0.16);
}

.btn-ghost {
  color: #5d4a34;
  background: rgba(255, 252, 247, 0.78);
  border-color: rgba(141, 118, 81, 0.28);
}

.btn-muted {
  color: #5f5242;
  background: #ebe3d7;
  border-color: #ddd1c1;
}

.mini-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(146, 122, 84, 0.32);
  border-radius: 999px;
  background: #fffdf9;
  color: #5b4831;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn-muted {
  background: #f2eadf;
}

.workspace {
  width: min(1240px, calc(100% - 32px));
  margin: 24px auto 0;
}

.customs-doc {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 14px 12px 24px;
  border-radius: 24px;
  border: 1px solid #e5e5e5;
  background: #f4f4f4;
  color: #16181d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.customs-order-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 4px 4px 14px;
}

.customs-order-anchor {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.customs-back-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1f1f1f;
  margin-top: 4px;
}

.customs-back-icon svg {
  width: 22px;
  height: 22px;
}

.customs-order-copy h2 {
  margin: 0;
  color: #101114;
  font-size: 28px;
  line-height: 1.14;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.customs-order-copy p {
  margin: 4px 0 0;
  color: #6b7079;
  font-size: 16px;
  line-height: 1.4;
}

.customs-order-copy h2 span {
  margin-left: 6px;
  display: inline-block;
}

.customs-buy-btn {
  height: 44px;
  padding: 0 20px;
  border: 1px solid #d6d8dc;
  border-radius: 14px;
  background: #f8fafb;
  color: #2f7291;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.customs-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr);
}

.customs-main-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.customs-card {
  padding: 22px;
  border-radius: 18px;
  border: 1px solid #d8dce1;
  background: #ffffff;
}

.customs-card h3 {
  margin: 0;
  color: #181a1f;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.customs-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.customs-status-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.customs-status-title-wrap {
  min-width: 0;
}

.customs-status-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.customs-status-title h3 {
  font-size: 22px;
  line-height: 1.2;
}

.customs-status-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1f232a;
}

.customs-status-icon svg {
  width: 20px;
  height: 20px;
}

.customs-status-title-wrap p {
  margin: 8px 0 0;
  color: #5f6671;
  font-size: 16px;
  line-height: 1.35;
}

.customs-show-details {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: #2e7c98;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.customs-show-details svg {
  width: 16px;
  height: 16px;
}

.customs-status-message {
  margin-top: 16px;
  color: #262a31;
  font-size: 14px;
  line-height: 1.45;
  white-space: normal;
}

.customs-details-grid {
  margin-top: 18px;
  display: grid;
  gap: 18px 26px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.customs-detail-block h4 {
  margin: 0;
  color: #727883;
  font-size: 13px;
  font-weight: 600;
}

.customs-detail-block p {
  margin: 8px 0 0;
  color: #1f2530;
  font-size: 14px;
  line-height: 1.6;
  display: block;
  width: 100%;
  text-align: left;
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.customs-summary-card {
  padding-bottom: 20px;
}

.customs-summary-card h3 {
  font-size: 22px;
}

.customs-add-product {
  height: 36px;
  padding: 0 16px;
  border: 1px solid #d0d4da;
  border-radius: 999px;
  background: #f7f9fb;
  color: #2f343d;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.customs-summary-items {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.customs-summary-item {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #ececec;
}

.customs-summary-item:last-child {
  border-bottom: none;
}

.customs-summary-image-wrap {
  position: relative;
  width: 70px;
  height: 70px;
}

.customs-summary-image {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #d9dce1;
  background: #ffffff;
}

.customs-image-upload-input {
  display: none;
}

.customs-qty-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #6f7278;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.customs-summary-copy {
  min-width: 0;
}

.customs-summary-title {
  color: #1f2430;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.customs-summary-meta {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: #676f7a;
  font-size: 12px;
}

.customs-summary-price {
  min-width: 88px;
  text-align: right;
  color: #1f2632;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.customs-empty {
  margin-top: 6px;
  padding: 16px;
  border: 1px dashed #d0d4d9;
  border-radius: 12px;
  color: #6e737b;
  font-size: 13px;
  text-align: center;
  background: #f8f9fb;
}

.customs-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-row {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  color: #262f3d;
  font-size: 13px;
  line-height: 1.4;
}

.summary-row-total {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e6e8ed;
  color: #1a2230;
  font-size: 16px;
  font-weight: 600;
}

.summary-row > span:last-child,
.summary-row-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-row-value {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-remove {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid #111827;
  border-radius: 999px;
  background: #fff;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.summary-remove:hover {
  background: #111827;
  color: #fff;
}

.customs-summary-items + .summary-row {
  margin-top: 16px;
}

.customs-summary-item .item-remove {
  min-width: 60px;
  margin-left: 4px;
}

.summary-total-amount {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.summary-total-amount small {
  font-size: 11px;
  color: #858b95;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.summary-total-amount strong {
  font-size: 17px;
  color: #17202d;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.customs-status-message,
.customs-summary-title,
.summary-row,
.summary-row-total,
.customs-detail-block p,
.customs-order-copy p,
.customs-buy-btn {
  letter-spacing: 0;
}

.customs-card p.editable,
.customs-summary-meta .editable,
.summary-row .editable {
  display: inline-block;
  padding: 0 2px;
}

.customs-detail-block p.editable {
  display: block;
  padding: 0;
}

.customs-summary-meta span {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.editable {
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.editable:hover {
  background: rgba(64, 64, 64, 0.12);
}

.modal,
.preview-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(38, 29, 17, 0.46);
  backdrop-filter: blur(10px);
}

.modal {
  z-index: 260;
}

.preview-modal {
  z-index: 280;
}

.device-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(32, 24, 14, 0.58);
  backdrop-filter: blur(12px);
}

.device-preview-dialog {
  width: min(1480px, calc(100vw - 24px));
  height: min(94dvh, 1100px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(157, 136, 102, 0.28);
  border-radius: 28px;
  background: #f7f1e8;
  box-shadow: 0 34px 100px rgba(34, 24, 13, 0.38);
}

.device-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(184, 166, 139, 0.42);
  background: rgba(255, 252, 247, 0.94);
}

.device-preview-heading {
  min-width: 0;
}

.device-preview-header h3 {
  margin: 7px 0 0;
  color: #21180f;
  font-size: 26px;
  line-height: 1.1;
}

.device-preview-header p {
  margin: 7px 0 0;
  color: #6f614d;
  font-size: 13px;
  line-height: 1.5;
}

.device-preview-close {
  flex: none;
}

.device-preview-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) minmax(230px, 0.8fr) minmax(130px, 0.42fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(184, 166, 139, 0.36);
  background: rgba(255, 249, 241, 0.9);
}

.device-control-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.device-control-field > span {
  color: #735f42;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.device-control-field select,
.device-dimension-inputs input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #cfc2b0;
  border-radius: 12px;
  outline: none;
  background: #fffdfa;
  color: #2b2319;
  font-size: 16px;
}

.device-control-field select:focus,
.device-dimension-inputs input:focus {
  border-color: #47331d;
  box-shadow: 0 0 0 3px rgba(111, 91, 60, 0.12);
}

.device-dimension-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.device-dimension-inputs > span {
  color: #75654f;
  font-weight: 700;
}

.device-preview-control-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.device-preview-control-actions .btn {
  width: auto;
  min-height: 44px;
  height: auto;
  padding: 8px 12px;
  white-space: nowrap;
}

.device-preview-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 9px 22px;
  border-bottom: 1px solid rgba(184, 166, 139, 0.3);
  background: #efe4d5;
  color: #68583f;
  font-size: 12px;
}

.device-preview-meta strong {
  color: #2a2117;
}

.device-preview-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 24px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(45deg, rgba(115, 91, 58, 0.05) 25%, transparent 25%, transparent 75%, rgba(115, 91, 58, 0.05) 75%),
    linear-gradient(45deg, rgba(115, 91, 58, 0.05) 25%, transparent 25%, transparent 75%, rgba(115, 91, 58, 0.05) 75%),
    #e9dfd1;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

.device-preview-frame-shell {
  position: relative;
  flex: none;
}

.device-preview-frame {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  transform-origin: top left;
  border: 10px solid #251d15;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 24px 56px rgba(38, 27, 15, 0.3);
}

.device-preview-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.product-modal {
  z-index: 270;
}

.modal-content {
  width: min(560px, calc(100vw - 32px));
  padding: 34px;
  border: 1px solid rgba(145, 123, 91, 0.22);
  border-radius: 28px;
  background: linear-gradient(180deg, #fffdf9 0%, #f4ede3 100%);
  box-shadow: 0 30px 70px rgba(45, 31, 17, 0.24);
}

.product-dialog {
  width: min(960px, calc(100vw - 30px));
  max-height: min(88vh, 920px);
  padding: 24px;
  border: 1px solid rgba(188, 172, 148, 0.4);
  border-radius: 24px;
  background: #fffbf6;
  box-shadow: 0 34px 90px rgba(45, 31, 17, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.product-header h3 {
  margin: 10px 0 4px;
  color: #21180f;
  font-size: 28px;
}

.product-header p {
  margin: 0;
  color: #6f614d;
  font-size: 13px;
}

.product-search-row {
  display: flex;
  gap: 10px;
}

.product-search-row input {
  flex: 1;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid #cfc2b0;
  border-radius: 14px;
  background: #fffdfa;
  color: #211b14;
  font-size: 16px;
  outline: none;
}

.product-search-row input:focus {
  border-color: #47331d;
  box-shadow: 0 0 0 4px rgba(111, 91, 60, 0.12);
}

.product-error {
  color: #9a2e1f;
  font-size: 13px;
}

.product-list {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid #e4d8c8;
  background: #fff;
}

.product-item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #f0e5d8;
}

.product-item:last-child {
  border-bottom: none;
}

.product-thumb {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #eadfce;
  background: #fff;
}

.product-copy {
  min-width: 0;
}

.product-title {
  color: #2b2319;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.product-meta {
  margin-top: 4px;
  color: #74644f;
  font-size: 12px;
}

.product-variant-field {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  max-width: 420px;
  color: #74644f;
  font-size: 11px;
  font-weight: 600;
}

.product-variant-select {
  width: 100%;
  min-height: 36px;
  padding: 7px 34px 7px 10px;
  border: 1px solid #d8c8b3;
  border-radius: 9px;
  background: #fffdfa;
  color: #2b2319;
  font: inherit;
  font-size: 12px;
  outline: none;
}

.product-variant-select:focus {
  border-color: #47331d;
  box-shadow: 0 0 0 3px rgba(111, 91, 60, 0.12);
}

.product-price {
  color: #2b2319;
  font-size: 14px;
  font-weight: 700;
}

.product-empty {
  padding: 22px;
  color: #7e6f5a;
  text-align: center;
  font-size: 13px;
}

.product-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-kicker,
.preview-kicker {
  color: #8b7352;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal-content h3,
.preview-copy h3 {
  margin: 10px 0 0;
  color: #1f180f;
  font-size: 32px;
  line-height: 1.1;
}

.modal-description,
.preview-copy p {
  margin: 12px 0 0;
  color: #6f614d;
  font-size: 14px;
  line-height: 1.6;
}

.modal-content input {
  width: 100%;
  min-height: 56px;
  margin-top: 22px;
  padding: 0 16px;
  border: 1px solid #cfc2b0;
  border-radius: 16px;
  background: #fffdfa;
  color: #211b14;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-content textarea {
  width: 100%;
  margin-top: 22px;
  padding: 12px 16px;
  border: 1px solid #cfc2b0;
  border-radius: 16px;
  background: #fffdfa;
  color: #211b14;
  font-size: 15px;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  min-height: 180px;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-content input:focus {
  border-color: #47331d;
  box-shadow: 0 0 0 4px rgba(111, 91, 60, 0.12);
}

.modal-content textarea:focus {
  border-color: #47331d;
  box-shadow: 0 0 0 4px rgba(111, 91, 60, 0.12);
}

.modal-btns {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.preview-dialog {
  width: min(1320px, calc(100vw - 24px));
  height: min(92vh, 980px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(157, 136, 102, 0.25);
  border-radius: 30px;
  overflow: hidden;
  background: #f6f0e5;
  box-shadow: 0 34px 90px rgba(41, 29, 15, 0.32);
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(184, 166, 139, 0.42);
  background: rgba(255, 251, 246, 0.86);
}

.preview-copy {
  max-width: 560px;
}

.preview-toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.preview-stage {
  flex: 1;
  overflow: auto;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 251, 246, 0.35), rgba(231, 220, 204, 0.72)),
    linear-gradient(90deg, rgba(164, 141, 108, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
}

.preview-sheet {
  min-height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.preview-sheet .invoice-box,
.preview-sheet .customs-doc {
  margin: 0 auto;
  box-shadow: 0 20px 46px rgba(50, 36, 17, 0.14);
}

.preview-sheet .editable {
  background: transparent !important;
}

.invoice-render-host {
  position: fixed;
  left: -200vw;
  top: 0;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.pdf-export-mode.customs-doc {
  width: 1020px;
  max-width: 1020px;
  padding: 20px 18px 26px;
}

.pdf-export-mode .pdf-export-layout {
  display: block;
}

.pdf-export-mode .pdf-export-side {
  margin-top: 18px;
}

.pdf-export-mode .pdf-export-summary-card {
  break-inside: avoid;
  page-break-inside: avoid;
}

.pdf-export-mode .pdf-export-summary-item {
  break-inside: avoid;
  page-break-inside: avoid;
}

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

  .customs-order-copy h2 {
    font-size: 26px;
  }

  .customs-order-copy p {
    font-size: 15px;
  }

  .customs-buy-btn {
    height: 40px;
    font-size: 14px;
  }
}

@media (max-width: 1024px) {
  .top-bar {
    align-items: stretch;
  }

  .top-bar,
  .preview-toolbar,
  .product-header,
  .product-search-row {
    flex-direction: column;
  }

  .customs-order-head {
    flex-direction: column;
  }

  .top-bar input {
    width: 100%;
  }

  .top-bar-actions,
  .preview-toolbar-actions {
    justify-content: flex-start;
  }

  .customs-details-grid {
    grid-template-columns: 1fr;
  }

  .customs-card h3 {
    font-size: 20px;
  }

  .customs-order-copy h2 {
    font-size: 22px;
  }

  .customs-order-copy p {
    font-size: 14px;
  }

  .customs-buy-btn {
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
  }

  .summary-row-total {
    font-size: 15px;
  }

  .summary-total-amount strong {
    font-size: 16px;
  }

  .customs-summary-item,
  .product-item {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .customs-summary-image-wrap,
  .customs-summary-image,
  .product-thumb {
    width: 72px;
    height: 72px;
  }

  .product-footer {
    justify-content: flex-start;
  }

  .preview-stage {
    padding: 18px;
  }

  .preview-dialog {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    border-radius: 22px;
  }

  .product-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    border-radius: 18px;
    padding: 16px;
  }

  .modal,
  .preview-modal,
  .product-modal,
  .device-preview-modal {
    padding: 8px;
  }
}

@media (max-width: 1024px) {
  #app {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .top-shell {
    position: static;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: 0;
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .top-bar {
    gap: 14px;
    padding: 14px;
    border-radius: 18px;
  }

  .top-bar-search {
    min-width: 0;
  }

  .top-bar input,
  .product-search-row input,
  .modal-content input,
  .modal-content textarea,
  .product-variant-select {
    font-size: 16px;
  }

  .top-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .mode-btn {
    min-height: 44px;
    height: auto;
    padding: 8px 10px;
    line-height: 1.2;
  }

  .top-bar-actions,
  .preview-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .btn {
    width: 100%;
    min-height: 44px;
    height: auto;
    padding: 9px 10px;
    font-size: 13px;
    line-height: 1.2;
  }

  .workspace {
    width: auto;
    margin-top: 12px;
    margin-right: max(10px, env(safe-area-inset-right));
    margin-left: max(10px, env(safe-area-inset-left));
  }

  .customs-doc {
    padding: 10px 8px 18px;
    border-radius: 18px;
  }

  .customs-order-head {
    gap: 10px;
    padding: 4px 2px 12px;
  }

  .customs-order-anchor {
    gap: 6px;
  }

  .customs-order-copy h2 {
    font-size: 20px;
  }

  .customs-buy-btn,
  .customs-add-product,
  .customs-show-details,
  .summary-remove,
  .mini-btn {
    min-height: 44px;
  }

  .customs-card {
    padding: 16px;
    border-radius: 14px;
  }

  .customs-card-head,
  .customs-status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .customs-details-grid {
    gap: 16px;
  }

  .customs-summary-item {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px 12px;
    align-items: start;
  }

  .customs-summary-image-wrap,
  .customs-summary-image {
    width: 64px;
    height: 64px;
  }

  .customs-summary-price,
  .customs-summary-item .item-remove {
    grid-column: 2;
    justify-self: start;
    min-width: 0;
    margin-left: 0;
    text-align: left;
  }

  .summary-row {
    gap: 14px;
  }

  .summary-row-value {
    max-width: 65%;
  }

  .modal-content {
    width: calc(100vw - 16px);
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    padding: 22px;
    border-radius: 20px;
    overflow-y: auto;
  }

  .modal-content h3,
  .preview-copy h3 {
    font-size: 25px;
  }

  .modal-content input,
  .modal-content textarea {
    margin-top: 16px;
  }

  .modal-btns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
  }

  .product-dialog {
    width: calc(100vw - 16px);
    max-width: 100%;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 14px;
    gap: 10px;
  }

  .product-header h3 {
    font-size: 24px;
  }

  .product-list {
    flex: 1;
    min-height: 0;
  }

  .product-item {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px 12px;
  }

  .product-thumb {
    width: 58px;
    height: 58px;
  }

  .product-price,
  .product-item .mini-btn {
    grid-column: 2;
    justify-self: start;
  }

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

  .preview-dialog {
    width: calc(100vw - 12px);
    max-width: 100%;
    height: calc(100dvh - 12px);
    border-radius: 18px;
  }

  .device-preview-dialog {
    width: calc(100vw - 12px);
    max-width: 100%;
    height: calc(100dvh - 12px);
    border-radius: 18px;
  }

  .device-preview-header {
    padding: 15px 16px 12px;
  }

  .device-preview-close {
    width: auto;
    min-width: 76px;
  }

  .device-preview-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 16px;
  }

  .device-control-model,
  .device-preview-control-actions {
    grid-column: 1 / -1;
  }

  .device-preview-control-actions {
    justify-content: flex-start;
  }

  .device-preview-meta {
    padding: 8px 16px;
  }

  .device-preview-stage {
    justify-content: flex-start;
    padding: 16px;
  }

  .preview-toolbar {
    gap: 14px;
    padding: 16px;
  }

  .preview-toolbar-actions .btn:last-child {
    grid-column: 1 / -1;
  }

  .preview-stage {
    padding: 10px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .preview-sheet {
    width: max-content;
    min-width: 100%;
    justify-content: flex-start;
  }

  .preview-sheet .invoice-box {
    flex: 0 0 595pt;
    width: 595pt;
    max-width: none;
  }

  .modal,
  .preview-modal,
  .product-modal,
  .device-preview-modal {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(8px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
  }
}

@media (max-width: 420px) {
  .top-bar-actions,
  .preview-toolbar-actions,
  .product-footer {
    grid-template-columns: 1fr;
  }

  .preview-toolbar-actions .btn:last-child {
    grid-column: auto;
  }

  .top-bar-hint {
    font-size: 11px;
  }

  .customs-card {
    padding: 14px;
  }

  .summary-row-value {
    max-width: 58%;
  }

  .device-preview-header {
    gap: 10px;
  }

  .device-preview-header h3 {
    font-size: 22px;
  }

  .device-preview-header p {
    display: none;
  }

  .device-preview-controls {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .device-control-model,
  .device-preview-control-actions {
    grid-column: auto;
  }

  .device-preview-control-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .device-preview-control-actions .btn {
    width: 100%;
    padding: 8px 6px;
    white-space: normal;
  }

  .device-preview-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}

@media (max-width: 360px) {
  .top-shell {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-right: max(6px, env(safe-area-inset-right));
    padding-left: max(6px, env(safe-area-inset-left));
  }

  .top-bar {
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
  }

  .top-bar input {
    height: 48px;
    padding: 0 12px;
  }

  .top-bar-hint {
    display: none;
  }

  .workspace {
    margin-top: 8px;
    margin-right: max(6px, env(safe-area-inset-right));
    margin-left: max(6px, env(safe-area-inset-left));
  }

  .modal,
  .preview-modal,
  .product-modal,
  .device-preview-modal {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-right: max(6px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(6px, env(safe-area-inset-left));
  }

  .modal-content,
  .product-dialog {
    padding: 16px;
    border-radius: 16px;
  }

  .modal-content h3,
  .preview-copy h3,
  .product-header h3 {
    font-size: 22px;
  }

  .preview-toolbar {
    padding: 12px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .top-shell {
    position: static;
    padding: 8px 10px 0;
  }

  .top-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 16px;
  }

  .top-bar-search {
    min-width: 0;
    gap: 4px;
  }

  .top-bar input {
    width: 100%;
    height: 42px;
  }

  .top-bar-hint {
    display: none;
  }

  .top-mode-switch,
  .top-bar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .mode-btn,
  .btn {
    width: 100%;
    min-height: 44px;
    height: auto;
    padding: 7px 9px;
  }

  .workspace {
    margin-top: 10px;
  }
}

@media (hover: none) {
  .btn:hover,
  .mode-btn:hover {
    transform: none;
  }

  .editable:active {
    background: rgba(64, 64, 64, 0.12);
  }
}

@media (pointer: coarse) {
  .mode-btn,
  .mini-btn,
  .customs-buy-btn,
  .customs-add-product,
  .customs-show-details,
  .summary-remove,
  .item-remove,
  .item-add-button {
    min-height: 44px;
  }

  .top-bar input,
  .product-search-row input,
  .modal-content input,
  .modal-content textarea,
  .product-variant-select {
    font-size: 16px;
  }
}
