@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=Playfair+Display:wght@500;600&display=swap');

:root {
  --bg-cream: #f4efe4;
  --bg-card: #ffffff;
  --bg-dark: #0d2f2f;
  --ink: #162020;
  --muted: #5f6b6a;
  --accent: #e07a5f;
  --accent-deep: #c96a52;
  --accent-soft: #f6d3c6;
  --teal: #2f6f6b;
  --teal-soft: #d3e7e3;
  --blue-soft: #dce6f5;
  --green-soft: #e4f2d8;
  --gray-soft: #ececec;
  --shadow: 0 24px 60px rgba(15, 32, 31, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #f9f0e1 0%, var(--bg-cream) 45%, #e7efe9 100%);
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: "Playfair Display", serif;
  margin: 0 0 12px;
}

a {
  color: inherit;
  text-decoration: none;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: linear-gradient(140deg, rgba(13, 47, 47, 0.08), rgba(224, 122, 95, 0.08));
  pointer-events: none;
  z-index: -1;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  padding: 20px 32px;
  background: rgba(255, 255, 255, 0.75);
  border-bottom: 1px solid rgba(13, 47, 47, 0.12);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--bg-dark);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.brand-title {
  font-size: 20px;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(47, 111, 107, 0.25);
  background: #fff;
  font-size: 13px;
  color: var(--teal);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: var(--shadow);
}

.user-name {
  font-weight: 600;
}

.link {
  color: var(--teal);
  font-size: 13px;
}

.container {
  padding: 28px 32px 48px;
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel.panel-gray {
  background: var(--gray-soft);
}

.panel.panel-blue {
  background: var(--blue-soft);
}

.panel.panel-green {
  background: var(--green-soft);
}

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

.flash {
  background: var(--accent-soft);
  color: #5f2d1f;
  border-radius: 12px;
  padding: 10px 14px;
}

.flash-success {
  background: #dff3e1;
  color: #1f6e3d;
}

.flash-error {
  background: #f6d3c6;
  color: #8a2f1f;
}

.flash-info {
  background: #e5eef8;
  color: #244b6b;
}

.stage-list-panel {
  overflow: hidden;
}

.stage-table {
  display: grid;
  gap: 8px;
}

.stage-row {
  display: grid;
  grid-template-columns: 0.5fr 2fr 3fr 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.68);
  border-radius: 12px;
}

.stage-head {
  background: rgba(47, 111, 107, 0.12);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stage-row-disabled {
  background: rgba(225, 225, 225, 0.8);
  color: #7b8382;
}

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 2fr) minmax(220px, 1fr);
}

.stage-preview {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  padding: 14px;
}

.stage-preview-title {
  font-weight: 600;
}

.meta {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.meta-label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.meta-value {
  font-weight: 600;
  font-size: 16px;
}

.form {
  display: grid;
  gap: 12px;
}

.form.compact {
  margin-top: 10px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d3d9d7;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}

textarea {
  resize: vertical;
}

input[type="radio"],
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.button {
  border: none;
  border-radius: 12px;
  padding: 9px 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}

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

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

.button.secondary {
  background: var(--teal);
  color: #fff;
}

.button.ghost {
  background: transparent;
  border: 1px solid #cfd8d4;
  color: var(--ink);
}

.button-disabled {
  background: #d9dcdb;
  color: #6f7675;
  cursor: default;
  pointer-events: none;
}

.training-grid,
.validation-grid,
.user-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.rules,
.results-list,
.table {
  display: grid;
  gap: 8px;
}

.rule-item,
.result-item,
.validation-card,
.metric,
.table-row {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 10px 12px;
}

.rule-item {
  border: 1px solid #d7e6fa;
}

.metric {
  border: 1px solid #f0dfd1;
}

.metric-label {
  font-size: 12px;
  color: var(--muted);
}

.metric-value {
  font-size: 22px;
  font-weight: 600;
}

.metric-value.small {
  font-size: 13px;
  font-weight: 500;
}

.table-header,
.table-row {
  display: grid;
  align-items: center;
  gap: 10px;
  grid-template-columns: 0.8fr 2fr 1fr 1fr;
}

.table-header {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.03em;
  padding: 0 6px;
}

.user-grid .table-header,
.user-grid .table-row {
  grid-template-columns: 1fr 1fr 1fr;
}

.phrase-table-head,
.phrase-table-row {
  grid-template-columns: 84px minmax(360px, 1fr) 120px;
}

.phrase-table-row {
  align-items: start;
}

.phrase-cell {
  display: grid;
  gap: 8px;
}

.phrase-file {
  font-weight: 500;
  word-break: break-word;
}

.phrase-actions .button {
  font-size: 12px;
  padding: 7px 10px;
}

.validation-card {
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.stage1-tool-card {
  margin-top: 16px;
}

.result-text-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.result-pre {
  margin: 8px 0 0;
  max-height: 520px;
  overflow: auto;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.86);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.45;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
}

.construction-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.construction-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  padding: 8px 10px;
}

.construction-no {
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

.construction-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.yandex-mode-card {
  margin-bottom: 10px;
}

.mode-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 20, 0.46);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 20px;
}

.modal-backdrop.active {
  display: flex;
}

.modal-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 14px;
}

.modal-panel-small {
  width: min(520px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.stage1-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 14px;
}

.compare-head,
.compare-row {
  display: grid;
  grid-template-columns: 68px minmax(220px, 1fr) minmax(220px, 1fr) 92px;
  gap: 0;
  min-width: 720px;
}

.compare-head {
  margin-top: 14px;
  background: rgba(47, 111, 107, 0.12);
  border-radius: 12px 12px 0 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.compare-head > div {
  padding: 9px 10px;
}

.compare-scroll {
  max-height: 320px;
  overflow: auto;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 255, 255, 0.72);
}

.compare-scroll.compact {
  max-height: 260px;
}

.compare-row {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.compare-cell {
  padding: 9px 10px;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  white-space: pre-wrap;
  word-break: break-word;
}

.compare-cell:last-child {
  border-right: none;
}

.compare-cell.no {
  text-align: center;
  font-weight: 600;
}

.compare-cell.status {
  text-align: center;
  font-weight: 600;
}

.compare-cell.status.match {
  color: #1f6e3d;
}

.compare-cell.status.mismatch {
  color: #9b5f00;
}

.inline {
  margin: 0;
}

.actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
}

.actions-inline .inline,
.actions-inline > .button {
  width: auto;
}

.actions-inline .button {
  width: auto;
}

.hidden {
  display: none;
}

.paired-table {
  display: grid;
  grid-template-columns: 76px 88px minmax(240px, 1fr) minmax(240px, 1fr);
  gap: 0;
  min-width: 920px;
}

.paired-head {
  background: rgba(47, 111, 107, 0.12);
  border-radius: 12px 12px 0 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.paired-head > div {
  padding: 10px 12px;
}

.paired-scroll {
  max-height: 520px;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 255, 255, 0.72);
}

.paired-row {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.paired-cell {
  margin: 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.paired-cell:last-child {
  border-right: none;
}

.paired-cell.no,
.paired-cell.id {
  text-align: center;
  font-weight: 600;
}

.paired-cell.raw {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 12px;
  border-left: 1px dashed rgba(0, 0, 0, 0.15);
}

.paired-cell.plain {
  background: rgba(255, 255, 255, 0.92);
}

.paired-cell.raw {
  background: rgba(244, 249, 255, 0.92);
}

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

.login-body {
  background: linear-gradient(160deg, #f8efe1, #f0f5ef);
}

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

.login-card {
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 420px;
  width: 100%;
  display: grid;
  gap: 16px;
}

.login-brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.hint {
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 960px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: center;
  }

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

  .stage-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

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

  .topbar {
    padding: 14px;
  }

  .header-actions,
  .user-chip {
    width: 100%;
    justify-content: center;
  }

  .table-header,
  .table-row,
  .user-grid .table-header,
  .user-grid .table-row {
    grid-template-columns: 1fr;
  }

  .compare-scroll {
    max-width: 100%;
  }

  .paired-scroll {
    max-width: 100%;
  }
}
