:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a1f26;
  --muted: #5c6672;
  --border: #e2e6ea;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.1);
  --radius: 14px;
  --bottom-nav-h: 4.25rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  color-scheme: light only;
}

/* Якщо в системі увімкнено темну тему — не даємо браузеру змінити палітру сторінки */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1a1f26;
    --muted: #5c6672;
    --border: #e2e6ea;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --accent-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.08);
    --ok: #15803d;
    --ok-soft: rgba(21, 128, 61, 0.1);
    color-scheme: light only;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light only;
  background-color: #f4f6f8;
}

body {
  margin: 0;
  font-family: var(--font);
  background-color: #f4f6f8;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ——— Top header: більший відступ зверху (зона статус-бару) ——— */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-bottom: 0.85rem;
  padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  min-height: calc(3.25rem + env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar--client {
  justify-content: center;
}

.topbar--client .brand {
  font-size: 1.15rem;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; color: var(--accent); }

.nav--top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  font-size: 0.875rem;
}

.nav--top a {
  color: var(--text);
  padding: 0.35rem 0;
}
.nav--top a:hover { color: var(--accent); text-decoration: none; }
.nav--top a.muted { color: var(--muted); }

/* ——— Main: відступ під нижню навігацію клієнта ——— */
.wrap {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1rem 1rem 1.25rem;
  animation: contentFade 0.28s ease-out;
}

@keyframes contentFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .wrap { animation: none; }
}

.wrap--bottom-nav {
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 0.75rem);
}

/* Логін: контент по центру екрана */
body.page-login {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

body.page-login .topbar {
  flex-shrink: 0;
}

body.page-login .wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
  max-width: 22rem;
}

body.page-login .wrap .card {
  margin-bottom: 0;
  box-shadow: var(--shadow-md);
}

/* ——— Bottom navigation (клієнт) ——— */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  min-height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.25rem 0.55rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item .bottom-nav__icon {
  opacity: 0.65;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.bottom-nav__item:hover {
  color: var(--accent);
  text-decoration: none;
}

.bottom-nav__item:hover .bottom-nav__icon {
  opacity: 1;
}

.bottom-nav__item:active {
  transform: scale(0.96);
}

.bottom-nav__item.is-active {
  color: var(--accent);
}

.bottom-nav__item.is-active .bottom-nav__icon {
  opacity: 1;
  transform: scale(1.06);
}

.bottom-nav__item--logout {
  color: var(--muted);
}

.bottom-nav__item--logout:hover {
  color: var(--danger);
}

.bottom-nav__item--logout.is-active {
  color: var(--muted);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card h1 { font-size: 1.35rem; margin: 0 0 0.6rem; font-weight: 700; letter-spacing: -0.02em; }
.card h2 { font-size: 1.05rem; margin: 1rem 0 0.5rem; font-weight: 600; }

.lead { color: var(--muted); font-size: 0.95rem; margin: 0 0 1rem; }

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}
.hint code {
  font-size: 0.8rem;
  word-break: break-all;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.flash {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--danger-soft); color: var(--danger); }

.stack { display: flex; flex-direction: column; gap: 0.65rem; }
.stack label { font-size: 0.85rem; color: var(--muted); }

.input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  min-height: 48px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.btn:hover { filter: none; text-decoration: none; border-color: #cdd5dc; }
.btn:active { transform: scale(0.98); }

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

.btn-ghost { border-style: dashed; color: var(--muted); background: transparent; }

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.25);
  color: var(--danger);
}

.btn-small { min-height: 40px; padding: 0.45rem 0.75rem; font-size: 0.9rem; }
.btn-block { width: 100%; }

.sep { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.list { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.9rem; }

.list-lines { list-style: none; padding: 0; margin: 0; }
.list-lines li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}
.list-lines li:last-child { border-bottom: none; }

.plate {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--bg);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.row-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
.row-line:last-child { border-bottom: none; }

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

.inline-form { display: inline; margin: 0; }

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

.plan-option {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  margin-bottom: 0.5rem;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.plan-option:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.plan-option input { margin-top: 0.25rem; }

.check-line {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.check-line input { margin-top: 0.35rem; }
.check-line.legal { color: var(--muted); font-size: 0.85rem; line-height: 1.45; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: var(--bg);
  margin-left: 0.35rem;
  color: var(--muted);
}

.link-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tile {
  display: block;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.tile:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.tile:active { transform: translateY(0); }

.user-row {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
@media (min-width: 480px) {
  .user-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.role-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.role-form .input { width: auto; min-width: 8rem; }

.text-center { text-align: center; }
.qr-box {
  display: inline-block;
  padding: 0.75rem;
  background: #fff;
  border-radius: var(--radius);
  margin: 0.5rem 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.qr-img { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 auto; }

.break-all { word-break: break-all; font-size: 0.75rem; }
