#root {
  width: 100%;
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

.content {
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 24px 20px 96px;
}

.auth-content {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.locked-card {
  width: min(460px, 100%);
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.locked-card h2 {
  margin: 0 0 8px;
}

.locked-card p {
  margin: 0 0 18px;
  color: var(--text-muted);
}

.content-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.content-tabs__btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 600;
}

.content-tabs__btn.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.wizard {
  padding: 20px 18px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.wizard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.wizard-step-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.form-field {
  display: grid;
  gap: 6px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin: 8px 0 6px;
}

.field-input,
.payload-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.field-input:focus,
.payload-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}

.payload-input {
  min-height: 120px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

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

.algorithm-grid {
  margin-top: 10px;
}

.algorithm-select {
  display: grid;
  gap: 8px;
}

.algorithm-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.algorithm-option:hover {
  background: var(--surface-soft);
}

.algorithm-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.algorithm-option span {
  display: grid;
  gap: 2px;
}

.algorithm-option small {
  color: var(--text-muted);
  font-size: 12px;
}

.algorithm-option:has(input:checked) {
  border-color: rgba(36, 125, 139, 0.35);
  background: var(--primary-light);
  box-shadow: inset 0 0 0 1px rgba(36, 125, 139, 0.12);
}

.muted-box {
  min-height: 120px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  background: var(--surface-soft);
  display: grid;
  align-content: start;
  gap: 8px;
}

.muted-box strong {
  color: var(--text);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(36, 125, 139, 0.25);
  background: rgba(36, 125, 139, 0.08);
  color: var(--primary);
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 10px;
}

.payload-mode {
  margin-top: 16px;
}

.payload-mode__label {
  margin-bottom: 8px;
}

.payload-mode__controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-chip {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  background: var(--surface);
  overflow: hidden;
}

.mode-chip span {
  display: block;
  padding: 6px 12px;
}

.mode-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-chip input:checked + span {
  background: var(--primary-light);
  color: var(--primary);
}

.mode-chip_disabled {
  background: var(--surface-disabled);
  cursor: not-allowed;
}

.mode-chip_disabled span {
  color: var(--text-muted);
}

.algorithm-fields {
  margin-top: 12px;
}

.payload-file-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.file-drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 104px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 14px 12px;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.file-drop-zone_small {
  min-height: 88px;
}

.file-drop-zone:hover,
.file-drop-zone--drag,
.file-drop-zone--filled {
  border-color: var(--primary);
  background: var(--surface-hover);
}

.file-drop-zone input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.file-drop-zone__text {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.file-drop-zone__name {
  display: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  word-break: break-all;
}

.file-drop-zone__clear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.file-drop-zone--filled .file-drop-zone__text {
  display: none;
}

.file-drop-zone--filled .file-drop-zone__name,
.file-drop-zone--filled .file-drop-zone__clear {
  display: inline-flex;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.matrix-file-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin: 4px 0 6px;
}

.preview-panel {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 12px;
}

.preview-panel__head {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.preview-panel__hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.preview-panel__hint_error {
  color: var(--danger);
}

.preview-map {
  position: relative;
  height: 250px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-hover);
}

.preview-map .leaflet-control-zoom a {
  color: var(--text);
}

.payload-note {
  margin: 12px 0 10px;
  padding: 9px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.actions-row {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

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

.btn-ghost:hover {
  background: var(--surface-soft);
}

.btn-compact {
  padding: 8px 12px;
  font-size: 13px;
}

.requests-grid {
  display: grid;
  gap: 12px;
}

.request-card {
  position: relative;
  padding: 14px 92px 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background-color 0.16s ease;
}

.request-card_clickable {
  cursor: pointer;
}

.request-card_clickable:hover {
  border-color: rgba(36, 125, 139, 0.42);
  background: var(--surface-soft);
  box-shadow: 0 10px 26px rgba(36, 125, 139, 0.12);
  transform: translateY(-1px);
}

.request-card_clickable:focus-visible {
  outline: 3px solid var(--primary-light-strong);
  outline-offset: 2px;
  border-color: var(--primary);
}

.request-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.request-card p {
  margin: 4px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.request-card b {
  color: var(--text);
}

.request-delete-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  font-weight: 700;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.request-delete-btn:hover,
.request-delete-btn:focus-visible {
  border-color: rgba(185, 28, 28, 0.35);
  background: #fee2e2;
  color: #b91c1c;
  outline: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 760px;
  max-height: min(760px, calc(100vh - 40px));
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

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

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

.modal-close-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.modal-close-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.modal__message {
  min-height: 0;
  overflow: auto;
  padding: 16px 18px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.modal__btn {
  min-width: 92px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 18px;
  cursor: pointer;
}

.modal__btn:hover {
  background: var(--surface-soft);
}

.request-details {
  display: grid;
  gap: 14px;
}

.request-details__rows {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.request-details__row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.request-details__row:last-child {
  border-bottom: 0;
}

.request-details__key,
.request-details__label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.request-details__value {
  color: var(--text);
  word-break: break-word;
}

.request-details__value_mono,
.request-details__json {
  font-family: Consolas, "Courier New", monospace;
}

.request-details__item {
  display: grid;
  gap: 6px;
}

.request-details__json {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.request-details__link {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px dashed rgba(36, 125, 139, 0.45);
}

.request-details__link:hover {
  color: var(--primary-hover);
}

.request-details__muted {
  color: var(--text-muted);
}

.status-badge {
  position: absolute;
  top: 12px;
  right: 48px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge_queued {
  background: var(--primary-light);
  color: #0369a1;
}

.status-badge_running {
  background: #d1fae5;
  color: #047857;
}

.status-badge_done {
  background: #dcfce7;
  color: #15803d;
}

.status-badge_failed {
  background: #fee2e2;
  color: #b91c1c;
}

.error {
  color: var(--danger) !important;
}

.empty-state {
  text-align: center;
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .content {
    padding: 18px 12px 72px;
  }

  .content-tabs {
    overflow-x: auto;
  }

  .content-tabs__btn {
    white-space: nowrap;
    padding: 10px 12px;
  }

  .wizard {
    padding: 15px 12px;
    border-radius: 14px;
  }

  .wizard-header,
  .actions-row {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-2,
  .file-grid {
    grid-template-columns: 1fr;
  }

  .preview-map {
    height: 210px;
  }

  .request-card {
    padding: 44px 12px 12px;
  }

  .modal {
    max-height: calc(100vh - 20px);
  }

  .request-details__row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
