:root {
  --brand: #b92b35;
  --accent: #e53946;
  --danger: #c92d39;
  --ink: #152033;
  --muted: #6c7688;
  --line: #d8e0eb;
  --line-soft: #e8edf4;
  --sidebar: #e9eef5;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --header: #101b2a;
  --success: #18864b;
  --warning: #b76a00;
  --shadow: 0 10px 30px rgba(21, 32, 51, 0.08);
  --font-body: 14px;
  --font-page-title: 28px;
  --font-section-title: 18px;
  --font-card-title: 15px;
  --font-label: 13px;
  --font-small: 12px;
  --dropdown-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%236c7688' d='M1 1.25 6 6.5l5-5.25z'/%3E%3C/svg%3E");
  --dropdown-arrow-width: 12px;
  --dropdown-arrow-height: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: var(--font-body);
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-inline-start: 6px;
  background-color: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 6 12 12M18 6 6 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 6 12 12M18 6 6 18' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  cursor: pointer;
}

input[type="search"]::-webkit-search-cancel-button:hover {
  background-color: var(--ink);
}

.hidden {
  display: none !important;
}

body.auth-pending {
  background: var(--bg);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex: 0 0 248px;
  width: 248px;
  height: 100vh;
  flex-direction: column;
  gap: 0;
  padding: 14px 12px 22px;
  background: var(--sidebar);
  border-right: 1px solid var(--line-soft);
  transition: width 0.18s ease, flex-basis 0.18s ease;
}

.brand-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 28px;
}

.sidebar-toggle {
  display: inline-flex;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.brand-title {
  color: var(--brand);
  font-size: var(--font-card-title);
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-subtitle {
  color: var(--muted);
  font-size: var(--font-small);
  white-space: nowrap;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 18px;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.65);
}

.nav-item.active {
  position: relative;
  background: #fff;
  color: var(--brand);
}

.nav-item.active::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  border-radius: 6px 0 0 6px;
  background: var(--accent);
  content: "";
}

.nav-icon {
  display: inline-flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
  color: currentColor;
}

.nav-icon svg {
  width: 24px;
  height: 24px;
}

.nav-text {
  overflow: hidden;
  font-size: var(--font-body);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell.sidebar-collapsed .sidebar {
  flex-basis: 64px;
  width: 64px;
  padding-inline: 10px;
}

.app-shell.sidebar-collapsed .brand-row {
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand-row > div,
.app-shell.sidebar-collapsed .nav-text {
  display: none;
}

.app-shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0;
}

.main-content {
  width: 100%;
  min-width: 0;
  padding: 28px 24px 48px;
}

.page-header {
  display: flex;
  min-height: auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 22px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  max-width: none;
}

.page-crumb {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: var(--font-label);
}

.page-header h1 {
  margin: 0;
  font-size: var(--font-page-title);
  line-height: 1.2;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.page-header-tools {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-left: auto;
}

.page-user {
  display: flex;
  min-width: 0;
  max-width: 360px;
  align-items: center;
  gap: 9px;
  padding: 2px 0;
}

.page-user-stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.page-user-stack .workspace-only {
  justify-content: flex-end;
}

.page-user-avatar {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f15861;
  color: #fff;
}

.page-user-avatar svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-user-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-user button {
  display: inline-flex;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  padding: 0 0 0 7px;
  border: 0;
  border-left: 1px solid var(--line-soft);
  background: transparent;
  color: var(--muted);
}

.page-user button:hover {
  color: var(--brand);
}

.page-user button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-section {
  display: none;
  max-width: none;
  margin: 0;
}

.app-section.active {
  display: block;
}

.surface {
  margin-bottom: 24px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.surface h2 {
  margin: 0 0 8px;
  font-size: var(--font-section-title);
  line-height: 1.2;
}

.surface h3 {
  margin: 0;
  font-size: var(--font-card-title);
}

.muted {
  color: var(--muted);
}

.section-title-row,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-title-row.small {
  align-items: center;
  margin: 18px 0 12px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field,
.check-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: var(--font-label);
}

.field.full {
  grid-column: 1 / -1;
}

.field.compact-field {
  max-width: 140px;
}

.field span,
.check-field span {
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
}

.field select:not([multiple]),
.models-type-filter select:not([multiple]) {
  appearance: none;
  background-image: var(--dropdown-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: var(--dropdown-arrow-width) var(--dropdown-arrow-height);
  padding-right: 36px;
}

.model-field.needs-attention > span {
  color: var(--danger);
  font-weight: 700;
}

.workspace-config-panel .model-field.needs-attention select {
  border-color: var(--danger);
  background-color: #fff7f8;
  box-shadow: 0 0 0 4px rgba(201, 45, 57, 0.14);
}

.field select[multiple] {
  min-height: 88px;
  padding: 6px;
}

.main-content.admin-view {
  padding: 34px 44px 64px;
}

.multi-select-field {
  align-self: stretch;
}

.multi-select {
  position: relative;
  min-height: 42px;
}

.multi-select summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  list-style: none;
}

.multi-select summary::-webkit-details-marker {
  display: none;
}

.multi-select summary::after {
  width: var(--dropdown-arrow-width);
  height: var(--dropdown-arrow-height);
  flex: 0 0 var(--dropdown-arrow-width);
  margin-left: auto;
  background-image: var(--dropdown-arrow);
  background-repeat: no-repeat;
  background-position: center;
  background-size: var(--dropdown-arrow-width) var(--dropdown-arrow-height);
  content: "";
  transition: transform 0.15s ease;
}

.multi-select[open] summary::after {
  transform: rotate(180deg);
}

.multi-select-options {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  width: min(360px, 100vw - 48px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.multi-select-options .check-field {
  justify-content: flex-start;
}

.field textarea {
  resize: vertical;
}

.check-field {
  justify-content: end;
}

.check-field.inline,
.check-field {
  flex-direction: row;
  align-items: center;
}

.check-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.drop-zone {
  position: relative;
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 1px dashed #a9b9cf;
  border-radius: 6px;
  background: #fbfdff;
  color: var(--ink);
  text-align: center;
}

.drop-zone.compact {
  min-height: 118px;
}

.drop-zone::before {
  content: "⇪";
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.selected-file {
  font-size: var(--font-small);
}

.drop-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 7px 18px;
  font-weight: 700;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.drop-zone.has-preview {
  min-height: 660px;
  align-items: stretch;
  justify-content: stretch;
  padding: 12px;
  background: #f8fbff;
}

.drop-zone.compact.has-preview {
  min-height: 660px;
}

.drop-zone.has-preview::before,
.drop-zone.has-preview > strong,
.drop-zone.has-preview > span:not(.selected-file),
.drop-zone.has-preview > .drop-button {
  display: none;
}

.drop-zone.has-preview .selected-file {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 2;
  overflow: hidden;
  color: var(--muted);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-preview {
  display: flex;
  width: 100%;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  gap: 8px;
  padding-top: 22px;
}

.document-preview-stage {
  display: flex;
  width: 100%;
  height: 572px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border-radius: 4px;
  background: #fff;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.document-preview-stage.panning {
  cursor: grabbing;
}

.document-preview-processing {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  background: rgba(248, 251, 255, 0.92);
  color: var(--ink);
  text-align: center;
  cursor: wait;
}

.document-preview-processing.error {
  color: var(--danger);
  cursor: default;
}

.document-preview-spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 3px solid #d9e4f0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: document-preview-spin 0.8s linear infinite;
}

.document-preview-processing.error .document-preview-spinner {
  display: none;
}

@keyframes document-preview-spin {
  to { transform: rotate(360deg); }
}

.document-preview-canvas {
  display: grid;
  flex-shrink: 0;
  max-height: 100%;
  transform-origin: center center;
}

.document-preview-canvas.hidden {
  display: none;
}

.document-preview-ocr-overlay {
  position: relative;
  grid-area: 1 / 1;
  z-index: 2;
  pointer-events: none;
}

.document-preview-ocr-box {
  position: absolute;
  border: 0.5px solid rgba(0, 118, 182, 0.58);
  border-radius: 1px;
  background: rgba(0, 118, 182, 0.035);
  padding: 0;
  pointer-events: auto;
}

.document-preview-ocr-box.line {
  border-color: rgba(202, 138, 4, 0.46);
  background: rgba(202, 138, 4, 0.025);
}

.document-preview-ocr-box.word {
  box-shadow: none;
}

.drop-zone.compact .document-preview-stage {
  height: 572px;
}

.document-preview-image,
.document-preview-pdf {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
}

.document-preview-image {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
}

.document-preview-pdf {
  width: 100%;
  height: 100%;
  background: #fff;
}

.document-preview-footer {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.document-preview-pages,
.document-preview-controls,
.document-preview-zoom {
  display: flex;
  align-items: center;
  gap: 5px;
}

.document-preview-page,
.document-preview-overlay-toggle,
.document-preview-zoom button {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd6e4;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 0;
  font-weight: 700;
}

.document-preview-page {
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.document-preview-page.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.document-preview-page-ellipsis,
.document-preview-page-label {
  color: var(--muted);
  font-size: var(--font-small);
}

.document-preview-page-label {
  padding-left: 2px;
  font-weight: 700;
}

.ocr-settings {
  display: grid;
  gap: 12px;
}

.settings-title {
  color: var(--ink);
  font-weight: 700;
}

.ocr-engine-picker {
  width: 100%;
}

.page-auto-rotate-setting {
  width: fit-content;
}

.ocr-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.engine-settings {
  display: grid;
  gap: 12px;
}

.ocr-settings .field input,
.ocr-settings .field select,
.ocr-settings .field textarea {
  min-height: 36px;
  border-radius: 4px;
  padding: 7px 10px;
}

.ocr-settings .field select {
  background-position: right 10px center;
  padding-right: 34px;
}

.ocr-settings .multi-select,
.ocr-settings .multi-select summary {
  min-height: 36px;
}

.ocr-settings .multi-select summary {
  padding: 7px 10px;
}

.ocr-settings .field textarea {
  min-height: 104px;
  line-height: 1.4;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.workspace-column {
  min-width: 0;
}

.workspace-column > .surface {
  margin-bottom: 0;
}

.workspace-scenario-context {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  border-left: 3px solid var(--brand);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  padding: 10px 13px;
  font-size: var(--font-label);
}

.workspace-scenario-context strong {
  color: var(--ink);
}

.workspace-config-surface {
  padding: 0;
}

.workspace-config-surface > h2,
.workspace-config-surface > p,
.workspace-config-surface .drop-zone {
  margin-right: 24px;
  margin-left: 24px;
}

.workspace-config-surface > h2 {
  padding-top: 24px;
}

.workspace-config-tabs {
  margin-top: 16px;
}

.workspace-config-panel {
  padding: 20px 24px 24px;
}

.attribute-title-row {
  align-items: flex-start;
  margin-bottom: 14px;
}

.workspace-shared-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding: 16px 24px 24px;
}

#user-run-section .surface,
#user-run-section .result-surface {
  margin-bottom: 0;
}

#user-run-section .result-surface {
  min-height: 340px;
}

#user-run-section .drop-zone {
  min-height: 156px;
}

#process-form > .action-row {
  justify-content: flex-end;
}

.attribute-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.attribute-row {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 0.55fr) minmax(0, 1.45fr) 44px;
  gap: 10px;
  align-items: center;
  border-radius: 4px;
  transition: opacity 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.attribute-row input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  padding: 8px 12px;
}

.attribute-row .btn {
  width: 44px;
  padding-inline: 0;
}

.drag-handle {
  width: 34px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  font-size: 17px;
  line-height: 1;
  touch-action: none;
}

.drag-handle:hover,
.drag-handle:focus-visible {
  border-color: var(--line);
  background: #f7f9fc;
  color: var(--ink);
}

.drag-handle:active,
.attribute-row.dragging .drag-handle {
  cursor: grabbing;
}

.attribute-row.dragging {
  z-index: 2;
  opacity: 0.48;
  box-shadow: 0 8px 20px rgba(21, 32, 51, 0.18);
  transform: scale(0.995);
}

.attribute-row.drop-before::before,
.attribute-row.drop-after::after {
  position: absolute;
  right: 0;
  left: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
  pointer-events: none;
}

.attribute-row.drop-before::before {
  top: -7px;
}

.attribute-row.drop-after::after {
  bottom: -7px;
}

.redesigned-title-row {
  margin-bottom: 20px;
}

.redesigned-title-row .muted {
  max-width: 690px;
  margin-bottom: 0;
}

.redesigned-attribute-form {
  gap: 20px;
}

.template-source-panel,
.attribute-editor {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.template-source-panel {
  display: grid;
  gap: 22px;
}

.subsection-title {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.subsection-title {
  font-size: 15px;
}

.model-field,
.template-picker-row .field {
  width: min(100%, 520px);
  margin: 0;
}

.model-field small,
.template-helper {
  display: block;
  margin-top: 8px;
  line-height: 1.35;
}

.template-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 520px) auto;
  gap: 10px;
  align-items: end;
}

.fill-template-button {
  min-height: 42px;
  white-space: nowrap;
}

.fill-template-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

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

.add-field-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.plus-symbol {
  font-size: 18px;
  line-height: 1;
  transform: translateY(-1px);
}

.attribute-column-labels {
  overflow-wrap: anywhere;
  display: grid;
  grid-template-columns: 34px minmax(0, 0.55fr) minmax(0, 1.45fr) 44px;
  gap: 10px;
  padding: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.redesigned-rows {
  gap: 8px;
}

.redesigned-rows .attribute-row {
  padding: 5px 0;
}

.instruction-section {
  padding-top: 2px;
}

.instruction-section textarea {
  min-height: 128px;
}

.attribute-editor-save-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.save-template-button {
  white-space: nowrap;
}

.divider {
  height: 1px;
  background: var(--line-soft);
}

.btn {
  min-height: 42px;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 16px;
  font-weight: 600;
  white-space: nowrap;
}

.secondary-button {
  min-height: 38px;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 12px;
  font-weight: 600;
  white-space: nowrap;
}

.secondary-button.small,
.danger-button.small {
  min-height: 34px;
  padding: 5px 10px;
  font-size: var(--font-label);
}

.danger-button {
  min-height: 38px;
  border: 1px solid #f0c7cd;
  border-radius: 6px;
  background: #fff;
  color: var(--danger);
  padding: 7px 12px;
  font-weight: 600;
  white-space: nowrap;
}

.secondary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn.ghost {
  background: #fff;
  color: var(--ink);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.btn.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: wait;
}

.btn.is-busy::before {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  content: "";
  animation: workflow-button-spin 0.75s linear infinite;
}

@keyframes workflow-button-spin {
  to { transform: rotate(360deg); }
}

.btn.danger-text {
  border-color: #f0c7cd;
  color: var(--danger);
  background: #fff;
}

.btn.align-start {
  align-self: start;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.action-row.end {
  justify-content: flex-end;
}

.status-text {
  color: var(--muted);
  font-size: var(--font-label);
  transition: color 0.18s ease, opacity 0.18s ease;
}

.status-text[data-status="busy"] {
  color: var(--warning);
  animation: workflow-status-pulse 1s ease-in-out infinite;
}

.status-text[data-status="ok"] {
  color: var(--success);
}

.status-text[data-status="error"] {
  color: var(--danger);
  font-weight: 700;
}

.result-error-message {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  color: var(--danger);
  font-size: var(--font-label);
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.disabled-feature-notice {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: var(--font-label);
  font-weight: 600;
}

.result-surface {
  scroll-margin-top: 20px;
  padding: 0;
}

.result-surface .result-header {
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
  padding: 20px 24px 18px;
}

.result-tabs-row {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  align-items: stretch;
  justify-content: space-between;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.result-tabs-row .tabs {
  flex: 0 1 auto;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  border: 0;
}

.result-tabs-row .tab {
  flex: 0 0 auto;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.result-tabs-row .result-metrics {
  flex: 0 1 auto;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  align-items: center;
  gap: 8px 18px;
  padding: 12px 24px;
}

.result-tabs-row .result-metrics span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.result-metrics {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: var(--font-small);
}

.result-metrics span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.18s ease;
}

.result-metrics span.is-busy {
  color: var(--warning);
  font-weight: 700;
}

.result-metrics span.is-busy::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
  animation: result-metric-pulse 1s ease-in-out infinite;
}

.result-metrics span.is-ok {
  color: var(--success);
  animation: workflow-status-arrive 0.35s ease-out;
}

.result-metrics span.is-error {
  color: var(--danger);
  font-weight: 700;
  animation: workflow-status-arrive 0.35s ease-out;
}

@keyframes result-metric-pulse {
  50% { opacity: 0.35; }
}

@keyframes workflow-status-pulse {
  50% { opacity: 0.55; }
}

@keyframes workflow-status-arrive {
  from {
    opacity: 0.35;
    transform: translateY(2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn.is-busy::before,
  .result-metrics span.is-busy::before,
  .result-metrics span.is-ok,
  .result-metrics span.is-error,
  .status-text[data-status="busy"] {
    animation: none;
  }
}

.tabs {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.tab {
  min-height: 54px;
  border: 0;
  border-right: 1px solid var(--line-soft);
  background: #fff;
  color: var(--ink);
  padding: 0 28px;
  font-size: var(--font-body);
}

.tab.active {
  color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}

.tab-panel {
  display: none;
  padding: 18px 24px 24px;
}

.tab-panel.active {
  display: block;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.full-text-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.full-text-toolbar {
  flex-wrap: wrap;
  align-items: center;
}

.full-text-toolbar .full-text-search {
  min-width: min(100%, 360px);
  flex: 1 1 360px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.full-text-toolbar > .btn,
.full-text-toolbar > .result-mode-toggle {
  min-height: 42px;
  flex: 0 0 auto;
}

.full-text-search-input {
  min-width: min(100%, 180px);
  max-width: 100%;
  min-height: 42px;
  flex: 1 1 180px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  font: inherit;
}

.full-text-search-input:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 18%, transparent);
  outline-offset: 1px;
}

.full-text-search-count {
  flex-shrink: 0;
  min-width: 72px;
  color: var(--muted);
  font-size: var(--font-small);
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.full-text-search-navigation {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.full-text-search-navigation button {
  width: 42px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.full-text-search-navigation button:hover:not(:disabled),
.full-text-search-navigation button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.full-text-search-navigation button:disabled {
  cursor: default;
  opacity: 0.4;
}

.result-mode-toggle {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  padding: 5px 10px;
  font-size: var(--font-small);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.result-mode-toggle:hover,
.result-mode-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.code-output {
  min-height: 220px;
  max-height: 720px;
  overflow: auto;
  margin: 0;
  border: 0;
  background: #fff;
  color: #111827;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--font-label);
  line-height: 1.45;
}

.text-search-match {
  border-radius: 2px;
  background: #fef08a;
  color: inherit;
  padding: 0;
}

.text-search-match.active {
  background: #fb923c;
  color: #111827;
  box-shadow: 0 0 0 2px color-mix(in srgb, #fb923c 34%, transparent);
}

@media (max-width: 760px) {
  .full-text-toolbar {
    flex-wrap: wrap;
  }

  .full-text-toolbar .full-text-search {
    flex: 1 0 100%;
  }
}

.field-results {
  display: grid;
  gap: 10px;
  line-height: 1.5;
}

.scrollable-field-results {
  max-height: min(572px, calc(100vh - 260px));
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.field-result-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(220px, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 0;
}

.field-result-card {
  display: grid;
  grid-template-columns: minmax(150px, 0.34fr) minmax(240px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.field-result-name,
.field-result-value {
  min-height: 42px;
  border: 1px solid #cbd6e4;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
}

.field-result-name {
  display: flex;
  align-items: flex-start;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.field-result-value {
  position: relative;
  padding-right: 104px;
}

.field-result-value-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.field-result-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  min-height: 28px;
  border: 1px solid #cbd6e4;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 4px 8px;
  font-size: var(--font-small);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.field-result-value:hover .field-result-copy,
.field-result-copy:focus-visible {
  opacity: 1;
}

.field-result-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.field-result-copy.copy-confirmed {
  border-color: var(--success);
  background: #e8f5ee;
  color: var(--success);
  opacity: 1;
}

.btn.copy-confirmed {
  border-color: var(--success);
  background: #e8f5ee;
  color: var(--success);
}

.field-results-empty {
  color: var(--muted);
}

.cards-search-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.cards-search-field {
  width: 380px;
  max-width: 100%;
}

.cards-search-bar > [role="status"] {
  padding-bottom: 10px;
  font-size: var(--font-label);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

#template-grid,
#scenarios-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, clamp(260px, 22vw, 320px)), 1fr));
}

.entity-card {
  display: flex;
  min-height: 170px;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 18px;
}

.scenario-card,
.template-card,
.model-card {
  display: flex;
  min-height: 170px;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 18px;
}

.template-card {
  gap: 12px;
}

.template-card > p {
  margin: 0;
  overflow-wrap: anywhere;
}

.scenario-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.scenario-card-header h3 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.scenario-more {
  position: relative;
  flex: 0 0 auto;
}

.scenario-more > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  font-size: 24px;
}

.scenario-more > summary::-webkit-details-marker {
  display: none;
}

.scenario-more > summary:hover,
.scenario-more[open] > summary {
  background: #f0f4f9;
}

.scenario-more > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.entity-card h3 {
  margin: 0;
  font-size: var(--font-card-title);
}

.entity-card p,
.scenario-card p,
.template-card p,
.model-card p {
  font-size: var(--font-label);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f0f4f9;
  color: var(--muted);
  padding: 4px 10px;
  font-size: var(--font-small);
}

.tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f0f4f9;
  color: var(--muted);
  padding: 4px 10px;
  font-size: var(--font-small);
  font-weight: 600;
}

.tag.red {
  background: #fde8eb;
  color: var(--danger);
}

.tag.blue {
  background: #e8f0fb;
  color: #315f9d;
}

.check-tag {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: #f6f8fb;
  color: var(--muted);
  padding: 4px 10px;
  font-size: var(--font-label);
  font-weight: 600;
}

.check-tag input {
  accent-color: var(--accent);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

.scenario-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fbfdff;
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.connection-url,
.service-note,
.model-note,
.small-muted {
  color: var(--muted);
  font-size: var(--font-label);
}

.danger-link {
  color: var(--danger);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fff;
}

.data-table th {
  background: #e0e7f0;
  color: #3b4656;
  text-align: left;
  font-weight: 700;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px 14px;
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.actions-col {
  width: 340px;
  text-align: right;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  min-width: 86px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8f5ee;
  color: var(--success);
  padding: 4px 10px;
  font-size: var(--font-small);
  font-weight: 700;
  text-align: center;
}

.status-pill {
  display: inline-flex;
  min-width: 86px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f0f4f9;
  color: var(--muted);
  padding: 4px 10px;
  font-size: var(--font-small);
  font-weight: 700;
  text-align: center;
}

.status-pill.running,
.status-pill.available {
  background: #e8f5ee;
  color: var(--success);
}

.status-pill.starting {
  background: #fff3dd;
  color: var(--warning);
}

.status-pill.stopped,
.status-pill.unavailable,
.status-pill.error {
  background: #fde8eb;
  color: var(--danger);
}

.models-header {
  align-items: center;
}

.models-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.check-all-button.checking::before {
  content: "";
  width: 13px;
  height: 13px;
  border: 2px solid rgba(21, 32, 51, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: model-check-spin 0.75s linear infinite;
}

@keyframes model-check-spin {
  to { transform: rotate(360deg); }
}

.model-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.model-title-line strong {
  color: var(--ink);
  font-size: var(--font-body);
}

.model-enabled-state {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: var(--font-small);
  font-weight: 700;
}

.document-preview-overlay-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.document-preview-overlay-toggle.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--accent);
}

.model-enabled-state.enabled {
  background: #e8f6ef;
  color: #18794e;
}

.model-enabled-state.disabled {
  background: #eef1f5;
  color: #697586;
}

.model-secondary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--font-label);
  line-height: 1.4;
}

.model-code {
  color: #24364a;
  font-family: inherit;
  font-size: var(--font-body);
}

.model-url,
.check-message {
  max-width: 250px;
  overflow-wrap: anywhere;
}

.purpose-badge {
  display: inline-flex;
  min-width: 48px;
  height: 25px;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd4e0;
  border-radius: 4px;
  background: #f8fafc;
  color: #38455a;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.purpose-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.65);
}

.purpose-badge.ocr {
  border-color: #cbd4e0;
  background: #f8fafc;
  color: #38455a;
}

.purpose-badge.attributes {
  border-color: #cbd4e0;
  background: #f8fafc;
  color: #38455a;
}

.purpose-badge.unknown {
  border-color: #d8dee7;
  background: #f2f4f7;
  color: #697586;
}

.status-ok,
.status-running,
.status-available {
  color: var(--success);
  font-weight: 700;
  text-align: center;
}

.status-error,
.status-stopped {
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

.status-loading {
  color: var(--warning);
  font-weight: 700;
  text-align: center;
}

.status-badge.warning {
  background: #fff3dd;
  color: var(--warning);
}

.status-badge.error {
  background: #fde8eb;
  color: var(--danger);
}

.admin-model-section {
  padding-top: 22px;
}

.admin-model-section + .admin-model-section {
  margin-top: 26px;
  border-top: 1px solid var(--line);
}

.admin-model-section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-model-section-title h3,
.admin-model-section-title p {
  margin: 0;
}

.admin-model-section-title p {
  margin-top: 4px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  background: rgba(16, 27, 42, 0.45);
  padding: 44px 24px;
}

.modal {
  width: min(620px, 100%);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal.wide {
  width: min(1180px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 0;
  font-size: var(--font-section-title);
}

.modal h3 {
  font-size: var(--font-card-title);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.icon-button svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

#save-scenario-form > .check-field {
  margin-top: 20px;
}

#save-scenario-available {
  margin: 0;
}

.api-token-modal-backdrop {
  align-items: center;
}

.api-token-modal {
  width: min(760px, 100%);
  overflow: hidden;
  border-radius: 11px;
  padding: 0;
  box-shadow: 0 24px 64px rgba(16, 27, 42, 0.26);
}

.api-token-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 32px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.api-token-modal-header h2,
.api-token-modal-header p {
  margin: 0;
}

.api-token-modal-header h2 {
  font-size: 24px;
  line-height: 1.2;
}

.api-token-modal-header p {
  margin-top: 7px;
  color: #738096;
  font-size: 15px;
}

.api-token-modal-header .icon-button {
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
  border-radius: 8px;
  font-weight: 300;
}

.api-token-create-form {
  display: flex;
  gap: 12px;
  padding: 30px 32px 22px;
}

.api-token-create-form input {
  min-width: 0;
  min-height: 47px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
}

.api-token-create-form input:focus {
  border-color: var(--ink);
  outline: 1px solid var(--ink);
}

.api-token-create-form .btn {
  min-width: 170px;
}

.api-tokens-table th:nth-child(1) { width: 20%; }
.api-tokens-table th:nth-child(2) { width: 18%; }
.api-tokens-table th:nth-child(3) { width: 18%; }
.api-tokens-table th:nth-child(4) { width: auto; }
.api-tokens-table th:nth-child(5) { width: 110px; }
.api-tokens-table th:nth-child(6) { width: 150px; }

.models-table-wrap.api-tokens-table-wrap {
  overflow-x: auto;
}

.models-table.api-tokens-table {
  min-width: 900px;
}

.api-tokens-table td {
  overflow-wrap: anywhere;
}

.api-tokens-table td:last-child {
  text-align: right;
  white-space: nowrap;
}

.api-tokens-table code {
  color: #627087;
}

#api-tokens-status:not(:empty) {
  padding: 0 24px 18px;
}

.api-token-modal-status {
  min-height: 20px;
  margin: -8px 32px 24px;
}

.api-token-secret-modal {
  width: min(850px, 100%);
}

.api-token-secret-value {
  overflow-x: auto;
  margin: 30px 32px 50px;
  background: #f1f5f9;
  padding: 17px 16px;
  color: #0b2240;
  font-family: Consolas, "Courier New", monospace;
  font-size: 16px;
  white-space: nowrap;
  user-select: all;
}

.api-token-secret-value:focus-visible {
  outline: 3px solid rgba(229, 57, 70, 0.18);
}

.api-token-secret-actions {
  display: flex;
  justify-content: flex-end;
  padding: 20px 32px;
  border-top: 1px solid var(--line-soft);
}

.api-token-secret-actions .btn {
  min-width: 185px;
}

.api-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.api-tabs {
  display: flex;
  overflow-x: auto;
  align-items: center;
  border: 0;
  border-radius: 10px;
  background: #f1f3f6;
  padding: 4px;
}

.api-tab {
  min-height: 42px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #5c687b;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 650;
}

.api-tab:hover {
  color: var(--brand);
}

.api-tab.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(21, 32, 51, 0.14);
}

.api-tab-panel {
  display: none;
  min-height: 430px;
  padding-top: 24px;
}

.api-tab-panel.active {
  display: block;
}

.api-tab-intro {
  margin-bottom: 18px;
}

.api-tab-intro h3,
.api-tab-intro p {
  margin: 0;
}

.api-tab-intro h3 {
  font-size: 20px;
}

.api-tab-intro p {
  max-width: 720px;
  margin-top: 6px;
  color: var(--muted);
}

.api-studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(260px, 1fr);
  align-items: stretch;
  gap: 18px;
}

.api-settings-stack {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.api-tab-intro-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.scenario-api-code-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8fa;
  padding: 3px 5px 3px 9px;
  white-space: nowrap;
}

.scenario-api-code-inline > span {
  color: var(--muted);
  font-size: 10px;
}

.scenario-api-code-inline > code {
  font-size: 11px;
}

.api-settings-card,
.api-help-card,
.api-code-panel,
.api-postman-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.api-settings-card {
  overflow: hidden;
}

.api-settings-header {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: #f7f8fa;
  padding: 0 18px;
}

.api-settings-header h4 {
  margin: 0;
  font-size: 14px;
}

.api-settings-header span {
  border-radius: 999px;
  background: #e9ecf1;
  color: #5c687b;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
}

.api-settings-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 30px;
  min-height: 46px;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  padding: 6px 14px;
}

.api-settings-row-dictionary {
  align-items: start;
  padding-top: 8px;
  padding-bottom: 8px;
}

.api-settings-name {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.api-settings-value {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  font-weight: 600;
}

input.api-settings-value,
textarea.api-settings-value {
  width: 100%;
  padding: 0;
}

.api-url-value {
  resize: none;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.api-value-copy {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #687487;
  padding: 0;
  font-size: 15px;
}

.api-value-copy:hover,
.api-value-copy:focus-visible {
  border-color: #efc8cc;
  background: #fff4f5;
  color: var(--brand);
}

.api-value-copy.copy-confirmed {
  border-color: #a9d8bd;
  background: #e8f5ee;
  color: var(--success);
}

.api-value-copy.inline {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  font-size: 13px;
}

.api-dictionary {
  display: grid;
  grid-template-columns: 0.8fr 1fr 1fr;
  gap: 9px;
  min-width: 0;
}

.api-dictionary-value {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.api-dictionary-value small {
  color: #8791a1;
  font-size: 10px;
  font-weight: 600;
}

.api-dictionary-value > span {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 3px;
}

.api-dictionary-value code {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  font-weight: 600;
}

.api-help-card {
  padding: 18px;
}

.api-help-card h4 {
  margin: 0 0 18px;
  font-size: 14px;
}

.api-help-summary {
  display: grid;
  gap: 10px;
}

.api-help-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.api-help-card ol {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.api-help-card li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.api-help-card li > span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #fff0f1;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.api-help-card li p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.api-help-card li b {
  color: var(--ink);
}

.api-help-note {
  margin-top: 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 7px 7px 0;
  background: #fff4f5;
  color: #583438;
  padding: 12px 13px;
}

.api-help-note b {
  font-size: 12px;
}

.api-help-note p {
  margin: 4px 0 0;
  font-size: 12px;
}

.api-code-panel {
  position: relative;
  overflow: hidden;
  background: #f1f3f6;
}

.api-code-panel > .btn {
  position: absolute;
  z-index: 1;
  top: 12px;
  right: 12px;
  border-color: #cbd1da;
  background: #fff;
  color: #4b586b;
}

.api-code-panel .code-output {
  min-height: 320px;
  margin: 0;
  background: transparent;
  color: #263244;
  padding: 58px 20px 20px;
}

.api-code-panel .syntax-keyword {
  color: #075fca;
  font-weight: 700;
}

.api-code-panel .syntax-string {
  color: #a33a00;
}

.api-code-panel .syntax-number,
.api-code-panel .syntax-literal {
  color: #7650b3;
}

.api-code-panel .syntax-comment {
  color: #687487;
  font-style: italic;
}

.compact-code {
  max-height: 520px;
  font-size: 12px;
  line-height: 1.6;
}

.api-postman-panel {
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
}

.api-postman-panel h4,
.api-postman-panel p {
  margin: 0;
}

.api-postman-panel p {
  margin-top: 5px;
  color: var(--muted);
}

.api-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin: 24px -24px -24px;
  border-top: 1px solid var(--line-soft);
  background: #fafbfd;
  padding: 16px 24px;
}

.api-result-metrics {
  justify-content: flex-start;
}

@media (max-width: 1180px) {
  .workspace-grid,
  .form-grid.two,
  .form-grid.four,
  .ocr-settings-grid {
    grid-template-columns: 1fr;
  }

  .workspace-grid {
    gap: 0;
  }
}

@media (max-width: 900px) {
  .api-studio-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .modal-backdrop {
    padding: 18px 10px;
  }

  .modal.wide {
    padding: 18px;
  }

  .api-tabs {
    margin-right: -4px;
    margin-left: -4px;
  }

  .api-tab {
    padding: 0 14px;
  }

  .api-tab-intro-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .api-settings-row {
    grid-template-columns: minmax(0, 1fr) 30px;
  }

  .api-settings-name {
    grid-column: 1 / -1;
  }

  .api-dictionary {
    grid-template-columns: 1fr;
  }

  .api-additional-grid {
    grid-template-columns: 1fr;
  }

  .api-postman-panel,
  .api-modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .api-modal-footer {
    margin: 24px -18px -18px;
    padding: 16px 18px;
  }

  .api-modal-footer .btn {
    width: 100%;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-basis: auto;
  }

  .main-content {
    padding: 18px;
  }

  .page-header {
    padding: 22px;
  }

  .surface {
    padding: 20px;
  }

  .models-header {
    align-items: stretch;
    flex-direction: column;
  }

  .models-toolbar {
    justify-content: stretch;
  }

  .models-toolbar .btn {
    flex: 1 1 auto;
  }

  .attribute-editor-header {
    align-items: stretch;
    flex-direction: column;
  }

  .template-picker-row {
    grid-template-columns: 1fr;
  }

  .template-picker-row .field,
  .model-field,
  .fill-template-button,
  .add-field-button,
  .save-template-button {
    width: 100%;
  }

  .fill-template-button,
  .add-field-button,
  .save-template-button {
    justify-content: center;
  }

  .attribute-column-labels {
    display: none;
  }

  .field-result-card {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }
}

/* Раздел системных моделей */
.page-subtitle {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: var(--font-body);
}

.header-actions.admin-only {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-actions.admin-only .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.header-actions.admin-only .btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.admin-tabs-row {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.admin-tabs {
  display: flex;
  min-width: 0;
  gap: 4px;
}

.admin-tabs-actions {
  flex: 0 0 auto;
  padding-bottom: 7px;
}

.admin-tab {
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 11px 16px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.admin-tab:hover {
  color: var(--ink);
}

.admin-tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.admin-data-intro {
  margin-bottom: 18px;
}

.admin-data-intro h2,
.data-transfer-card h3 {
  margin: 0;
}

.admin-data-intro p,
.data-transfer-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.data-transfer-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.data-transfer-step {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: var(--font-small);
  font-weight: 700;
}

.data-secret-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface-soft, #f7f8fa);
  padding: 12px;
}

.data-secret-option input {
  flex: 0 0 auto;
  margin-top: 3px;
}

.data-secret-option span {
  display: grid;
  gap: 3px;
}

.data-secret-option small {
  color: var(--muted);
  font-weight: 400;
}

.data-transfer-card > .btn,
.data-import-actions {
  align-self: flex-start;
}

.data-import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-text.success {
  color: var(--success);
}

.status-text.error {
  color: var(--danger);
}

.import-preview {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 18px;
}

.import-preview h3 {
  margin: 0;
}

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

.import-preview-item {
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 11px 12px;
}

.import-preview-item strong,
.import-preview-item span {
  display: block;
}

.import-preview-item strong {
  font-size: 18px;
}

.import-preview-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--font-small);
}

.import-preview-secrets {
  margin: 0;
  border-left: 3px solid var(--line);
  padding: 8px 12px;
  color: var(--muted);
}

.import-preview-secrets.has-secrets {
  border-left-color: var(--warning, #b7791f);
  color: var(--ink);
}

.import-preview-warnings {
  margin: 0;
  padding-left: 20px;
  color: var(--danger);
}

.models-summary {
  display: none;
  max-width: 510px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.models-summary-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  padding: 11px 13px;
}

.models-summary-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.models-summary-label {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--font-small);
}

.models-summary-item.available .models-summary-value {
  color: var(--success);
}

.models-summary-item.unavailable .models-summary-value {
  color: var(--danger);
}

.models-surface {
  overflow: visible;
  padding: 0;
  border-radius: 7px;
}

.models-surface-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.models-surface .models-surface-head h2 {
  margin: 0;
  font-size: 17px;
}

.models-surface-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: var(--font-label);
}

.models-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

[data-admin-panel="models"] .models-surface-head {
  flex-wrap: wrap;
}

.models-search {
  position: relative;
  width: 285px;
  flex: 0 0 auto;
  border-radius: 6px;
}

.models-search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.7;
}

.models-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px 8px 36px;
}

.models-type-filter select {
  min-width: 126px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: #fff;
  color: var(--ink);
  padding: 0 36px 0 12px;
}

.models-search:focus-within {
  box-shadow: 0 0 0 3px rgba(229, 57, 70, 0.16);
}

.models-type-filter select:focus-visible {
  outline: 3px solid rgba(229, 57, 70, 0.16);
  outline-offset: 1px;
}

.models-search input::placeholder {
  color: #939cab;
}

.models-table-wrap {
  overflow: visible;
}

.models-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.models-table th {
  height: 44px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: #f4f7fa;
  color: #566174;
  font-size: var(--font-small);
  font-weight: 700;
  letter-spacing: 0.015em;
  text-align: left;
}

.models-table td {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

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

.models-row {
  transition: background 0.14s ease;
}

.models-row:hover {
  background: #fbfcfe;
}

.models-row.is-muted {
  background: #fcfdfe;
}

.models-col-model {
  width: 34%;
}

.models-col-purpose {
  width: 10%;
}

.models-col-state {
  width: 17%;
}

.models-col-context {
  width: 17%;
}

.models-col-check {
  width: 22%;
  text-align: right !important;
}

.models-name-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.models-name {
  overflow: hidden;
  font-size: var(--font-card-title);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.models-code {
  overflow: hidden;
  margin-top: 5px;
  color: #364256;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.models-url {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--font-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.models-usage {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  border-radius: 4px;
  background: #eef2f7;
  color: #667286;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}

.models-availability {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-weight: 700;
}

.models-error-help {
  position: relative;
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--danger);
  cursor: help;
  font-size: 12px;
  line-height: 1;
}

.models-error-help::after {
  position: absolute;
  z-index: 40;
  bottom: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: min(360px, 75vw);
  border-radius: 6px;
  background: #152033;
  box-shadow: 0 8px 24px rgba(21, 32, 51, 0.2);
  color: #fff;
  content: attr(data-tooltip);
  font-size: var(--font-small);
  font-weight: 400;
  line-height: 1.4;
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, 4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  visibility: hidden;
  white-space: normal;
}

.models-error-help:hover::after,
.models-error-help:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}

.models-error-help:focus-visible {
  outline: 3px solid rgba(201, 45, 57, 0.18);
  outline-offset: 2px;
}

.models-availability::before {
  display: none;
}

.models-availability.ok {
  color: var(--ink);
}

.models-availability.ok::before {
  background: var(--success);
  box-shadow: 0 0 0 4px #e8f5ee;
}

.models-availability.error {
  color: var(--danger);
}

.models-availability.error::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px #fdebed;
}

.models-availability.unknown {
  color: var(--muted);
}

.models-availability.unknown::before {
  background: #8b96a7;
  box-shadow: 0 0 0 4px #eef1f5;
}

.models-availability.checking {
  color: var(--warning);
}

.models-availability.checking::before {
  background: var(--warning);
  box-shadow: 0 0 0 4px #fff3dd;
  animation: model-status-pulse 1s infinite;
}

@keyframes model-status-pulse {
  50% { opacity: 0.45; }
}

.models-enabled-control {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: var(--font-small);
}

.models-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex: 0 0 auto;
}

.models-switch input {
  width: 0;
  height: 0;
  opacity: 0;
}

.models-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #bec8d5;
  transition: 0.18s ease;
}

.models-slider::before {
  position: absolute;
  bottom: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(21, 32, 51, 0.25);
  transition: 0.18s ease;
  content: "";
}

.models-switch input:checked + .models-slider {
  background: var(--accent);
}

.models-switch input:checked + .models-slider::before {
  transform: translateX(14px);
}

.models-switch input:focus-visible + .models-slider {
  outline: 3px solid rgba(185, 43, 53, 0.18);
  outline-offset: 2px;
}

.models-context-main {
  display: block;
  font-weight: 650;
}

.models-subtext {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--font-small);
}

.models-check-cell {
  position: relative;
  text-align: right;
}

.models-check-time {
  color: #435067;
  font-size: var(--font-small);
}

.models-check-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 8px;
}

.models-check-actions .btn.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: var(--font-label);
}

.models-menu-wrap {
  position: relative;
}

.models-menu-toggle {
  width: 36px;
  min-width: 36px;
  padding: 0 !important;
  font-size: 18px !important;
  line-height: 1;
}

.models-menu,
.scenario-more-actions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  width: 180px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 16px 44px rgba(21, 32, 51, 0.14);
  padding: 6px;
}

.models-menu button,
.scenario-more-actions button {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  padding: 7px 9px;
  text-align: left;
}

.models-menu button:hover,
.scenario-more-actions button:hover {
  background: #f4f7fa;
}

.models-menu button.danger,
.scenario-more-actions button.danger {
  color: var(--danger);
}

.models-menu button:disabled,
.scenario-more-actions button:disabled {
  color: #a3abb8;
  cursor: not-allowed;
}

.models-menu-separator,
.scenario-more-separator {
  height: 1px;
  margin: 5px 3px;
  background: var(--line-soft);
}

.models-empty-state,
.models-empty-search {
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.models-empty-search strong {
  display: block;
  margin-bottom: 4px;
  color: #364256;
  font-size: var(--font-card-title);
}

.models-mobile-list {
  display: none;
  padding: 12px;
}

.admin-model-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 14px;
}

.admin-model-card + .admin-model-card {
  margin-top: 10px;
}

.admin-model-card.is-muted {
  background: #fcfdfe;
}

.admin-model-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.admin-model-card-heading {
  min-width: 0;
}

.admin-model-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.admin-model-card-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.admin-model-card-value {
  font-size: var(--font-label);
  font-weight: 650;
}

.admin-model-card-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
}

.admin-model-card-actions .models-enabled-control,
.admin-model-card-actions .models-check-actions {
  margin-top: 0;
}

.models-mobile-list.search-empty {
  display: none !important;
}

@media (max-width: 1000px) {
  .main-content.admin-view {
    padding: 26px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-header-tools {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-left: 0;
  }

  .page-user {
    margin-left: 0;
  }

  .page-user-stack {
    margin-left: auto;
  }

  .header-actions.admin-only {
    width: 100%;
    justify-content: flex-start;
  }

  .header-actions.admin-tabs-actions {
    width: auto;
    justify-content: flex-end;
  }

  .admin-data-grid {
    grid-template-columns: 1fr;
  }

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

  .models-surface-head {
    align-items: stretch;
    flex-direction: column;
  }

  .models-filters,
  .models-search {
    width: 100%;
  }

  .models-search {
    flex: 1 1 auto;
  }

  .models-table-wrap {
    display: none;
  }

  .api-tokens-table-wrap {
    display: block;
    overflow-x: auto;
  }

  .models-mobile-list {
    display: block;
  }
}

@media (max-width: 600px) {
  .main-content.admin-view {
    padding: 22px 16px 42px;
  }

  .admin-tabs-row {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
  }

  .admin-tabs-actions {
    width: 100%;
    padding-bottom: 0;
  }

  .header-actions.admin-tabs-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions.admin-only .btn {
    flex: 1 1 auto;
  }

  .admin-tab {
    flex: 1 1 0;
  }

  .import-preview-grid {
    grid-template-columns: 1fr;
  }

  .models-summary {
    max-width: none;
  }

  .api-token-modal-backdrop {
    align-items: flex-start;
    padding: 18px 12px;
  }

  .api-token-modal-header {
    padding: 22px 20px 18px;
  }

  .api-token-modal-header h2 {
    font-size: 20px;
  }

  .api-token-create-form {
    flex-direction: column;
    padding: 22px 20px 16px;
  }

  .api-token-create-form .btn {
    width: 100%;
  }

  .api-token-secret-value {
    margin: 24px 20px 36px;
  }

  .api-token-secret-actions {
    padding: 18px 20px;
  }

  .api-token-secret-actions .btn {
    width: 100%;
  }

  .models-summary-item {
    padding: 9px 10px;
  }

  .models-summary-label {
    font-size: 11px;
  }

  .models-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .models-type-filter select {
    width: 100%;
  }

  .admin-model-card-grid {
    grid-template-columns: 1fr;
  }

  .admin-model-card-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-model-card-actions .models-check-actions {
    justify-content: flex-start;
  }
}

/* Авторизация */
.auth-view {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(420px, 46%) 1fr;
  background: var(--surface);
}

.auth-card {
  display: flex;
  width: min(440px, calc(100% - 64px));
  margin: auto;
  flex-direction: column;
  padding: 42px 0;
}

.auth-heading {
  margin-bottom: 28px;
}

.auth-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-heading h1 {
  margin: 0 0 10px;
  color: var(--header);
  font-size: 32px;
  line-height: 1.15;
}

.auth-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.auth-form {
  display: grid;
  gap: 17px;
}

.auth-form input {
  min-height: 44px;
}

.auth-submit,
.auth-keycloak {
  width: 100%;
  min-height: 44px;
  justify-content: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line-soft);
  content: "";
}

.auth-keycloak {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 650;
}

.auth-keycloak:hover {
  border-color: #aab6c7;
  background: #f8fafc;
}

.auth-keycloak:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.auth-keycloak svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-status {
  min-height: 20px;
  margin: 18px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.auth-status.error {
  color: var(--danger);
}

.auth-aside {
  position: relative;
  display: flex;
  min-height: 100vh;
  align-items: flex-end;
  overflow: hidden;
  padding: 72px;
  background:
    radial-gradient(circle at 74% 24%, rgba(229, 57, 70, 0.3), transparent 24%),
    linear-gradient(145deg, #101b2a 0%, #172942 56%, #701c27 130%);
  color: #fff;
}

.auth-aside::before,
.auth-aside::after {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  content: "";
}

.auth-aside::before {
  top: 10%;
  right: 8%;
  width: 420px;
  height: 420px;
}

.auth-aside::after {
  top: 20%;
  right: 18%;
  width: 220px;
  height: 220px;
}

.auth-aside-content {
  position: relative;
  z-index: 1;
  max-width: 540px;
}

.auth-aside-content strong {
  display: block;
  max-width: 520px;
  margin: 0 0 18px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.04;
}

.auth-aside-content p {
  max-width: 450px;
  margin: 0;
  color: #bfcada;
  font-size: 16px;
}

@media (max-width: 900px) {
  .auth-view {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    display: none;
  }
}

@media (max-width: 520px) {
  .result-tabs-row {
    flex-direction: column;
  }

  .result-tabs-row .tabs {
    border-bottom: 1px solid var(--line-soft);
  }

  .result-tabs-row .result-metrics {
    min-height: 44px;
    padding: 12px 18px;
  }

  .auth-card {
    width: min(100% - 36px, 440px);
  }

  .page-header-tools {
    align-items: stretch;
  }

  .page-user {
    width: 100%;
    max-width: none;
    margin-left: 0;
  }

  .page-user-stack {
    width: 100%;
    margin-left: 0;
  }

  .auth-heading h1 {
    font-size: 28px;
  }
}

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

.license-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.license-upload-card {
  grid-column: 1 / -1;
}

.license-card-heading,
.license-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.license-kicker {
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 700;
  text-transform: uppercase;
}

.license-card h2 {
  margin: 4px 0 6px;
}

.license-card p {
  margin: 0;
  color: var(--muted);
}

.license-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--muted);
  font-size: var(--font-small);
  font-weight: 700;
  white-space: nowrap;
}

.license-badge.is-valid {
  background: #e4f5eb;
  color: var(--success);
}

.license-badge.is-invalid {
  background: #fdebed;
  color: var(--danger);
}

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

.license-metrics > div,
.license-details > div {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

.license-metrics span,
.license-details dt {
  display: block;
  color: var(--muted);
  font-size: var(--font-small);
}

.license-metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

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

.license-details dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

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

  .license-upload-card {
    grid-column: auto;
  }
}
