@import url("tokens.css");

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.site-nav--app {
  width: min(1240px, calc(100% - 40px));
  margin: 16px auto 0;
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 12px auto 20px;
}

.dashboard-nav {
  display: grid;
  gap: 6px;
}

.dashboard-nav .nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition:
    background-color 0.15s var(--ease-out),
    color 0.15s var(--ease-out);
}

.dashboard-nav .nav-link:hover {
  background: var(--bg-soft);
}

.dashboard-nav .nav-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.dashboard-nav .nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.dashboard-panel {
  margin-top: 16px;
}

.dashboard-empty {
  padding: 32px 24px;
  text-align: center;
  color: var(--muted);
}

.dashboard-empty--compact {
  padding: 18px 0 0;
  text-align: left;
}

.dashboard-empty p {
  margin-bottom: 16px;
  max-width: 52ch;
  line-height: 1.55;
}

.dashboard-empty--compact p {
  margin-bottom: 0;
}

.dashboard-empty--compact:not(.dashboard-empty--loading) p {
  max-width: none;
}

.dashboard-empty--loading p {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  color: var(--muted);
}

.dashboard-empty--loading p::before {
  content: "";
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ui-spin 0.75s linear infinite;
}

.dashboard-empty:not(.dashboard-empty--compact) .button {
  margin-top: 4px;
}

.dashboard-table-wrap {
  overflow-x: auto;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

.dashboard-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.dashboard-table tbody tr {
  transition: background-color 0.12s var(--ease-out);
}

.dashboard-table tbody tr:hover {
  background: var(--panel-subtle);
}

.dashboard-table tbody tr:focus-within {
  background: var(--accent-soft);
  outline: none;
}

.table-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-danger {
  color: var(--danger);
  border-color: rgba(164, 61, 50, 0.32);
}

.button-danger:hover:not(:disabled) {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button-danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(164, 61, 50, 0.22);
}

.dashboard-links a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
  border-radius: 2px;
  transition: color 0.15s var(--ease-out);
}

.dashboard-links a:hover {
  text-decoration: underline;
}

.dashboard-links a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(49, 95, 203, 0.22);
}

.dashboard-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.download-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.download-chip {
  color: var(--blue);
  text-decoration: none;
  transition:
    border-color 0.15s var(--ease-out),
    background-color 0.15s var(--ease-out),
    color 0.15s var(--ease-out);
}

.download-chip:hover {
  border-color: rgba(49, 95, 203, 0.38);
  background: var(--blue-soft);
  text-decoration: none;
}

.download-chip:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 203, 0.18);
}

.download-chip:active {
  transform: translateY(1px);
}

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

.status-chip--ok {
  border-color: rgba(22, 115, 77, 0.28);
  background: var(--ok-soft);
  color: var(--ok);
}

.status-chip--danger {
  border-color: rgba(164, 61, 50, 0.32);
  background: var(--danger-soft);
  color: var(--danger);
}

.status-chip--info {
  border-color: rgba(49, 95, 203, 0.32);
  background: var(--blue-soft);
  color: var(--blue);
}

.status-chip--info.is-pending {
  animation: status-pulse 1.8s var(--ease-out) infinite;
}

@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.72;
  }
}

.muted-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
  font-weight: 700;
  text-wrap: balance;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 600;
  text-wrap: balance;
}

p {
  color: var(--muted);
  line-height: 1.5;
  text-wrap: pretty;
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 13px;
  border: 1px solid rgba(22, 115, 77, 0.28);
  border-radius: var(--radius);
  color: var(--ok);
  background: var(--ok-soft);
  font-size: 14px;
  font-weight: 620;
  white-space: nowrap;
}

.layout,
.wizard {
  display: grid;
  gap: 20px;
  padding: 20px 0 10px;
}

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

.panel {
  min-width: 0;
  padding: 22px 22px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.slide {
  display: none;
}

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

.results-panel {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.wizard-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s var(--ease-out),
    background-color 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out);
}

.wizard-step:not(:disabled):hover {
  border-color: var(--line-strong);
  background: var(--panel-subtle);
}

.wizard-step:not(:disabled):focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.wizard-step:not(:disabled):active {
  transform: translateY(1px);
}

.wizard-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: #44546a;
  font-size: 14px;
  font-weight: 750;
}

.wizard-step strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-step.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wizard-step.is-active span,
.wizard-step.is-done span {
  background: var(--accent);
  color: #fff;
}

.wizard-step:disabled {
  cursor: not-allowed;
  opacity: 1;
  color: var(--muted);
  background: var(--panel-subtle);
  border-color: var(--line);
}

.wizard-step:disabled span {
  background: var(--line-strong);
  color: #fff;
}

.global-message {
  margin-top: 14px;
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  color: #34445b;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

input[type="file"] {
  padding: 8px;
}

input::file-selector-button {
  min-height: 28px;
  margin-right: 10px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

input::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

input:user-invalid:not(:focus):not(:placeholder-shown),
select:user-invalid:not(:focus) {
  border-color: rgba(164, 61, 50, 0.45);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 0.12s var(--ease-out),
    border-color 0.15s var(--ease-out),
    background-color 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out);
}

.button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--panel-subtle);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

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

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button-primary:focus-visible {
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.28);
}

.button-secondary {
  width: fit-content;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.template-result {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

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

.preview-box,
.message,
.summary {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-subtle);
  color: #3a4a61;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.message[role="alert"] {
  font-weight: 620;
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.document-preview-wrap {
  display: grid;
  gap: 10px;
}

.document-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.document-preview-head span {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

.document-preview-head small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.document-preview {
  max-height: 560px;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #edf2f7;
}

.doc-page {
  display: grid;
  gap: 8px;
  min-height: 520px;
  max-width: 760px;
  margin: 0 auto;
  padding: 34px 38px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
}

.doc-region {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 7px 9px;
  border: 1px dashed transparent;
  border-radius: 4px;
  background: transparent;
  color: #1f2937;
  font: inherit;
  line-height: 1.4;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.doc-region:hover {
  border-color: rgba(23, 107, 91, 0.62);
  background: var(--accent-soft);
}

.doc-region:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--focus-ring);
}

.doc-region.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.doc-region.is-number-selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.doc-region.is-recommended:not(.is-selected) {
  border-color: #d6a328;
  background: var(--warning-soft);
}

.doc-region.is-number-recommended:not(.is-number-selected) {
  border-color: #8ab3ff;
  background: var(--blue-soft);
}

.doc-part-label {
  margin: 8px 0 2px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  color: #4f6075;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.ticket-preview-card,
.generation-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.ticket-preview-card {
  min-height: 460px;
  padding: 26px 30px;
}

.ticket-preview-head {
  display: grid;
  gap: 6px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.ticket-preview-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.ticket-preview-head strong {
  color: var(--text);
  font-size: 20px;
}

.ticket-preview-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 24px;
  color: #1f2937;
  line-height: 1.55;
}

.ticket-preview-list li {
  padding-left: 4px;
}

.generation-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.doc-paragraph {
  white-space: pre-wrap;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
}

.doc-table td {
  min-width: 120px;
  padding: 0;
  border: 1px solid #aeb8c4;
  vertical-align: top;
}

.doc-cell {
  min-height: 46px;
  border-radius: 0;
}

.message.is-error {
  border-color: rgba(164, 61, 50, 0.32);
  background: var(--danger-soft);
  color: var(--danger);
}

.message.is-ok {
  border-color: rgba(22, 115, 77, 0.28);
  background: var(--ok-soft);
  color: var(--ok);
}

.message.is-warning {
  border-color: rgba(154, 101, 0, 0.28);
  background: var(--warning-soft);
  color: var(--warning);
}

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-list a {
  display: block;
  min-height: 42px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--blue);
  text-decoration: none;
  overflow-wrap: anywhere;
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 1;
  color: var(--muted);
  background: var(--bg-soft);
  border-color: var(--line);
  transform: none;
  box-shadow: none;
}

.button-primary:disabled {
  background: var(--bg-soft);
  color: var(--muted);
  border-color: var(--line);
}

.file-list a {
  transition:
    border-color 0.15s var(--ease-out),
    background-color 0.15s var(--ease-out);
}

.file-list a:hover {
  border-color: rgba(49, 95, 203, 0.45);
  background: var(--blue-soft);
}

.file-list a:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 95, 203, 0.18);
}

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

@media (max-width: 820px) {
  .page-shell {
    width: calc(100% - 20px);
    margin: 10px auto 16px;
  }

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

  .wizard-nav,
  .template-controls,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .document-preview {
    padding: 10px;
  }

  .document-preview-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .document-preview-head small {
    text-align: left;
  }

  .doc-page {
    min-height: 420px;
    padding: 20px 18px;
  }

  .layout,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .dashboard-table {
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  .dashboard-table thead {
    display: none;
  }

  .dashboard-table tbody,
  .dashboard-table tr,
  .dashboard-table td {
    display: block;
  }

  .dashboard-table tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
  }

  .dashboard-table td {
    padding: 0;
    border-bottom: 0;
  }

  .dashboard-table td + td {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .dashboard-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: 0;
  }

  .dashboard-table td[data-label="Комплект"]::before,
  .dashboard-table td[data-label="Название"]::before {
    display: none;
  }

  .table-row-actions {
    display: grid;
  }

  .table-row-actions .button {
    width: 100%;
  }
}
