/* Общие стили приложения: токены брендбука, основа, общие элементы.
   Палитра — docs/Брендбук.pdf: академічний синій #0B1B3D, сигнальний
   червоний #D32F2F (активный раздел, «зараз»), блакитний #2585B5
   (для мелкого текста — #1F6F98), світло-сірий #F8F9FA.
   Отступы — по сетке 4 px; шрифт 12/14/16/20/24/28; веса 400–600. */

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --raised: #eef1f5;
  --ink: #0b1b3d;
  --muted: #4d586f;
  --line: rgb(11 27 61 / 0.12);
  --line-soft: rgb(11 27 61 / 0.06);
  --field-line: rgb(11 27 61 / 0.24);
  --accent: #0b1b3d;
  --accent-hover: #1d2f58;
  --accent-ink: #ffffff;
  --active: #d32f2f;
  --date: #1f6f98;
  --blue: #2585b5;

  --warn-bg: #fbefd8;
  --warn-ink: #6e4300;
  --warn-edge: #d9a441;
  --err-bg: #fdecea;
  --err-ink: #8f1d14;
  --danger: #c62828;
  --danger-hover: #a91f1f;
  --danger-ink: #b3261e;

  --plate-bg: #e8edf4;
  --plate-ink: #0b1b3d;

  --r-control: 10px;
  --r-nav: 8px;
  --r-card: 16px;
  --r-plate: 6px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --display: "Fixel Display", "Fixel Text", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  font-family: "Fixel Text", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body { margin: 0; min-height: 100dvh; background: var(--bg); }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }

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

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

/* Иконки: пути из lucide (ISC), один размер и одна толщина везде. */
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- кнопки ---------- */

.btn,
.iconbtn,
.topnav-item,
.tab {
  transition:
    background-color 150ms var(--ease),
    border-color 150ms var(--ease),
    color 150ms var(--ease),
    transform 120ms var(--ease);
}
.btn:active,
.iconbtn:active { transform: scale(0.98); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--raised); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--raised); color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-ghost { color: var(--danger-ink); }
.btn-block { width: 100%; min-height: 48px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }

.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.iconbtn:hover { background: var(--raised); }

/* ---------- поля ---------- */

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 14px; font-weight: 500; }
.field-hint { font-size: 14px; color: var(--muted); }
.field-hint.is-ok { color: var(--date); }

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* меньше 16 — iPhone увеличивает страницу при фокусе */
}
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgb(37 133 181 / 0.2); }

.pw { position: relative; display: block; }
.pw .input { padding-right: 52px; }
.pw-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); background: var(--raised); }

.check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }

.alert {
  padding: 12px 14px;
  border-radius: var(--r-control);
  font-size: 14px;
  line-height: 20px;
}
.alert-error { background: var(--err-bg); color: var(--err-ink); }
.alert-warn { background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- карточка, состояния ---------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 64px auto;
  max-width: 28rem;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
}
.state-title { color: var(--ink); font-family: var(--display); font-size: 20px; line-height: 28px; font-weight: 600; }

/* ---------- табличка кабинета (фирменная деталь) ---------- */

.room-plate {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-plate);
  background: var(--plate-bg);
  color: var(--plate-ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  white-space: nowrap;
}

/* ---------- уведомление «Збережено» ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 500;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms var(--ease), transform 150ms var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- карточка поверх экрана (на телефоне — лист снизу) ---------- */

.sheet {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 64px);
  padding: 0;
  border: 0;
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgb(11 27 61 / 0.24);
}
.sheet::backdrop { background: rgb(11 27 61 / 0.4); }
.sheet[open] { display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 0; }
.sheet-close { border-color: transparent; margin: -6px -8px 0 0; }
.sheet-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 20px 20px; overflow-y: auto; }
.sheet-body:focus { outline: none; }
.sheet-title { font-family: var(--display); font-size: 20px; line-height: 28px; font-weight: 600; }
.sheet-actions { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--line-soft); }
.sheet-actions .btn-primary { flex: 1; }
.sheet-confirm { flex-direction: column; background: #fdf3f2; }
.sheet-confirm p { font-size: 14px; }
.sheet-confirm-btns { display: flex; gap: 8px; }

@media (max-width: 767px) {
  .sheet {
    width: 100vw;
    max-width: none;
    margin: auto 0 0;
    max-height: 85dvh;
    border-radius: 16px 16px 0 0;
  }
  .sheet-actions { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* ---------- тумблер ---------- */

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.switch-track {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  border-radius: 13px;
  background: #c6cdd8;
  transition: background-color 150ms var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2);
  transition: transform 150ms var(--ease);
}
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch input:disabled ~ * { opacity: 0.5; cursor: default; }
.switch-label { font-weight: 500; min-width: 64px; }

/* ---------- переключатель из двух-трёх вариантов ---------- */

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-control); background: var(--raised); }
.seg-item { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; text-decoration: none; text-align: center; }
.seg-item[aria-current] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(11 27 61 / 0.12); }
