* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(32, 91, 160, 0.15), transparent 28%),
    linear-gradient(180deg, #eef3f8, #f5f7fa 44%, #edf2f7);
  color: #18212b;
}

.app {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 22px 24px;
  background: linear-gradient(135deg, #18344d, #274e70 58%, #3d7ca6);
  border-radius: 20px;
  color: #fff;
  box-shadow: 0 18px 45px rgba(24, 52, 77, 0.22);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.76);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.02;
}

.hero-copy {
  margin: 0;
  max-width: 760px;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.5;
}

.hero-note {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.note-pill {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  border: 1px solid #dbe4ec;
  box-shadow: 0 14px 36px rgba(24, 33, 43, 0.08);
}

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

.panel h2 {
  margin: 0;
  font-size: 18px;
}

.hint {
  margin: 0;
  color: #617487;
  font-size: 13px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-group label,
.group-label {
  font-size: 13px;
  font-weight: 600;
  color: #28445c;
}

.field-group input[type="text"],
.field-group input[type="date"],
.field-group input[type="number"],
.field-group select,
.field-group textarea {
  border: 1px solid #c9d7e3;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #18212b;
  background: #f9fbfd;
}

.field-group textarea {
  resize: vertical;
  min-height: 54px;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: 2px solid #3d7ca6;
  outline-offset: 1px;
}

.field-note {
  font-size: 12px;
  color: #7a8b9c;
}

.payee-field {
  position: relative;
}

.payee-row {
  display: flex;
  gap: 6px;
}

.payee-row input {
  flex: 1;
  min-width: 0;
}

.icon-btn {
  border: 1px solid #c9d7e3;
  background: #f5f8fb;
  color: #28445c;
  border-radius: 10px;
  width: 40px;
  min-height: 40px;
  cursor: pointer;
  font-size: 15px;
  flex: 0 0 auto;
}

.icon-btn:hover {
  background: #eaf0f6;
}

.payee-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid #c9d7e3;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(17, 42, 67, 0.16);
  max-height: 220px;
  overflow-y: auto;
  z-index: 30;
}

.payee-empty {
  padding: 12px;
  font-size: 13px;
  color: #7a8b9c;
  text-align: center;
}

.payee-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-bottom: 1px solid #eef2f6;
}

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

.payee-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: none;
  text-align: left;
  padding: 8px 6px;
  font-size: 14px;
  color: #18212b;
  cursor: pointer;
  border-radius: 6px;
}

.payee-item-name:hover {
  background: #f0f5fa;
}

.payee-item-action {
  border: none;
  background: none;
  color: #7a8b9c;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  flex: 0 0 auto;
}

.payee-item-action:hover {
  background: #eef2f6;
  color: #28445c;
}

.linklike {
  align-self: flex-start;
  border: none;
  background: none;
  color: #1a5fa8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
}

.radio-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #c9d7e3;
  background: #f5f8fb;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.radio-pill input {
  margin: 0;
}

.advanced {
  border: 1px solid #dbe4ec;
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 4px;
}

.advanced summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: #28445c;
}

.advanced .field-group {
  margin-top: 14px;
}

.offset-row {
  display: flex;
  gap: 12px;
}

.offset-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #28445c;
}

.offset-row input {
  width: 70px;
  border: 1px solid #c9d7e3;
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
}

.calibration-hint {
  background: #f5f8fb;
  border: 1px solid #dbe4ec;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: #40576d;
}

button.secondary {
  border: 1px solid #c9d7e3;
  background: #f5f8fb;
  color: #28445c;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

button.secondary:hover {
  background: #eaf0f6;
}

.selection-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: #eef4fa;
  border: 1px solid #c9d7e3;
  border-radius: 10px;
  font-size: 13px;
  color: #28445c;
}

.selection-toolbar span {
  font-weight: 600;
  margin-right: auto;
}

.selection-toolbar button {
  border: 1px solid #1f405e;
  background: linear-gradient(180deg, #234a6f, #1a3a57);
  color: #fff;
  border-radius: 8px;
  min-width: 34px;
  height: 30px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.selection-toolbar button.active {
  background: linear-gradient(180deg, #00a779, #007d5b);
  border-color: #007d5b;
}

.cheque-stage {
  overflow: hidden;
  padding: 6px 0 14px;
}

.cheque-canvas {
  position: relative;
  transform-origin: top left;
  background: #fff;
  box-shadow: 0 10px 30px rgba(24, 33, 43, 0.16);
  border-radius: 4px;
}

.cheque-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 4px;
  pointer-events: none;
  user-select: none;
}

.field {
  position: absolute;
  cursor: grab;
  touch-action: none;
  white-space: nowrap;
  font-family: "Courier New", Consolas, monospace;
  color: #0e2338;
  line-height: 1;
  user-select: none;
}

.field:active {
  cursor: grabbing;
}

.field.selected {
  outline: 1.5px dashed #00a779;
  outline-offset: 3px;
}

.field-wrap {
  white-space: normal;
}

.date-boxes {
  display: flex;
}

.date-boxes span {
  display: inline-block;
  text-align: center;
}

.resize-handle {
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 16px;
  background: #00a779;
  border: 1.5px solid #fff;
  border-radius: 3px;
  cursor: ew-resize;
  touch-action: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.resize-handle-v {
  right: auto;
  left: 50%;
  top: auto;
  bottom: -7px;
  transform: translateX(-50%);
  width: 16px;
  height: 9px;
  cursor: ns-resize;
}

.field-crossing svg {
  display: block;
  width: 100%;
  height: 100%;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
  flex-wrap: wrap;
}

#printButton {
  border: 1px solid #1f405e;
  background: linear-gradient(180deg, #234a6f, #1a3a57);
  color: #fff;
  border-radius: 10px;
  padding: 11px 20px;
  min-height: 44px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

#printButton:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(26, 58, 87, 0.2);
}

.secondary-action {
  border: 1px solid #c9d7e3;
  background: #f5f8fb;
  color: #28445c;
  border-radius: 10px;
  padding: 11px 18px;
  min-height: 44px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.secondary-action:hover {
  background: #eaf0f6;
}

#saveStatus {
  color: #007d5b;
  font-weight: 600;
}

.font-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.font-row label {
  font-size: 13px;
  font-weight: 600;
  color: #28445c;
}

.font-row select {
  flex: 1;
  max-width: 320px;
  border: 1px solid #c9d7e3;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  background: #f9fbfd;
}

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

  .hero {
    flex-direction: column;
    padding: 20px;
  }

  .hero-note {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 14px;
  }

  .hero {
    margin-bottom: 14px;
    padding: 18px 16px;
    border-radius: 16px;
  }

  .hero h1 {
    font-size: 30px;
  }

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

@media print {
  body {
    background: #fff;
  }

  .hero,
  .panel-input,
  .panel-preview .panel-head,
  .selection-toolbar,
  .preview-actions,
  .resize-handle,
  .font-row,
  .save-hint {
    display: none !important;
  }

  .app {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .workspace {
    display: block;
  }

  .panel-preview {
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
  }

  .cheque-stage {
    overflow: visible !important;
    height: auto !important;
    padding: 0;
  }

  .cheque-canvas {
    transform: none !important;
    box-shadow: none;
    margin: 0;
  }

  .cheque-image {
    display: none;
  }

  .field.selected {
    outline: none;
  }
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input[type="checkbox"] {
  width: auto;
}

@media print {
  .test-print .field {
    visibility: hidden !important;
  }

  .test-print .cheque-canvas {
    outline: 0.3mm solid #000;
    background-image:
      linear-gradient(#000, #000), linear-gradient(#000, #000);
    background-size: 100% 0.2mm, 0.2mm 100%;
    background-position: 0 50%, 50% 0;
    background-repeat: no-repeat;
  }
}

.settings-card {
  border: 1px solid #d5deea;
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
  display: grid;
  gap: 8px;
}

.settings-card h3 {
  margin: 0;
  font-size: 1rem;
}

.bank-tag {
  font-weight: 400;
  font-size: 0.8rem;
  color: #6b7a90;
  margin-left: 6px;
}

.settings-card select {
  width: 100%;
}

.settings-card label {
  font-size: 13px;
  font-weight: 600;
  color: #28445c;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-card h3 {
  font-size: 15px;
  color: #18212b;
}

.settings-card select,
.settings-card input[type="text"],
.settings-card input[type="number"] {
  border: 1px solid #c9d7e3;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: #18212b;
  background: #f9fbfd;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.settings-card .offset-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-card [hidden] {
  display: none !important;
}
