:root {
  --orange: #f26b21;
  --orange-dark: #de5d18;
  --bg: #efefef;
  --card: #f3f3f3;
  --border: #d7d7d7;
  --text: #1f2937;
  --muted: #6b7280;
  --green-bg: #dff2dd;
  --green-text: #2a6c2f;
  --warn-bg: #fff2c9;
  --warn-text: #6b5500;
  --error-bg: #fde2e2;
  --error-text: #991b1b;
  --input-border: #9ab4d4;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

.site-header {
  background: #ececec;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.header-inner {
  max-width: 1700px;
  margin: 0 auto;
  padding: 20px 24px 12px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand-logo {
  width: 150px;
  max-height: 58px;
  object-fit: contain;
}
.header-title-wrap h1 {
  margin: 0;
  font-size: 29px;
  font-weight: 700;
  color: #202020;
}
.header-accent {
  height: 4px;
  background: var(--orange);
}

.main-wrap {
  width: 100%;
  padding: 34px 16px 24px;
}
.invoice-shell {
  max-width: 760px;
  margin: 0 auto;
}
.panel {
  background: #f1f1f1;
  border: 1px solid #ebebeb;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  padding: 30px 34px;
}
.panel-title {
  text-align: center;
  font-size: 22px;
  margin: 0 0 28px;
  color: #303030;
}
.panel-form {
  max-width: 430px;
  margin: 0 auto;
}
.panel-form.compact {
  max-width: 550px;
}
.field-block {
  margin-bottom: 18px;
}
.field-block label {
  display: block;
  font-weight: 700;
  color: #2f2f2f;
  margin-bottom: 8px;
}
.field-block input,
.field-block select {
  width: 100%;
  height: 48px;
  border: 2px solid var(--input-border);
  border-radius: 5px;
  padding: 11px 12px;
  background: #fff;
  outline: none;
}
.field-block input:focus,
.field-block select:focus {
  border-color: #5c8ec6;
  box-shadow: 0 0 0 3px rgba(92, 142, 198, 0.14);
}
.field-block small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.button-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.button-row.centered {
  justify-content: center;
  margin-top: 30px;
}
.btn {
  min-width: 140px;
  border-radius: 4px;
  padding: 13px 18px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
}
.btn:hover { opacity: .95; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary {
  background: #fff;
  color: var(--orange);
  border-color: var(--orange);
}
.btn-outline {
  background: #fff;
  color: #4b5563;
  border-color: #c7ccd3;
}
.full-btn {
  width: 100%;
}

.customer-title {
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 24px;
}
.customer-title span {
  color: var(--orange);
  margin-left: 6px;
}
.summary-card {
  max-width: 620px;
  margin: 0 auto 24px;
}
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.summary-item label,
.summary-description label {
  display: block;
  font-size: 13px;
  color: #434343;
  margin-bottom: 6px;
  font-weight: 700;
}
.summary-item input,
.summary-description input {
  width: 100%;
  height: 44px;
  border: 1px solid #d3d6dc;
  background: #ececec;
  border-radius: 5px;
  padding: 10px 12px;
  color: #2d2d2d;
}
.summary-description {
  margin-top: 12px;
}

.summary-items {
  margin-top: 14px;
}
.summary-items label {
  display: block;
  font-size: 13px;
  color: #434343;
  margin-bottom: 6px;
  font-weight: 700;
}
.summary-items-box {
  border: 1px solid #d3d6dc;
  background: #ececec;
  border-radius: 5px;
  overflow: hidden;
}
.summary-item-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid #d9dde3;
}
.summary-item-row:last-child {
  border-bottom: none;
}
.summary-item-main {
  display: grid;
  gap: 4px;
}
.summary-item-main strong {
  font-size: 14px;
  color: #2d2d2d;
}
.summary-item-main span,
.summary-item-price {
  font-size: 12px;
  color: #5b6470;
}
.summary-item-price {
  font-weight: 700;
  white-space: nowrap;
  align-self: center;
}

.notice-box {
  padding: 13px 14px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
}
.notice-box.warning {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid #f2d97d;
}

.system-message {
  max-width: 760px;
  margin: 0 auto 18px;
  padding: 13px 15px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.45;
}
.system-message.success {
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid #b8dfb6;
}
.system-message.error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #f4b6b6;
}

.success-banner {
  background: #dbf0d6;
  border: 1px solid #b7ddb0;
  color: #2a6c2f;
  border-radius: 6px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 280px;
  gap: 18px;
  align-items: start;
}
.pdf-viewer-card {
  background: #fafafa;
  border: 1px solid #d4d4d4;
  border-radius: 8px;
  overflow: hidden;
  min-height: 520px;
}
#pdf-preview {
  width: 100%;
  min-height: 520px;
  border: none;
  background: #f8f8f8;
}
.result-sidebar {
  display: grid;
  gap: 14px;
}
.result-info-card,
.result-meta {
  background: #f8f8f8;
  border: 1px solid #d7d7d7;
  border-radius: 8px;
  padding: 14px;
}
.result-label {
  font-weight: 700;
  margin-bottom: 6px;
}
.result-email {
  background: #fff;
  border: 1px solid #cfd5dc;
  padding: 10px 12px;
  border-radius: 4px;
  font-weight: 700;
  margin-bottom: 8px;
  word-break: break-word;
}
.result-meta {
  display: grid;
  gap: 8px;
  font-size: 14px;
}
.result-meta span {
  color: var(--muted);
}
.result-actions {
  display: grid;
  gap: 10px;
}

.bottom-info {
  max-width: 760px;
  margin: 20px auto 0;
}
.bottom-alert {
  background: #f6e8b2;
  border: 1px solid #e7d37d;
  border-radius: 6px;
  padding: 16px 18px;
  color: #6f5b06;
  font-size: 14px;
  line-height: 1.55;
}
.bottom-alert p { margin: 0 0 8px; }
.bottom-alert p:last-child { margin-bottom: 0; }

.site-footer {
  max-width: 1400px;
  margin: 18px auto 0;
  padding: 0 20px 24px;
  text-align: center;
  color: #626262;
  font-size: 12px;
  line-height: 1.5;
}

.modal-backdrop,
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 18px;
}
.modal-card,
.loading-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
}
.modal-card {
  width: 100%;
  max-width: 470px;
  padding: 30px 26px 24px;
  text-align: center;
}
.modal-icon {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  margin: 0 auto 18px;
  border: 3px solid #f1b575;
  color: #f1b575;
  font-size: 44px;
  display: grid;
  place-items: center;
}
.modal-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.modal-card p {
  margin: 0 0 10px;
  color: #414141;
  line-height: 1.5;
}
.modal-question {
  font-weight: 700;
}
.modal-actions {
  margin-top: 18px;
}
.loading-card {
  width: 100%;
  max-width: 280px;
  padding: 24px 20px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  text-align: center;
}
.spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin: 0 auto 16px;
  border: 4px solid rgba(242,107,33,0.22);
  border-top-color: var(--orange);
  animation: spin 1s linear infinite;
}
.loading-text {
  font-weight: 700;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@media (max-width: 700px) {
  .header-inner {
    padding: 16px 16px 12px;
  }
  .brand-logo {
    width: 110px;
  }
  .header-title-wrap h1 {
    font-size: 22px;
  }
  .main-wrap {
    padding: 22px 12px 18px;
  }
  .panel {
    padding: 24px 18px;
  }
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .button-row {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
}
