* {
  box-sizing: border-box;
}

:root {
  --green: #064a31;
  --gold: #a97719;
  --cream: #f4f1df;
  --line: #d7d3bf;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eeeade;
  color: #163c2c;
  font-family: "Montserrat", Arial, sans-serif;
}

.page {
  width: 100%;
  padding: 28px;
}

.generator {
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: rgba(255,255,255,.9);
  border: 1px solid #d9d5c5;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.08);
}

.form-panel {
  padding: 24px;
  position: sticky;
  top: 20px;
}

.brand {
  margin-bottom: 22px;
  color: var(--green);
}

.brand span {
  display: block;
  font-family: "Cinzel", Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .06em;
}

.brand small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: .18em;
  font-weight: 700;
  opacity: .7;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

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

input {
  width: 100%;
  border: 1px solid #d3d1c5;
  border-radius: 9px;
  padding: 11px 12px;
  font: 500 13px "Montserrat", Arial, sans-serif;
  color: #173c2d;
  background: #fafaf6;
  outline: none;
}

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(169,119,25,.10);
}

input[type="file"] {
  padding: 8px;
}

.buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 20px;
}

button {
  border: 0;
  border-radius: 9px;
  padding: 12px 10px;
  cursor: pointer;
  font: 700 11px "Montserrat", Arial, sans-serif;
  letter-spacing: .04em;
  color: white;
  background: var(--green);
}

button:hover {
  filter: brightness(1.08);
}

button.secondary {
  background: #9a6c18;
}

button.ghost {
  color: var(--green);
  background: #eef1e8;
}

.hint {
  margin: 15px 0 0;
  font-size: 10px;
  line-height: 1.55;
  color: #6b746e;
}

.preview-panel {
  padding: 16px;
  min-width: 0;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding: 5px 5px 14px;
}

.preview-head strong {
  display: block;
  font-size: 14px;
}

.preview-head span:not(.status) {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: #778078;
}

.status {
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef3eb;
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
}

.canvas-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: #ddd;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

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

  .form-panel {
    position: static;
  }

  .preview-panel {
    order: -1;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 12px;
  }

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

  label.full {
    grid-column: auto;
  }

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

.form-section {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e6e2d7;
}

.form-section:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}

.form-section h3 {
  margin: 0 0 12px;
  font-family: "Cinzel", Georgia, serif;
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--green);
}

.permit-input {
  display: flex;
  align-items: stretch;
  border: 1px solid #d3d1c5;
  border-radius: 9px;
  overflow: hidden;
  background: #fafaf6;
}

.permit-input span {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: #eef1e8;
  color: var(--green);
  font: 700 12px "Roboto Condensed", Arial, sans-serif;
  white-space: nowrap;
}

.permit-input input {
  border: 0;
  border-radius: 0;
  min-width: 0;
  background: transparent;
}

.permit-input input:focus {
  box-shadow: none;
}

.success-message {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 10;
  width: min(390px, calc(100vw - 56px));
  padding: 22px;
  border: 1px solid #d7d3bf;
  border-radius: 16px;
  background: rgba(250, 252, 246, .98);
  box-shadow: 0 18px 50px rgba(0,0,0,.18);
  text-align: center;
}

.success-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 24px;
  font-weight: 700;
}

.success-message h2 {
  margin: 0;
  color: var(--green);
  font: 700 15px "Cinzel", Georgia, serif;
  letter-spacing: .05em;
}

.success-message p {
  margin: 9px 0;
  font-size: 11px;
  color: #66716a;
}

.success-message strong {
  color: #26342F;
  font: 500 18px "Roboto Condensed", Arial, sans-serif;
  letter-spacing: .12em;
}


/* Generate flow: the live preview stays visible at all times.
   Download actions are unlocked only after Generate Permit. */
.success-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.success-actions button {
  width: 100%;
}
button[hidden] {
  display: none !important;
}
