/* ===== TOKENS (PSB Bank Style) ===== */
:root {
  --bg: #f2f4f7; /* Light corporate grey */
  --surface: #ffffff;
  --border: #d0d5dd;
  --text: #111827;
  --text-secondary: #4b5563;
  
  /* Primary PSB Blue */
  --primary: #004e9c;
  --primary-light: #e6f0fa;
  --primary-hover: #003d7a;
  
  /* Secondary PSB Orange (CTA) */
  --accent: #f05123;
  --accent-light: #feebe5;
  --accent-hover: #d24119;
  
  --error: #ef4444;
  --error-bg: #fef2f2;
  --error-border: #f87171;
  
  --radius: 8px; /* More strict, banking feel */
  --radius-sm: 6px;
  
  /* Banking UI shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.08);
  
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --transition: 0.2s ease-in-out;
}

/* ===== RESET ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ===== CONTAINER ===== */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

.container--narrow {
  max-width: 580px; /* Slightly narrower for form focus */
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.2;
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(240, 81, 35, 0.2);
}

.btn--ghost {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  border-color: var(--text);
  color: var(--text);
  background: #f9fafb;
}

.btn--full {
  width: 100%;
}

.btn--small {
  font-size: 14px;
  padding: 10px 20px;
}

/* ===== FORM SECTION ===== */
.form-section {
  padding: 40px 0 80px;
}

.form-intro {
  text-align: center;
  margin-bottom: 32px;
}

.form-intro__eyebrow {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.form-intro__title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 12px;
  color: var(--text);
}

.form-intro__desc {
  max-width: 520px;
  margin: 0 auto;
  font-size: 15px;
  color: var(--text-secondary);
}

/* Step indicator */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 40px;
  padding: 0 20px;
}

.step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  flex-shrink: 0;
  z-index: 1;
}

.step.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.step.done {
  border-color: var(--primary);
  background: #fff;
  color: var(--primary);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  max-width: 60px;
  transition: background var(--transition);
  margin: 0 8px;
}

.step-line.done {
  background: var(--primary);
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: cardIn 0.3s ease-out both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

/* ===== FORM ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row .form-group {
  margin-bottom: 0;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Inputs styling matching strict guidelines */
input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: var(--shadow-sm);
}

input:hover,
select:hover {
  border-color: #9ca3af;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

input.error-field,
select.error-field {
  border-color: var(--error);
  background-color: var(--error-bg);
}

input.error-field:focus,
select.error-field:focus {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

input::placeholder {
  color: #9ca3af;
}

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd' /%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
}

.amount-wrapper {
  position: relative;
}

.amount-wrapper input {
  padding-right: 36px;
  font-weight: 600;
  font-size: 16px;
}

.amount-currency {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 15px;
}

.amount-tip {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Error box */
.error-box {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-left: 4px solid var(--error);
  border-radius: var(--radius-sm);
  color: #b91c1c;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: pre-line;
}

/* ===== PREVIEW ===== */
.preview-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--surface);
}

.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.preview-row:last-child {
  border-bottom: none;
}

.preview-row:nth-child(even) {
  background: #f9fafb;
}

.preview-key {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 40%;
}

.preview-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  width: 60%;
  text-align: right;
  word-break: break-word;
}

.preview-val--amount {
  font-size: 18px;
  color: var(--text);
}

.preview-payment-desc {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preview-payment-desc label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.payment-desc-text {
  font-size: 13px;
  color: var(--primary-hover);
  line-height: 1.5;
  font-family: monospace;
}

.btn-group {
  display: flex;
  gap: 12px;
}

.btn-group .btn {
  flex: 1;
}

/* ===== RESULT ===== */
.result-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 28px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.result-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.result-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.result-btn--qr {
  border: 1px solid var(--primary);
  background: var(--primary-light);
}

.result-btn--qr:hover {
  background: #dbeafe;
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.result-btn--save:hover:not(:disabled) {
  border-color: #9ca3af;
  background: #f9fafb;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.result-btn__icon {
  font-size: 24px;
  flex-shrink: 0;
}

.result-btn strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.result-btn small {
  font-size: 13px;
  color: var(--text-secondary);
}

/* QR area */
.qr-area {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  padding: 32px 24px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  border: 1px solid #bfdbfe;
  margin-bottom: 24px;
  animation: cardIn 0.3s both;
}

.qr-code-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.qr-code-wrapper canvas {
  display: block;
  margin: 0 auto;
}

.qr-tip {
  font-size: 13px;
  line-height: 1.5;
  color: var(--primary-hover);
  text-align: center;
  max-width: 400px;
}

.new-payment-btn {
  width: 100%;
}

/* ===== FOOTER ===== */
.site-footer {
  padding: 32px 0 48px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== HIDDEN ===== */
.hidden {
  display: none !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .card {
    padding: 24px 20px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-row .form-group {
    margin-bottom: 20px;
  }

  .preview-row {
    flex-direction: column;
    gap: 4px;
  }
  
  .preview-key, .preview-val {
    width: 100%;
    text-align: left;
  }

  .btn-group {
    flex-direction: column-reverse;
  }

  .form-section {
    padding-top: 24px;
  }

  .form-intro {
    margin-bottom: 24px;
  }

  .qr-area {
    padding: 20px 12px;
  }

  .qr-code-wrapper {
    padding: 10px;
  }
}

/* ===== BUTTON PRINT ===== */
.result-btn--print {
  border-color: var(--border);
}

.result-btn--print:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* ===== PRINT LAYOUT ===== */
.print-only {
  display: none;
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
  
  /* Скрыть всё кроме печати */
  .form-section, .site-footer, .error-box {
    display: none !important;
  }
  
  .print-only {
    display: block !important;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  @page {
    size: A4 portrait;
    margin: 15mm;
  }

  .print-header {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
  }

  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
  }

  .print-table td {
    padding: 8px 4px;
    border-bottom: 1px solid #ccc;
    font-size: 14px;
    vertical-align: top;
  }

  .print-label {
    width: 35%;
    font-weight: 600;
  }

  .print-value {
    width: 65%;
  }

  .print-total-label {
    font-size: 16px;
    font-weight: bold;
  }

  .print-total {
    font-size: 16px;
    font-weight: bold;
  }

  .print-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 50px;
    padding-top: 40px;
    border-top: 2px dashed #ccc;
  }

  .print-qr-box {
    text-align: center;
    color: #111;
  }
  
  .print-qr-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 16px;
    text-transform: uppercase;
  }

  .print-qr-box img {
    width: 250px;
    height: 250px;
    display: block;
    margin: 0 auto 16px auto;
    border: 2px solid #000;
    padding: 8px;
  }
  
  .print-qr-subtitle {
    font-size: 14px;
    color: #555;
  }
}
