:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3ff;
  --ink: #162033;
  --muted: #5f6b85;
  --line: #d9e1f0;
  --primary: #0f4bd8;
  --primary-strong: #0b3aa7;
  --success: #16794f;
  --success-bg: #eaf8f0;
  --error: #b42318;
  --error-bg: #fef3f2;
  --shadow: 0 20px 40px rgba(15, 39, 84, 0.06);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(15, 75, 216, 0.08), transparent 32%),
    linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Inter", sans-serif;
  overflow-x: hidden;
}

body {
  overflow-y: auto;
}

h1,
h2,
h3,
strong,
.button,
.simple-eyebrow,
.status {
  font-family: "Manrope", sans-serif;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.page-shell {
  width: 100%;
  max-width: 1440px;
  min-width: 0;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.simple-page,
.result-block,
.card,
.message,
.field-row,
.field,
.table-wrap,
.steps-table-wrap,
.total-grid,
.total-row {
  min-width: 0;
}

.simple-page {
  display: grid;
  gap: 28px;
  max-width: 1180px;
  margin: 0 auto;
}

.simple-header-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.version-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.simple-header h1 {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1.04;
  letter-spacing: -0.05em;
}

.simple-eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card,
.message {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  padding: 24px;
}

/* Внешняя карточка-секция для таблиц — больше воздуха */
.card-table {
  padding: 28px 32px 32px;
}

/* Внутренний контейнер таблицы — собственная рамка и скругление */
.table-frame {
  margin-top: 20px;
  border: 1px solid #dce4f0;
  border-radius: 14px;
  overflow: hidden;
}

.message {
  padding: 18px 20px;
}

.message h2,
.message h3,
.card h3 {
  margin: 0 0 10px;
}

.message p,
.card p,
.card li {
  line-height: 1.7;
}

.message-info {
  background: var(--surface-soft);
  border-color: #cbd9ff;
}

.message-success {
  background: var(--success-bg);
  border-color: #a6e1be;
}

.message-error {
  background: var(--error-bg);
  border-color: #fecdca;
}

.provider-health {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.provider-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.provider-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #b0b7c7;
  flex: 0 0 auto;
}

.provider-chip-enabled .provider-dot {
  background: var(--success);
}

.provider-chip-disabled .provider-dot {
  background: var(--error);
}

.provider-name {
  font-weight: 700;
}

.provider-state {
  color: var(--muted);
}

.simple-form {
  display: grid;
  gap: 18px;
}

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

.field-row-tight {
  align-items: stretch;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  font-weight: 700;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

input[type="text"] {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 180px;
  padding: 14px;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
  outline: 2px solid rgba(15, 75, 216, 0.15);
  border-color: rgba(15, 75, 216, 0.45);
}

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

.test-models-toggle {
  margin-top: 8px;
}

.test-models-toggle > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  list-style: none;
}

.test-models-toggle > summary::before {
  content: "▶";
  font-size: 0.65rem;
  transition: transform 0.15s;
}

.test-models-toggle[open] > summary::before {
  transform: rotate(90deg);
}

.segmented-control-test {
  margin-top: 8px;
}

.segmented-option {
  position: relative;
  display: block;
}

.segmented-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented-option > input + span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.segmented-option > input + span small {
  color: var(--muted);
  font-size: 0.86em;
  font-weight: 600;
}

.segmented-option input:checked + span {
  border-color: rgba(15, 75, 216, 0.45);
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.toggle-card-copy {
  display: grid;
  gap: 4px;
}

.toggle-card-copy small {
  color: var(--muted);
  line-height: 1.5;
}

.switch {
  position: relative;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.switch-track {
  display: block;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #d6def0;
  position: relative;
  cursor: pointer;
  pointer-events: none;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(22px);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
  margin-left: 6px;
}

.file-drop {
  display: block;
  padding: 14px 18px;
  border: 1px dashed #b9c5d6;
  border-radius: 12px;
  background: #fbfcff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.file-drop:hover {
  border-color: var(--primary);
  background: #f4f7ff;
}

.file-drop-prompt {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-drop-hint {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.file-item::before {
  content: "📄";
  font-size: 0.85rem;
  flex-shrink: 0;
}

.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-remove-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.file-remove-btn:hover {
  color: var(--error, #c0392b);
  background: rgba(192,57,43,0.08);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.button-secondary {
  color: var(--ink);
  background: #edf1f8;
}

.button-ghost {
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--line);
}

.button-ghost:hover {
  background: #edf1f8;
}

.button-sm {
  min-height: 34px;
  padding: 0 14px;
  font-size: 0.85rem;
  font-weight: 700;
}

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

.result-block {
  display: grid;
  gap: 24px;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.result-head h2 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.04em;
  overflow-wrap: break-word;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #eaf2ff;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-done {
  background: var(--success-bg);
  color: var(--success);
}

.steps-table-wrap,
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

.data-table th,
.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid #eaeff8;
  text-align: left;
  vertical-align: top;
  word-break: normal;
  overflow-wrap: normal;
}

.data-table thead th {
  background: #f4f6fb;
  padding: 13px 20px;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: normal;
  hyphens: none;
  line-height: 1.45;
  border-bottom: 1px solid #dce4f0;
}


.data-table tbody tr:not(.summary-row):hover td {
  background: #f5f8ff;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.summary-row td {
  font-weight: 800;
  background: #f7f9fe;
}

.step-row td {
  background: #fafcff;
}

.step-name {
  padding-left: 20px !important;
  color: #30415f;
}

.note-ocr-row td {
  color: #c0392b;
  font-style: italic;
  background: #fff8f8;
}

.ocr-disclaimer {
  margin-top: 4px;
  padding: 12px 20px;
  border-radius: 10px;
  background: #fff0f0;
  border: 1px solid #f5c0c0;
  color: #b02020;
  font-size: 0.88rem;
  font-weight: 600;
}

.export-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 16px 20px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 10px;
}

.export-customer-input {
  flex: 1;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 0.92rem;
  background: #fff;
  color: #212529;
}

.export-customer-input:focus {
  outline: none;
  border-color: #86b7fe;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.plain-list {
  margin: 0;
  padding-left: 18px;
}

.cell-nowrap,
.col-id,
.col-complexity,
.col-hours,
.col-count,
.col-term,
.col-money,
.col-days {
  white-space: nowrap;
}

.col-id {
  min-width: 36px;
  width: 40px;
}

.col-name {
  min-width: 200px;
}

.col-text {
  min-width: 200px;
}

.col-complexity {
  min-width: 100px;
}

.col-hours {
  min-width: 100px;
}

.col-count {
  min-width: 56px;
  width: 56px;
}

.col-term {
  min-width: 90px;
}

.col-money {
  min-width: 140px;
}

.col-days {
  min-width: 90px;
}

.total-card {
  border-color: #cdd8f7;
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
}

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

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

.total-row:last-child {
  border-bottom: 0;
}

.total-row-grand strong {
  color: var(--primary-strong);
  font-size: 1.05rem;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .field-row,
  .field-row-tight,
  .segmented-control {
    grid-template-columns: 1fr;
  }

  .toggle-card {
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 20px 14px 32px;
  }

  .simple-header h1 {
    font-size: 1.9rem;
  }

  .provider-health,
  .form-actions,
  .result-head,
  .total-row {
    flex-direction: column;
    align-items: stretch;
  }

  .button {
    width: 100%;
  }
}

/* --- Progress stepper --- */
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-title {
  font-weight: 700;
  font-family: "Manrope", sans-serif;
}

.progress-timer {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-steps {
  display: flex;
  gap: 6px;
  flex-direction: column;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.progress-step-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #d6def0;
  transition: background 0.2s;
}

.step-done .progress-step-dot {
  background: var(--success);
}

.step-done .progress-step-label {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: #a0aec0;
}

.step-active .progress-step-dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 75, 216, 0.18);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.step-active .progress-step-label {
  font-weight: 700;
  color: var(--primary-strong);
}

.step-pending .progress-step-label {
  color: var(--muted);
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(15, 75, 216, 0.18); }
  50%       { box-shadow: 0 0 0 6px rgba(15, 75, 216, 0.08); }
}

/* --- LLM reasoning UI --- */
.llm-analysis-card {
  border-left: 3px solid var(--primary);
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: "Manrope", sans-serif;
  letter-spacing: 0.01em;
}

.confidence-low {
  background: #fde8e8;
  color: #c0392b;
}

.confidence-medium {
  background: #fef3d0;
  color: #a05800;
}

.confidence-high {
  background: #e0f5ea;
  color: #1a7a45;
}

.llm-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-bottom: 8px;
}

.llm-meta-item {
  font-size: 0.875rem;
  color: var(--muted);
}

.llm-meta-item strong,
.llm-meta-item span {
  color: var(--ink);
  font-weight: 600;
}

.llm-risk-summary {
  font-size: 0.9rem;
  color: var(--ink);
  margin: 0 0 8px;
}

.llm-prompt-hash {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
}

.llm-prompt-hash code {
  font-family: monospace;
  background: var(--surface-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

.step-reasoning {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 3px;
  font-style: italic;
}

.step-risks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.risk-tag {
  font-size: 0.7rem;
  background: #fff3e0;
  color: #a05000;
  border: 1px solid #ffd59e;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
}

.risk-mult {
  color: #a05000;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Process tabs */
.detection-note { margin-bottom: 16px; }
.tabs-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs-btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.process-tab-btn {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink);
  transition: background 0.15s, color 0.15s;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.process-tab-btn:hover { background: var(--surface-soft); }
.process-tab-btn.tab-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab-arrow {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  color: var(--ink);
  flex-shrink: 0;
}
.tab-arrow:disabled { opacity: 0.3; cursor: default; }
[data-tab-panel] {
  display: grid;
  gap: 24px;
}
[data-tab-panel][hidden] { display: none; }

/* --- Model option layout --- */
.segmented-option > input + span.model-option-content {
  justify-content: space-between;
  width: 100%;
}

.model-label {
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Model badges --- */
.model-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.model-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #98a2b3;
  border-radius: 6px;
  background: transparent;
  color: #475467;
  box-sizing: border-box;
  cursor: default;
  flex: 0 0 24px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.model-badge:hover {
  background: #f5f7fa;
  color: #344054;
  border-color: #667085;
}

.model-badge-no-ocr {
  width: 36px;
  flex: 0 0 36px;
}

.model-badge-icon {
  width: 17px;
  height: 17px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.model-badge-no-ocr .model-badge-icon {
  width: 34px;
  height: 22px;
}

.model-badge-fast .model-badge-icon path,
.model-badge-warning .model-badge-icon rect,
.model-badge-warning .model-badge-icon circle {
  fill: currentColor;
  stroke: none;
}

.model-badge-no-ocr .model-badge-icon text {
  fill: currentColor;
  stroke: none;
}

.model-badge-no-ocr .model-badge-icon .slash {
  stroke-width: 1.2;
}

.model-badge[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2340;
  color: #fff;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.5;
  text-align: center;
  font-family: "Inter", sans-serif;
}

.model-badge[data-tooltip]:hover::before {
  opacity: 1;
}

