:root {
  --ink: #152033;
  --muted: #657086;
  --line: #dbe1ea;
  --soft: #f6f3ec;
  --paper: #ffffff;
  --navy: #10243f;
  --gold: #c49a45;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(21, 32, 51, .12);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, #f7f4ed 0%, #eef2f6 52%, #ffffff 100%);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}

img { max-width: 100%; display: block; }

.hidden { display: none !important; }

.lock-screen {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
}

.lock-card {
  width: min(420px, 100%);
  padding: 28px;
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(16,36,63,.08);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.lock-card img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lock-card h1, .hero-panel h1 {
  margin: 0;
  line-height: 1.12;
}

.muted, .hero-panel p, .section-title p {
  color: var(--muted);
  line-height: 1.6;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  color: #26334a;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea { resize: vertical; }

input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196,154,69,.16);
}

.primary-btn, .ghost-btn {
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 999px;
  font-weight: 800;
}

.primary-btn {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 24px rgba(16,36,63,.22);
}

.ghost-btn {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--line);
}

.danger { color: var(--danger); }
.error-text { color: var(--danger); min-height: 20px; }
.status-text { color: var(--muted); line-height: 1.5; }

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px 14px 60px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.15;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.hero-panel, .step-card {
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(16,36,63,.08);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 26px;
  margin: 10px 0 16px;
}

.hero-panel h1 {
  font-size: clamp(30px, 8vw, 54px);
}

.step-card {
  padding: 18px;
  margin: 16px 0;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.section-title > span {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #fff;
  background: var(--navy);
  font-weight: 900;
}

.section-title h2 {
  margin: 0;
  font-size: clamp(22px, 6vw, 32px);
  line-height: 1.2;
}

.section-title p { margin: 6px 0 0; }

.action-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
}

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

.wide { grid-column: 1 / -1; }

.products-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 10px;
}

.products-head h3 { margin: 0; }

.product-row {
  display: grid;
  grid-template-columns: 1.4fr .8fr .8fr .8fr .8fr auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfe;
  margin-bottom: 10px;
}

.product-row .remove {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid #ffd6d2;
}

.summary-box, .missing-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--soft);
  line-height: 1.6;
}

.missing-box {
  color: var(--danger);
  background: #fff3f0;
}

.invoice-shell {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
}

.pi-document {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  padding: 34px;
  background: #fff;
  color: #172033;
  border: 1px solid #d8dee8;
  box-shadow: 0 16px 30px rgba(21,32,51,.1);
  font-family: Arial, sans-serif;
}

.pi-top {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  border-bottom: 3px solid #10243f;
  padding-bottom: 16px;
}

.pi-top h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: .02em;
}

.pi-top p { margin: 4px 0 0; color: #657086; }
.pi-meta { text-align: right; line-height: 1.7; }

.pi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.pi-box {
  border: 1px solid #dbe1ea;
  border-radius: 10px;
  padding: 12px;
}

.pi-box h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #10243f;
  text-transform: uppercase;
}

.pi-line {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 8px;
  font-size: 12px;
  line-height: 1.45;
  margin: 4px 0;
}

.pi-line b { color: #39445a; }
.pi-line span {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.buyer-box .pi-line {
  grid-template-columns: 112px minmax(0, 1fr);
  font-size: 11.5px;
}

.buyer-box .buyer-email span {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  font-size: 11px;
}

.shipping-method-line {
  margin: 10px 0 0 auto;
  width: 320px;
  border: 1px solid #dbe1ea;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
  background: #fff;
}

.payment-section {
  margin-top: 16px;
}

.payment-box .pi-line {
  grid-template-columns: 150px minmax(0, 1fr);
  font-size: 11.2px;
  line-height: 1.5;
}

.payment-box .pi-line span {
  overflow-wrap: normal;
  word-break: normal;
}

.payment-box .bank-address span {
  white-space: nowrap;
  letter-spacing: 0;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.invoice-table th {
  background: #10243f;
  color: #fff;
  padding: 8px 6px;
  text-align: left;
}

.invoice-table td {
  border: 1px solid #dbe1ea;
  padding: 7px 6px;
  vertical-align: middle;
}

.invoice-table .num { text-align: right; white-space: nowrap; }
.product-photo {
  max-width: 70px;
  max-height: 90px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto;
}

.total-table {
  width: 320px;
  margin-left: auto;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 12px;
}

.total-table td {
  border: 1px solid #dbe1ea;
  padding: 8px;
}

.total-table .grand {
  background: #f6f3ec;
  font-weight: 800;
}

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.notes ul { padding-left: 18px; margin: 0; font-size: 11px; line-height: 1.55; }

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  line-height: 1.5;
}

.history-item strong { display: block; }
.history-item span { color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .app { padding-left: 10px; padding-right: 10px; }
  .hero-panel, .step-card { border-radius: 18px; padding: 16px; }
  .app-header .ghost-btn { font-size: 12px; padding: 8px 10px; min-height: 38px; }
  .form-grid, .pi-grid, .notes { grid-template-columns: 1fr; }
  .product-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .product-row .remove { grid-column: 1 / -1; width: 100%; border-radius: 12px; }
  .invoice-shell { margin: 0 -12px; }
  .pi-document { transform-origin: top left; }
  .sticky-actions {
    position: sticky;
    bottom: 8px;
    padding: 8px;
    background: rgba(255,255,255,.94);
    border-radius: 999px;
    box-shadow: var(--shadow);
  }
}

@media print {
  body { background: #fff; }
  .app-header, .hero-panel, .step-card:not(#previewSection), .section-title, .sticky-actions, .status-text { display: none !important; }
  #previewSection { display: block !important; box-shadow: none; border: 0; padding: 0; margin: 0; }
  .invoice-shell { padding: 0; overflow: visible; }
  .pi-document { width: auto; min-height: auto; border: 0; box-shadow: none; padding: 0; }
}
