/* Веб-интерфейс учёта смен: одна таблица стилей, без внешних ресурсов (CSP default-src 'self'). */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --line: #d9dee5;
  --accent: #1f5fbf;
  --accent-dark: #174a96;
  --ok-bg: #e7f5ec;
  --ok-text: #1d6b3a;
  --error-bg: #fdecea;
  --error-text: #a3261b;
  --warn-bg: #fff4d6;
  --warn-text: #7a5200;
  --radius: 6px;
}

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

html {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

body {
  margin: 0;
}

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

h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

h2 {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.15rem;
}

.hidden {
  display: none;
}

/* Шапка */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin-left: auto;
  font-size: 0.9rem;
}

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

.who form {
  margin: 0;
}

/* Страница */

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.page-narrow {
  max-width: 26rem;
}

/* График: месяц (до 31 столбца) не помещается в обычную ширину страницы. */
.page-wide {
  max-width: none;
}

.hint,
.empty {
  color: var(--muted);
}

.hint {
  font-size: 0.9rem;
}

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

.alert {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.alert-error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* Формы */

.form {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field > span {
  font-size: 0.9rem;
  font-weight: 600;
}

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

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.button {
  justify-self: start;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

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

.link {
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}

/* Таблицы */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table th,
.table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

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

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

/* Разделы, заголовок страницы */

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.nav a {
  padding: 0.15rem 0;
  color: var(--text);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.nav a:hover,
.nav a.active {
  border-bottom-color: var(--accent);
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.head h1 {
  margin: 0;
}

.crumbs {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.list {
  margin: 0;
  padding-left: 1.2rem;
}

.num {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-bottom: 1rem;
}

.tabs a {
  padding: 0.2rem 0;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.tabs a.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

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

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  font-size: 0.8rem;
  white-space: nowrap;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.badge-warn {
  color: var(--warn-text);
  background: var(--warn-bg);
  border-color: transparent;
}

.badge-ok {
  color: var(--ok-text);
  background: var(--ok-bg);
  border-color: transparent;
}

.alert-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.alert p,
.alert ul {
  margin: 0 0 0.4rem;
}

.alert :last-child {
  margin-bottom: 0;
}

.secret {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.15rem;
  user-select: all;
}

/* Формы справочников */

.form-wide {
  max-width: 44rem;
}

.form h2 {
  margin: 0.5rem 0 0;
}

.form h2:first-of-type {
  margin-top: 0;
}

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
  align-items: start; /* поле без подсказки не растягивается под соседнее с подсказкой */
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field legend {
  padding: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 400;
}

.check input {
  margin-top: 0.3rem;
}

input[type="time"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="search"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--muted);
  background: var(--bg);
}

.field-error input,
.field-error select,
.field-error textarea {
  border-color: var(--error-text);
}

.field small.error {
  color: var(--error-text);
}

.button-secondary {
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
}

.button-secondary:hover {
  color: #ffffff;
}

.button-danger {
  background: var(--error-text);
}

.button-danger:hover {
  background: #7d1d15;
}

a.button {
  display: inline-block;
  text-decoration: none;
}

.panel {
  display: grid;
  gap: 0.75rem;
  max-width: 44rem;
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel h2 {
  margin: 0;
}

.panel p {
  margin: 0;
}

.panel form:not(.inline) {
  display: grid;
  gap: 0.75rem;
  justify-items: start;
}

.inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.inline .field {
  flex: 1 1 12rem;
}

/* Смена: сведения, фото отметок, несогласия */

.panel-wide {
  max-width: none;
  margin-top: 0;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.6rem 1.5rem;
  margin: 0;
}

.facts dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

.thumb {
  display: block;
  width: 6rem;
  height: 4.5rem;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quote {
  padding-left: 0.75rem;
  white-space: pre-wrap;
  border-left: 3px solid var(--line);
}

.queue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.queue a {
  text-decoration: none;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.filters .check {
  align-self: center;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.interval {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.interval input {
  width: 8rem;
}

.interval small.error {
  flex-basis: 100%;
  color: var(--error-text);
}

input.short {
  max-width: 10rem;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#shift-filters.htmx-request ~ #shift-results {
  opacity: 0.5;
}

/* Отбор над таблицей */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filters .field {
  flex: 1 1 10rem;
}

/* График работ: крановщики × дни месяца */

.grid-wrap {
  overflow-x: auto;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.grid th,
.grid td {
  padding: 0;
  text-align: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.grid thead th {
  padding: 0.3rem 0.2rem;
  min-width: 3rem;
  font-weight: 600;
  color: var(--muted);
  scroll-margin-left: 14rem;
  scroll-margin-top: 5rem; /* над таблицей остаётся видно «Сохранено» */
}

.grid thead th small {
  display: block;
  font-weight: 400;
}

.grid .grid-name {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 11rem;
  max-width: 14rem;
  padding: 0.3rem 0.6rem;
  text-align: left;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
}

.grid thead .grid-name {
  font-weight: 600;
  color: var(--muted);
}

.grid-weekend {
  background: var(--bg);
}

.grid thead .grid-today,
.grid td.grid-today {
  background: var(--warn-bg);
}

.cell {
  display: block;
  min-height: 2.4rem;
  padding: 0.3rem 0.15rem;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.cell:hover,
.cell:focus-visible {
  background: var(--ok-bg);
}

.cell-started {
  color: var(--ok-text);
  font-weight: 600;
}

.cell-add {
  color: #9aa5b4;
}

.cell-add:hover,
.cell-add:focus-visible {
  color: var(--accent);
}

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

.cell-mark {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 5rem;
  margin: 0 auto;
}

.cell-warn {
  color: var(--warn-text);
}

@media (max-width: 40rem) {
  .who {
    margin-left: 0;
  }

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

  .grid .grid-name {
    min-width: 7.5rem;
    max-width: 9rem;
  }
}
