/* Разборы. Mobile-first: базовые правила для телефона, расширения — в @media. */

:root {
  --text: #222428;
  --muted: #5c6068;
  --border: #d5d8de;
  --field-border: #81868f;
  --surface: #f4f5f7;
  --accent: #0b57d0;
  --accent-hover: #0842a0;
  --accent-soft: #e8f0fe;
  --accent-text: #0a3d8f;
  --danger: #b3261e;
  --danger-soft: #fce8e6;
  --radius: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #fff;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 12px;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 12px;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

.page {
  padding-top: 20px;
  padding-bottom: 48px;
}

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

.text {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Шапка */

.site-header {
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 6px;
  color: var(--text);
  text-decoration: none;
  font: inherit;
}

.nav-link:hover {
  color: var(--accent);
}

.nav-link.is-active {
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 var(--accent);
}

.logout-form {
  margin: 0;
}

.nav-button {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
}

/* Кнопки и поля */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent-hover);
  color: var(--accent-hover);
}

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

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

.btn:disabled,
.btn:disabled:hover {
  border-color: #c4c7cc;
  background: #e3e5e8;
  color: #5c6068;
  cursor: not-allowed;
}

.btn-small {
  padding: 0 14px;
  font-size: 0.94rem;
}

.btn-block {
  width: 100%;
}

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

.field {
  display: block;
  margin: 0 0 20px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="text"],
input[type="password"],
input[type="tel"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-group legend {
  padding: 0;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  cursor: pointer;
}

.choice input {
  width: 22px;
  height: 22px;
  margin: 0;
}

/* Сообщения */

.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.notice-error {
  border: 1px solid #f0b4af;
  background: var(--danger-soft);
  color: var(--danger);
}

.notice-success,
.notice-info {
  border: 1px solid #b6cdf7;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.notice-list {
  margin: 0;
  padding-left: 20px;
}

/* Вход */

.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 24px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.auth-title {
  margin-bottom: 20px;
  text-align: center;
  font-size: 1.6rem;
}

.auth-link {
  margin: 16px 0 0;
  text-align: center;
}

.auth-link a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
}

.field-error {
  display: block;
  margin-top: 6px;
  color: var(--danger);
  font-size: 0.94rem;
  font-weight: 600;
}

.field-action {
  margin-top: 10px;
}

/* Заголовок страницы с кнопкой */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
}

/* Таблицы админки. На узком экране строка превращается в карточку. */

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
}

.table th,
.table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.row-link {
  cursor: pointer;
}

.row-link:hover td {
  background: var(--surface);
}

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

@media (max-width: 639px) {
  .table-cards thead {
    display: none;
  }

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

  .table-cards tr {
    margin-bottom: 12px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .table-cards td {
    display: flex;
    gap: 12px;
    padding: 4px 0;
    border: 0;
  }

  .table-cards td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    color: var(--muted);
    font-size: 0.88rem;
  }

  .table-cards td:empty {
    display: none;
  }
}

/* Экран с паролем */

.credentials {
  margin: 0;
}

.credentials dt {
  color: var(--muted);
  font-size: 0.88rem;
}

.credentials dd {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.credential-value {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.nowrap {
  white-space: nowrap;
}

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

/* Карточка кейса */

.case-head {
  margin-bottom: 16px;
}

.case-meta {
  margin: 0 0 4px;
  color: var(--muted);
}

.photos {
  margin: 0 -16px 8px;
}

.photo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 8px;
  cursor: zoom-in;
}

.case-section {
  margin: 0 0 20px;
}

.case-section h2 {
  margin-bottom: 6px;
}

.case-section p:last-child {
  margin-bottom: 0;
}

.details {
  width: 100%;
  margin: 0 0 20px;
  border-collapse: collapse;
}

.details th,
.details td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.details tr:first-child th,
.details tr:first-child td {
  border-top: 1px solid var(--border);
}

.details th {
  width: 40%;
  padding-right: 12px;
  color: var(--muted);
  font-weight: 400;
}

.cost {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.manager-block {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

/* Админка: карточка и форма кейса */

.admin-case-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.state {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.state-draft {
  background: var(--surface);
  color: var(--muted);
}

.state-published {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.photos-field {
  margin: 8px 0 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.photo-list {
  display: grid;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 0;
  list-style: none;
}

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

.photo-item img {
  width: 120px;
  height: 90px;
  border-radius: 6px;
  object-fit: cover;
}

input[type="file"] {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 0;
  font: inherit;
}

@media (min-width: 640px) {
  .photos {
    margin: 0 0 8px;
  }

  .photo {
    border-radius: 8px;
  }
}

/* Лента механика */

.progress {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

.unread-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

.feed {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.feed-item {
  display: grid;
  gap: 2px;
  margin: 0 0 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.feed-item:hover {
  border-color: var(--field-border);
  color: var(--text);
}

.feed-item.is-unread {
  border-left: 5px solid var(--danger);
}

.feed-item.is-read {
  color: var(--muted);
}

.feed-meta,
.feed-node {
  color: var(--muted);
  font-size: 0.94rem;
}

.feed-title {
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.feed-item.is-read .feed-title {
  font-weight: 600;
}

.badge {
  justify-self: start;
  margin-top: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.badge-unread {
  background: var(--danger);
  color: #fff;
}

.badge-read {
  background: var(--surface);
  color: var(--muted);
}

.empty {
  padding: 32px 0;
  text-align: center;
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
}

/* Ответ механика и сравнение */

.answer,
.compare {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 2px solid var(--border);
}

.answer textarea {
  margin-bottom: 12px;
}

.compare {
  display: grid;
  gap: 16px;
}

.compare-block {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.compare-block.manager-block {
  border-color: #b6cdf7;
}

.compare-date {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (min-width: 640px) {
  .compare {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* Просмотр фото во весь экран */

.photo-viewer {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
}

.photo-viewer::backdrop {
  background: #000;
}

.photo-viewer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewer-close {
  position: fixed;
  top: 8px;
  right: 8px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.inline-form {
  margin: 0;
}

/* Админка: ответы в карточке кейса */

.admin-answers {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 2px solid var(--border);
}

.admin-answers h2 {
  margin-top: 8px;
}

.pending-list {
  margin: 0 0 24px;
  padding-left: 20px;
}

.pending-list li {
  padding: 2px 0;
}

/* Отчёт-матрица: прокручивается вбок, колонка с ФИО закреплена. */

.scroll-hint {
  margin: 0 0 8px;
}

/* Подсказку показывает скрипт, только когда таблица не помещается. */
.scroll-hint[hidden] {
  display: none;
}

.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

.matrix {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
}

.matrix th,
.matrix td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  text-align: center;
  white-space: nowrap;
}

.matrix tbody tr:last-child th,
.matrix tbody tr:last-child td {
  border-bottom: 0;
}

.matrix thead th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.matrix .matrix-name {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 140px;
  max-width: 45vw;
  border-right: 1px solid var(--border);
  text-align: left;
  white-space: normal;
  font-weight: 400;
}

.matrix thead .matrix-name {
  font-weight: 600;
}

.matrix-total {
  font-weight: 600;
}

.matrix-case,
.matrix-cell {
  min-width: 48px;
}

.tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
  text-decoration: none;
}

.tick:hover {
  background: var(--accent-soft);
}

.answer-dialog {
  width: calc(100% - 32px);
  max-width: 560px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
}

.answer-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.answer-dialog form {
  margin: 16px 0 0;
}

/* Админка: страница механика в отчёте */

.back-link {
  margin: 0 0 8px;
}

.back-link a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
}

.mechanic-section {
  margin-top: 24px;
}

.feed-title-link {
  display: grid;
  gap: 2px;
  color: inherit;
  text-decoration: none;
}

.feed-title-link:hover .feed-title {
  color: var(--accent);
}

.mechanic-answer {
  display: block;
  margin-top: 4px;
  color: var(--text);
}
