@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --color-primary-red: #e53935;
  --color-primary-red-hover: #d32f2f;
  --color-bg: #ffffff;
  --color-surface: #f7f7f8;
  --color-surface-hover: #efeff1;
  --color-bg-muted: #f1f2f4;
  --color-border: #e4e4e7;
  --color-border-strong: #d4d4d8;
  --color-text-primary: #18181b;
  --color-text-secondary: #52525b;
  --color-text-muted: #a1a1aa;
  --color-danger: #ef4444;
  --color-danger-light: #fee2e2;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-info-light: #dbeafe;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-button: 8px;
  --radius-card: 14px;
  --shadow-md: 0 4px 10px rgba(24, 24, 27, 0.07);
  --shadow-lg: 0 10px 28px rgba(24, 24, 27, 0.12);
  --gutter: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-muted);
  -webkit-text-size-adjust: 100%;
}

body.payroll-tooltip-modal-open {
  overflow: hidden;
}

body.payroll-tooltip-modal-open .candidate-card,
body.payroll-tooltip-modal-open .app-meta {
  pointer-events: none;
}

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

.candidate-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px 28px;
}

.candidate-shell__center {
  flex: 0 1 auto;
  width: 100%;
  max-width: 720px;
  min-width: 0;
}

.app-meta {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 12px 0 0;
  padding: 4px 8px;
  text-align: center;
  pointer-events: none;
}

.app-meta__text {
  display: inline-block;
  font-size: 11px;
  line-height: 1.3;
  color: var(--color-text-muted);
  font-weight: 400;
}

.zone-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.candidate-card {
  padding: 24px 16px 20px;
  gap: 16px;
}

.candidate-card__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.candidate-card__logo {
  display: block;
  max-width: 120px;
  height: auto;
}

.candidate-card__brand {
  text-align: center;
  margin-bottom: 4px;
}

.candidate-card__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.candidate-card__subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.candidate-card__meta {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--color-info-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--color-text-secondary);
  text-align: left;
}

.candidate-card__hint {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
}

.status-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.app-status:not([hidden]) {
  display: block;
}

.status-card--check-error,
.status-card--invalid-link-no-id,
.status-card--invalid-link-rejected,
.status-card--config-error,
.status-card--submit-error-generic,
.status-card--submit-error-rejected {
  background: var(--color-danger-light);
  border-color: #fecaca;
  color: #991b1b;
}

.status-card--success {
  background: var(--color-success-light);
  border-color: #bbf7d0;
  color: #166534;
}

.status-card--service-unavailable,
.status-card--maintenance {
  background: var(--color-info-light);
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.status-card--loading,
.status-card--already-submitted {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.status-card.is-visible {
  display: flex;
}

.status-card__title {
  font-size: 15px;
  font-weight: 700;
}

.status-card__text {
  font-size: 13px;
  color: inherit;
  white-space: pre-line;
}

.draft-banner:not([hidden]) {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-info-light);
  color: #1e3a8a;
  font-size: 12px;
}

.phones-warning:not([hidden]) {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-danger-light);
  color: #991b1b;
  font-size: 12px;
}

.demo-badge:not([hidden]) {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--color-text-muted);
}

.form-error {
  display: none;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-danger-light);
  color: #991b1b;
  font-size: 13px;
}

.form-error.is-visible {
  display: block;
}

.candidate-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  width: 100%;
}

.candidate-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  min-width: 0;
}

.candidate-section[hidden],
.form-field[hidden],
.form-field.is-hidden {
  display: none !important;
}

.candidate-section__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.candidate-section__subtitle {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  max-width: 100%;
}

.employment-blocks {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  width: 100%;
}

.employment-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.form-field--span-2 {
  grid-column: auto;
}

.form-field input:not([type='checkbox']):not([type='radio']),
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-button);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-weight: 400;
  outline: none;
}

.form-field textarea {
  min-height: 88px;
  resize: vertical;
}

.form-field input:focus:not([type='checkbox']):not([type='radio']),
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--color-primary-red);
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.15);
}

.form-field input:disabled:not([type='checkbox']):not([type='radio']),
.form-field input[readonly]:not([type='checkbox']):not([type='radio']),
.form-field select:disabled,
.form-field textarea:disabled {
  background: #eef0f2;
  color: var(--color-text-secondary);
  cursor: not-allowed;
}

.form-field.is-invalid input:not([type='checkbox']):not([type='radio']),
.form-field.is-invalid select,
.form-field.is-invalid textarea {
  border-color: var(--color-danger);
}

.form-field--phone-ok input:not([type='checkbox']):not([type='radio']) {
  border-color: var(--color-success);
  background: var(--color-success-light);
}

.form-field--phone-ok.is-invalid input:not([type='checkbox']):not([type='radio']) {
  border-color: var(--color-danger);
  background: var(--color-bg);
}

.date-field {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.date-field__text {
  flex: 1 1 auto;
  min-width: 0;
}

/* Path B: hit открытия = кнопка; native — sibling (не оверлей-hit Path A). */
.date-field__picker-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
}

.date-field__picker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-button);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
}

.date-field__picker:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.date-field__icon {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}

/* Sibling под кнопкой: размер для showPicker/fallback; pointer-events none — hit у кнопки. */
.date-field__native {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  pointer-events: none;
  z-index: 0;
}

.date-field__native:disabled {
  cursor: not-allowed;
}

.form-field--date {
  position: relative;
}

.form-field.is-invalid .date-field__text,
.form-field.is-invalid .date-field__picker {
  border-color: var(--color-danger);
}

.form-field__helper {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.form-field__error {
  display: none;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-danger);
}

/* Текст ошибки виден и без красной рамки (доп. номер §8.3.3). */
.form-field.is-invalid .form-field__error,
.form-field__error:not(:empty) {
  display: block;
}

.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-button);
  background: var(--color-bg);
  font-weight: 400;
  color: var(--color-text-primary);
  cursor: pointer;
}

.choice-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary-red);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-weight: 400;
  color: var(--color-text-primary);
  cursor: pointer;
}

.checkbox-row input[type='checkbox'] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  accent-color: var(--color-primary-red);
  flex-shrink: 0;
}

.checkbox-row span {
  line-height: 1.35;
  font-weight: 400;
}

.checkbox-row--split {
  cursor: default;
  flex-wrap: wrap;
}

.checkbox-row__text-group {
  display: inline;
  line-height: 1.35;
  font-weight: 400;
}

.checkbox-row--split .tooltip-word {
  flex-shrink: 0;
}

.checkbox-row__text {
  line-height: 1.35;
  font-weight: 400;
  cursor: pointer;
}

.consent-link {
  color: var(--color-primary-red);
  text-decoration: underline;
  font-weight: 600;
}

.consent-link.is-disabled {
  pointer-events: none;
  opacity: 0.55;
  cursor: default;
}

.tooltip-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--color-border-strong);
  color: var(--color-text-secondary);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}

.form-actions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 4px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 28%);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-button);
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
}

.button--primary {
  width: 100%;
  background: var(--color-primary-red);
  color: #fff;
}

.button--primary:hover:not(:disabled) {
  background: var(--color-primary-red-hover);
}

.button--primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.button--secondary {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}

/* «Добавить предыдущее место» — нейтральный secondary (не красная CTA). */

[hidden] {
  display: none !important;
}

.consent-panel {
  display: none;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary);
}

.consent-panel.is-visible {
  display: block;
}

.form-field__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-button);
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-weight: 400;
  outline: none;
}

.input:focus {
  border-color: var(--color-primary-red);
  box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.15);
}

.input--textarea {
  min-height: 88px;
  resize: vertical;
}

.input--readonly {
  background: #eef0f2;
  color: var(--color-text-secondary);
}

.primary-phones {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.employment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button--small {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.form-grid--checkboxes {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid--checkboxes .form-field {
  gap: 0;
}

.tooltip-word {
  display: inline;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: underline dotted;
  cursor: pointer;
}

.tooltip-word:disabled {
  opacity: 0.55;
  cursor: default;
  text-decoration: none;
}

.payroll-tooltip-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.payroll-tooltip-modal[hidden] {
  display: none;
}

.payroll-tooltip-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 27, 0.55);
}

.payroll-tooltip-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  max-height: min(80vh, 480px);
  background: var(--color-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  outline: none;
}

.payroll-tooltip-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.payroll-tooltip-modal__title {
  font-size: 16px;
  font-weight: 700;
}

.payroll-tooltip-modal__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-button);
  background: var(--color-surface);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.payroll-tooltip-modal__body {
  padding: 16px;
  overflow: auto;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-primary);
  line-height: 1.45;
}

.payroll-tooltip-modal__footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--color-border);
}

.consent-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.consent-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 27, 0.55);
}

.consent-modal__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  background: var(--color-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.consent-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.consent-modal__title {
  font-size: 16px;
  font-weight: 700;
}

.consent-modal__close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-button);
  background: var(--color-surface);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.consent-modal__body {
  padding: 16px;
  overflow: auto;
  font-size: 13px;
  font-weight: 400;
  color: var(--color-text-primary);
}

.consent-modal__body p {
  margin-bottom: 12px;
}

.consent-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 11px;
}

.consent-table th,
.consent-table td {
  border: 1px solid var(--color-border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

.consent-table th {
  background: var(--color-surface);
}

.consent-list {
  margin: 0 0 12px 18px;
}

.consent-modal__footer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--color-border);
}

body.consent-modal-open {
  overflow: hidden;
}

.maintenance-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(24, 24, 27, 0.55);
}

.maintenance-overlay__box {
  max-width: 480px;
  padding: 20px;
  border-radius: var(--radius-card);
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  text-align: center;
}

@media (min-width: 640px) {
  .candidate-shell {
    padding: 28px 20px 40px;
  }

  .candidate-card {
    padding: 32px 28px 24px;
  }

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

  .form-field--span-2 {
    grid-column: span 2;
  }

  .candidate-section {
    padding: 16px;
  }
}
