:root {
  --bg: #f4efe7;
  --bg-ambient: #e6d8c4;
  --panel: rgba(255, 250, 243, 0.88);
  --panel-strong: #fffdfa;
  --panel-muted: rgba(255, 255, 255, 0.68);
  --ink: #181411;
  --ink-soft: #63584d;
  --line: rgba(24, 20, 17, 0.1);
  --line-strong: rgba(24, 20, 17, 0.18);
  --accent: #b85d3d;
  --accent-strong: #95462a;
  --accent-soft: rgba(184, 93, 61, 0.1);
  --accent-soft-strong: rgba(184, 93, 61, 0.16);
  --cool: #456169;
  --cool-soft: rgba(69, 97, 105, 0.11);
  --ok: #236a4c;
  --ok-soft: rgba(35, 106, 76, 0.12);
  --warn: #946003;
  --warn-soft: rgba(148, 96, 3, 0.12);
  --error: #9d3535;
  --error-soft: rgba(157, 53, 53, 0.12);
  --radius-xxl: 32px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-lift: 0 24px 80px rgba(24, 20, 17, 0.08);
  --shadow-soft: 0 14px 40px rgba(24, 20, 17, 0.06);
  --font-sans: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(184, 93, 61, 0.14), transparent 26%),
    radial-gradient(circle at right 16% top 12%, rgba(69, 97, 105, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg) 0%, #efe7db 100%);
  color: var(--ink);
  font-family: var(--font-sans);
}

body {
  margin: 0;
  min-height: 100vh;
  background-image:
    linear-gradient(rgba(24, 20, 17, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 20, 17, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
}

body.is-auth-locked {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(184, 93, 61, 0.18);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-strong);
  box-shadow: var(--shadow-lift);
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 360px);
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.hero__copy {
  max-width: 900px;
}

.eyebrow,
.panel__label {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cool);
}

.hero h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 72px);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero__lede {
  max-width: 70ch;
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.65;
}

.hero__meta {
  display: grid;
  gap: 14px;
  align-self: start;
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  color: var(--ink-soft);
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 249, 0.66);
}

.app-nav__button,
.segmented-control__button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  color: var(--ink-soft);
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.app-nav__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  min-width: 0;
  white-space: nowrap;
}

.app-nav__icon {
  width: 17px;
  height: 17px;
  display: inline-flex;
  flex: 0 0 auto;
}

.app-nav__icon svg {
  width: 100%;
  height: 100%;
}

.app-nav__button.is-active,
.segmented-control__button.is-active {
  border-color: rgba(184, 93, 61, 0.42);
  background: var(--accent-soft-strong);
  color: var(--accent-strong);
}

.hero__status,
.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 6px rgba(148, 96, 3, 0.12);
}

.status-dot.is-ok {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(35, 106, 76, 0.16);
}

.status-dot.is-error {
  background: var(--error);
  box-shadow: 0 0 0 6px rgba(157, 53, 53, 0.16);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(400px, 560px) minmax(680px, 1fr);
  gap: 22px;
  align-items: start;
}

.app-view[hidden] {
  display: none;
}

.account-view {
  width: 100%;
}

.admin-grid {
  display: grid;
  gap: 22px;
}

.account-panel {
  padding: 0 24px 24px;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: var(--radius-xxl);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lift);
}

.panel--intake {
  position: sticky;
  top: 20px;
}

.panel--intake,
.panel--results {
  padding: 0 24px 24px;
}

.panel__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 24px 24px 0;
}

.panel__head--compact {
  padding: 0;
}

.panel__head h2,
.results-intro__title {
  margin: 0;
  font-size: 30px;
  line-height: 1.04;
}

.composer-card,
.ktru-catalog-panel,
.draft-panel,
.log-panel,
.result-card {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-strong);
}

.composer-card {
  display: grid;
  gap: 14px;
}

.composer-card__intro {
  display: grid;
  gap: 8px;
}

.field-label {
  display: block;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.field-label--compact {
  margin-bottom: 8px;
}

.field-note,
.submit-note,
.section-note,
.draft-item__hint {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.field-input,
.field-textarea,
select.field-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fffdf9;
  color: var(--ink);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease,
    background 0.2s ease;
}

.field-input {
  min-height: 52px;
  padding: 13px 15px;
}

.field-textarea {
  min-height: 170px;
  resize: vertical;
  padding: 16px 18px;
  line-height: 1.65;
}

.field-textarea--hero {
  min-height: 220px;
}

.field-textarea--composer {
  min-height: 190px;
  border: 0;
  padding: 10px 12px 6px;
  background: transparent;
  box-shadow: none;
}

.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: rgba(184, 93, 61, 0.45);
  box-shadow: 0 0 0 4px rgba(184, 93, 61, 0.12);
  transform: translateY(-1px);
}

.field-textarea--composer:focus {
  border: 0;
  box-shadow: none;
  transform: none;
}

.composer-shell {
  display: grid;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fffdf9;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.composer-shell:focus-within {
  border-color: rgba(184, 93, 61, 0.45);
  box-shadow: 0 0 0 4px rgba(184, 93, 61, 0.1);
  transform: translateY(-1px);
}

.composer-shell.is-recording {
  border-color: rgba(184, 93, 61, 0.34);
  box-shadow: 0 0 0 4px rgba(184, 93, 61, 0.08);
}

.composer-shell__status {
  display: grid;
  gap: 10px;
  padding: 0 10px;
}

.composer-shell__footer,
.composer-tools,
.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.composer-shell__footer {
  display: grid;
  gap: 12px;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.composer-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  gap: 8px;
}

.composer-tools .button {
  width: 100%;
  min-width: 0;
  padding-inline: 8px;
  white-space: nowrap;
}

.composer-actions {
  justify-content: flex-end;
}

.composer-ticker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.86);
  color: var(--ink-soft);
}

.composer-ticker[data-state="recording"] {
  border-color: rgba(184, 93, 61, 0.24);
  background: rgba(184, 93, 61, 0.08);
  color: var(--accent-strong);
}

.composer-wave {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  width: 40px;
  height: 18px;
  opacity: 0;
  visibility: hidden;
  flex: 0 0 auto;
  transition: opacity 0.18s ease;
}

.composer-wave span {
  width: 3px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.72;
  transform: scaleY(0.5);
  transform-origin: center;
}

.composer-ticker[data-state="recording"] .composer-wave {
  opacity: 1;
  visibility: visible;
}

.composer-ticker[data-state="recording"] .composer-wave span {
  animation: voice-wave 0.82s ease-in-out infinite;
}

.composer-ticker[data-state="recording"] .composer-wave span:nth-child(2) {
  animation-delay: -0.7s;
}

.composer-ticker[data-state="recording"] .composer-wave span:nth-child(3) {
  animation-delay: -0.58s;
}

.composer-ticker[data-state="recording"] .composer-wave span:nth-child(4) {
  animation-delay: -0.46s;
}

.composer-ticker[data-state="recording"] .composer-wave span:nth-child(5) {
  animation-delay: -0.34s;
}

.composer-ticker[data-state="recording"] .composer-wave span:nth-child(6) {
  animation-delay: -0.22s;
}

.composer-ticker[data-state="recording"] .composer-wave span:nth-child(7) {
  animation-delay: -0.1s;
}

.composer-ticker[data-state="transcribing"] {
  border-color: rgba(148, 96, 3, 0.24);
  background: rgba(148, 96, 3, 0.08);
  color: #805100;
}

.composer-ticker[data-state="success"] {
  border-color: rgba(35, 106, 76, 0.24);
  background: rgba(35, 106, 76, 0.08);
  color: var(--ok);
}

.composer-ticker[data-state="error"] {
  border-color: rgba(157, 53, 53, 0.24);
  background: rgba(157, 53, 53, 0.08);
  color: var(--error);
}

.composer-ticker__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--cool);
  box-shadow: 0 0 0 5px rgba(69, 97, 105, 0.12);
  flex: 0 0 auto;
}

.composer-ticker[data-state="recording"] .composer-ticker__dot {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(184, 93, 61, 0.16);
  animation: pulse-dot 1.15s ease-in-out infinite;
}

.composer-ticker[data-state="transcribing"] .composer-ticker__dot {
  background: var(--warn);
  box-shadow: 0 0 0 6px rgba(148, 96, 3, 0.14);
}

.composer-ticker[data-state="success"] .composer-ticker__dot {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(35, 106, 76, 0.14);
}

.composer-ticker[data-state="error"] .composer-ticker__dot {
  background: var(--error);
  box-shadow: 0 0 0 6px rgba(157, 53, 53, 0.14);
}

@keyframes pulse-dot {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

@keyframes voice-wave {
  0%,
  100% {
    opacity: 0.5;
    transform: scaleY(0.45);
  }
  30% {
    opacity: 1;
    transform: scaleY(1.5);
  }
  60% {
    opacity: 0.75;
    transform: scaleY(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .composer-ticker[data-state="recording"] .composer-ticker__dot,
  .composer-ticker[data-state="recording"] .composer-wave span {
    animation: none;
    transition: none;
  }

  .composer-ticker[data-state="recording"] .composer-wave span {
    opacity: 0.78;
    transform: scaleY(1);
  }
}

.composer-tips,
.meta-row,
.chip-row,
.linked-list,
.result-match__footer,
.result-match__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hint-pill,
.file-chip,
.warning-chip,
.match-badge,
.match-issue,
.summary-card,
.stat-pill,
.meta-pill,
.chip {
  border-radius: 999px;
}

.hint-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  background: rgba(24, 20, 17, 0.05);
  color: var(--ink-soft);
}

.file-list,
.warning-stack,
.draft-editor,
.results-stack,
.summary-grid,
.draft-chars,
.result-list,
.compact-list {
  display: grid;
  gap: 12px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  padding: 6px 6px 6px 14px;
  background: var(--cool-soft);
  color: var(--cool);
}

.file-chip__name {
  min-width: 0;
  max-width: min(260px, 52vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip__size {
  flex: 0 0 auto;
}

.file-chip__remove {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(69, 97, 105, 0.1);
  color: inherit;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.file-chip__remove:hover,
.file-chip__remove:focus-visible {
  background: rgba(69, 97, 105, 0.18);
  outline: 2px solid rgba(69, 97, 105, 0.24);
  outline-offset: 1px;
}

.action-row,
.draft-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.action-row {
  margin-top: 22px;
}

.action-row--primary {
  margin-top: 4px;
}

.action-row--editor {
  margin-top: 18px;
}

.draft-toolbar {
  justify-content: space-between;
  margin: 18px 0 18px;
}

.lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  margin-top: 18px;
  align-items: center;
}

.ktru-catalog-results,
.ktru-suggestions {
  display: grid;
  gap: 10px;
}

.ktru-catalog-results {
  margin-top: 12px;
}

.ktru-catalog-results[hidden] {
  display: none;
}

.ktru-suggestions {
  margin-top: 10px;
}

.draft-ktru-resolution-slot:empty {
  display: none;
}

.draft-ktru-resolution {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
}

.draft-ktru-resolution--resolved {
  border-color: rgba(35, 106, 76, 0.24);
  background: rgba(35, 106, 76, 0.06);
}

.draft-ktru-resolution--ambiguous,
.draft-ktru-resolution--unresolved {
  border-color: rgba(184, 93, 61, 0.28);
  background: rgba(184, 93, 61, 0.07);
}

.draft-ktru-resolution__head,
.draft-ktru-resolution__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.draft-ktru-resolution__choices {
  align-items: stretch;
}

.ktru-choice-button {
  max-width: 100%;
  justify-content: flex-start;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
}

.catalog-pager {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.catalog-pager[hidden] {
  display: none;
}

.catalog-pager__info {
  color: var(--ink-soft);
  text-align: center;
  font-size: 14px;
}

.lookup-state {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.54);
}

.lookup-state--muted {
  border-style: dashed;
}

.draft-summary {
  margin: 0;
  color: var(--ink-soft);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button--primary {
  background: var(--accent);
  color: #fff8f4;
  box-shadow: 0 12px 30px rgba(184, 93, 61, 0.2);
}

.button--primary:hover {
  background: var(--accent-strong);
}

.button--secondary {
  background: var(--cool);
  color: #eef6f8;
  box-shadow: 0 12px 30px rgba(69, 97, 105, 0.18);
}

.button--ghost {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  border-color: var(--line);
}

.button--ghost.is-active {
  border-color: rgba(69, 97, 105, 0.34);
  background: rgba(69, 97, 105, 0.1);
  color: var(--cool);
}

#liveFeedToggleButton {
  gap: 9px;
  border-color: rgba(69, 97, 105, 0.42);
  background: rgba(255, 255, 255, 0.9);
  color: var(--cool);
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(69, 97, 105, 0.13);
}

#liveFeedToggleButton::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.2s ease;
}

#liveFeedToggleButton[aria-expanded="true"]::after {
  transform: rotate(225deg) translateY(-1px);
}

#liveFeedToggleButton:hover,
#liveFeedToggleButton:focus-visible {
  border-color: rgba(69, 97, 105, 0.64);
  background: rgba(69, 97, 105, 0.12);
  color: var(--cool);
  box-shadow:
    0 12px 28px rgba(69, 97, 105, 0.16),
    0 0 0 4px rgba(69, 97, 105, 0.08);
}

.button--icon {
  gap: 10px;
}

.button--icon.is-recording {
  border-color: rgba(184, 93, 61, 0.28);
  background: rgba(184, 93, 61, 0.08);
  color: var(--accent-strong);
}

.button__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.button__icon svg {
  width: 18px;
  height: 18px;
}

.draft-item,
.ktru-option,
.result-match,
.compact-list__item,
.summary-card,
.log-entry {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fffdf9;
}

.draft-item {
  padding: 20px;
}

.ktru-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
}

.ktru-option--compact {
  grid-template-columns: 1fr;
  padding: 12px;
  background: rgba(255, 253, 249, 0.76);
}

.ktru-option__main,
.ktru-option__actions {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.ktru-option__actions {
  justify-items: end;
}

.ktru-option--compact .ktru-option__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  justify-items: start;
  align-items: center;
}

.ktru-option--compact .link-inline {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
}

.button--small {
  min-height: 38px;
  padding: 7px 13px;
}

.history-list,
.settings-form,
.admin-filters {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.admin-filters {
  grid-template-columns: minmax(180px, 0.9fr) minmax(160px, 0.7fr) minmax(240px, 1fr) auto;
  align-items: end;
}

.admin-summary-panel {
  grid-column: 1 / -1;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.admin-summary-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 249, 0.72);
}

.admin-summary-card__label,
.admin-summary-card span:last-child {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.admin-summary-card strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  color: var(--ink-soft);
  font-weight: 600;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.data-table-shell {
  margin-top: 18px;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
}

.data-table th {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.data-table__title {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.data-table__meta {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.data-table__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-request-preview,
.admin-diagnostics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-width: 0;
}

.admin-request-preview {
  display: grid;
}

.admin-request-preview__item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid rgba(69, 97, 105, 0.16);
  border-radius: var(--radius-sm);
  background: rgba(250, 247, 239, 0.72);
}

.admin-request-preview__item span,
.admin-request-preview__item small {
  overflow-wrap: anywhere;
}

.admin-request-preview__item span {
  font-weight: 700;
}

.admin-request-preview__item small {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
}

.history-item__main {
  min-width: 0;
}

.history-item__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.history-item__meta,
.settings-form__meta {
  margin: 6px 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.history-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.history-item__note {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.history-item__comment {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 249, 0.76);
  color: var(--ink);
  line-height: 1.35;
}

.history-item__comment:focus {
  outline: 2px solid rgba(69, 97, 105, 0.28);
  border-color: rgba(69, 97, 105, 0.45);
}

.history-item__comment-status {
  min-height: 18px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented-control__button {
  padding: 0 18px;
  font-weight: 700;
}

.settings-form__number {
  max-width: 180px;
}

.draft-item__head,
.draft-item__identity,
.result-card__head,
.result-match__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.draft-item__identity {
  align-items: flex-start;
}

.draft-item__index {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(24, 20, 17, 0.06);
  color: var(--ink-soft);
  white-space: nowrap;
}

.draft-item__hint {
  margin-top: 14px;
}

.draft-item__actions {
  margin-top: 14px;
}

.char-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.char-row__source {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--cool-soft);
  color: var(--cool);
  font-size: 13px;
  white-space: nowrap;
}

.status-strip {
  display: flex;
  justify-content: flex-start;
  margin-top: 24px;
}

.status-strip--sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  box-shadow: none;
}

.status-strip.is-success {
  border-color: rgba(35, 106, 76, 0.25);
  background: rgba(255, 252, 245, 0.96);
  color: var(--ok);
}

.status-strip.is-warning {
  border-color: rgba(148, 96, 3, 0.22);
  background: rgba(255, 252, 245, 0.96);
  color: var(--warn);
}

.status-strip.is-error {
  border-color: rgba(157, 53, 53, 0.22);
  background: rgba(255, 252, 245, 0.96);
  color: var(--error);
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

.summary-card {
  padding: 18px;
}

.summary-card__label {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.summary-card__value {
  margin: 10px 0 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0;
}

.live-feed-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.panel--results > .panel__head {
  align-items: center;
}

.live-feed-summary {
  color: var(--ink-soft);
  font-size: 14px;
}

.live-feed-panel[hidden] {
  display: none;
}

.live-feed-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 249, 0.78);
  box-shadow: var(--shadow-soft);
}

.live-feed-panel__head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.live-feed-panel__head h3 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.1;
}

.live-feed-panel .log-list {
  min-height: 72px;
  max-height: 360px;
  padding: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.live-feed-panel .log-list:empty::before {
  content: "Событий пока нет. После запуска подбора здесь появятся шаги обработки.";
  display: block;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.5);
}

.results-intro {
  margin-top: 20px;
  margin-bottom: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.results-intro__title {
  font-size: 22px;
}

.warning-chip {
  padding: 12px 14px;
  border: 1px solid rgba(148, 96, 3, 0.18);
  background: var(--warn-soft);
  color: #7b4d00;
}

.warning-chip--error {
  border-color: rgba(157, 53, 53, 0.18);
  background: var(--error-soft);
  color: #8a2d2d;
}

.stat-pill,
.meta-pill,
.match-badge,
.match-issue,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
}

.stat-pill,
.meta-pill {
  background: rgba(24, 20, 17, 0.05);
  color: var(--ink-soft);
}

.chip {
  background: var(--accent-soft);
  color: var(--accent);
}

.match-badge {
  font-weight: 700;
  border: 1px solid transparent;
}

.match-badge--full {
  border-color: rgba(35, 106, 76, 0.22);
  background: var(--ok-soft);
  color: var(--ok);
}

.match-badge--partial {
  border-color: rgba(148, 96, 3, 0.22);
  background: var(--warn-soft);
  color: #7b4d00;
}

.match-badge--mismatch {
  border-color: rgba(184, 93, 61, 0.28);
  background: rgba(184, 93, 61, 0.12);
  color: #8a3518;
}

.match-badge--missing {
  border-color: rgba(59, 96, 104, 0.18);
  background: rgba(59, 96, 104, 0.08);
  color: #2f555d;
}

.match-badge--exact {
  border-color: rgba(29, 78, 216, 0.18);
  background: rgba(29, 78, 216, 0.08);
  color: #1d4ed8;
}

.match-badge--fallback {
  border-color: rgba(184, 93, 61, 0.2);
  background: var(--accent-soft);
  color: var(--accent);
}

.match-issue {
  background: rgba(148, 96, 3, 0.08);
  color: #7b4d00;
}

.match-issue--mismatch {
  background: rgba(184, 93, 61, 0.1);
  color: #8a3518;
}

.match-issue--missing {
  background: rgba(59, 96, 104, 0.08);
  color: #2f555d;
}

.match-issue--unverified {
  background: rgba(59, 96, 104, 0.1);
  color: #2f555d;
}

.desired-summary {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 249, 0.72);
}

.desired-summary__head,
.desired-summary__preview,
.desired-summary__list {
  display: grid;
  gap: 8px;
}

.desired-summary__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.desired-summary__item {
  color: var(--ink-soft);
  line-height: 1.55;
}

.desired-summary__item strong {
  color: var(--ink);
  font-weight: 700;
}

.desired-summary__source {
  display: inline-flex;
  margin-left: 6px;
  color: var(--cool);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.desired-summary__details {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.desired-summary__details summary {
  cursor: pointer;
  color: var(--cool);
  font-weight: 700;
}

.desired-summary__list {
  margin-top: 10px;
}

.result-card {
  display: grid;
  gap: 18px;
}

.result-card__head h3,
.result-match__head h4,
.compact-list__title {
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.result-card__head h3 {
  font-size: 28px;
  line-height: 1.06;
}

.result-card__section {
  display: grid;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.result-card__section-title {
  margin: 0;
  font-size: 18px;
}

.result-card__section-note,
.result-match__reason,
.compact-list__meta {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.result-match {
  padding: 16px;
  box-shadow: 0 6px 18px rgba(24, 20, 17, 0.03);
}

.result-match__head h4 {
  font-size: 19px;
  line-height: 1.2;
}

.result-match__reason {
  margin-top: 10px;
}

.result-match__issues {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.link-inline {
  color: var(--cool);
  text-decoration: none;
  border-bottom: 1px solid rgba(69, 97, 105, 0.26);
}

.link-inline:hover {
  border-color: rgba(69, 97, 105, 0.55);
}

.code {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(24, 20, 17, 0.06);
  font-family: var(--font-mono);
}

.result-disclosure,
.log-disclosure {
  margin-top: 16px;
}

.result-disclosure summary,
.log-disclosure summary {
  cursor: pointer;
  color: var(--cool);
  font-weight: 600;
  list-style: none;
}

.result-disclosure summary::-webkit-details-marker,
.log-disclosure summary::-webkit-details-marker {
  display: none;
}

.result-disclosure__content {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.compact-list {
  gap: 10px;
}

.compact-list__item {
  padding: 14px 16px;
}

.compact-list__meta {
  margin-top: 8px;
}

.log-panel {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: transparent;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  min-width: 0;
  max-height: 320px;
  overflow: auto;
}

.log-entry {
  position: relative;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 7px 10px;
  align-items: start;
  width: 100%;
  min-width: 0;
  min-height: 68px;
  padding: 12px 12px 12px 14px;
  border-left: 0;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(24, 20, 17, 0.035);
}

.log-entry::before {
  content: "";
  grid-row: 1 / span 2;
  width: 10px;
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--cool);
  box-shadow: 0 0 0 5px rgba(69, 97, 105, 0.07);
}

.log-entry--info {
  background: linear-gradient(90deg, rgba(69, 97, 105, 0.035), rgba(255, 253, 249, 0) 46%), #fffdf9;
}

.log-entry--success {
  background: linear-gradient(90deg, rgba(35, 106, 76, 0.04), rgba(255, 253, 249, 0) 46%), #fffdf9;
}

.log-entry--warning {
  background: linear-gradient(90deg, rgba(148, 96, 3, 0.045), rgba(255, 253, 249, 0) 46%), #fffdf9;
}

.log-entry--error {
  background: linear-gradient(90deg, rgba(157, 53, 53, 0.05), rgba(255, 253, 249, 0) 46%), #fffdf9;
}

.log-entry--success::before {
  background: var(--ok);
  box-shadow: 0 0 0 5px rgba(35, 106, 76, 0.075);
}

.log-entry--warning::before {
  background: var(--warn);
  box-shadow: 0 0 0 5px rgba(148, 96, 3, 0.08);
}

.log-entry--error::before {
  background: var(--error);
  box-shadow: 0 0 0 5px rgba(157, 53, 53, 0.08);
}

.log-entry__meta {
  display: flex;
  flex-wrap: wrap;
  grid-column: 2;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.log-entry__pill {
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid rgba(24, 20, 17, 0.06);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.log-entry__pill--time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.log-entry--info .log-entry__pill--level,
.log-entry--scope-ktru .log-entry__pill--scope,
.log-entry--scope-process .log-entry__pill--scope {
  background: rgba(69, 97, 105, 0.075);
  color: var(--cool);
}

.log-entry--success .log-entry__pill--level,
.log-entry--scope-gisp .log-entry__pill--scope,
.log-entry--scope-done .log-entry__pill--scope {
  background: rgba(35, 106, 76, 0.08);
  color: var(--ok);
}

.log-entry--warning .log-entry__pill--level,
.log-entry--scope-input .log-entry__pill--scope {
  background: rgba(148, 96, 3, 0.08);
  color: #7b4d00;
}

.log-entry--error .log-entry__pill--level {
  background: rgba(157, 53, 53, 0.08);
  color: var(--error);
}

.log-entry--scope-llm .log-entry__pill--scope {
  background: rgba(184, 93, 61, 0.075);
  color: var(--accent-strong);
}

.log-entry__message {
  grid-column: 2;
  margin: 0;
  min-width: 0;
  max-width: 100%;
  line-height: 1.45;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--ink-soft);
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.48);
}

.empty-state--editor {
  min-height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-state--results {
  min-height: 128px;
  display: flex;
  align-items: center;
  border-style: solid;
  background: rgba(255, 253, 249, 0.72);
}

@media (min-width: 1221px) {
  .panel--intake {
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
}

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

  .workspace {
    grid-template-columns: 1fr;
  }

  .panel--intake {
    position: static;
  }

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

@media (max-width: 820px) {
  .page-shell {
    width: min(100%, calc(100% - 20px));
    padding-top: 18px;
  }

  .panel--intake,
  .panel--results {
    padding: 0 18px 18px;
  }

  .panel__head {
    padding: 18px 18px 0;
  }

  .live-feed-controls,
  .live-feed-panel__head {
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .composer-tools {
    grid-template-columns: 1fr;
  }

  .action-row,
  .composer-shell__footer,
  .composer-tools,
  .composer-actions,
  .draft-toolbar,
  .results-intro,
  .live-feed-controls,
  .live-feed-panel__head,
  .draft-item__head,
  .draft-item__identity,
  .result-card__head,
  .result-match__head {
    flex-direction: column;
  }

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

  .lookup-row,
  .catalog-pager,
  .ktru-option,
  .admin-summary-grid,
  .history-item,
  .admin-filters {
    grid-template-columns: 1fr;
  }

  .ktru-option__actions,
  .history-item__actions {
    justify-items: stretch;
    justify-content: stretch;
  }

  .button {
    width: 100%;
    justify-content: center;
  }

  .composer-actions {
    justify-content: stretch;
  }

  .data-table-shell {
    overflow-x: visible;
  }

  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .data-table {
    border: 0;
    background: transparent;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel-strong);
    overflow: hidden;
  }

  .data-table td {
    border-bottom: 1px solid var(--line);
  }

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