/* LSPD vezérlőpult
   Flat, neutral, strict. No gradients, no shadows, no glow, no decorative
   accent. Colour appears only where it carries meaning: data marks and status. */

:root {
  --bg: #0d0d0d;
  --surface: #141414;
  --surface-2: #1a1a19;
  --surface-3: #222221;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);

  --text: #f4f4f2;
  --text-2: #c3c2b7;
  --muted: #898781;

  /* Chart chrome and the single data hue (validated on #1a1a19). */
  --grid: #2c2c2a;
  --axis: #383835;
  --data: #3987e5;

  /* Status — only ever shown next to a word. */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;

  --r: 4px;
  --r-lg: 6px;
  --sidebar-w: 232px;
  --bar-h: 56px;

  /* z-index scale: sticky 10, sidebar 20, scrim 30, drawer 35, modal 40, toast 50.
     The off-canvas drawer has to sit ABOVE the scrim, otherwise taps on the
     mobile menu land on the overlay instead of the links. */
  --z-sticky: 10;
  --z-sidebar: 20;
  --z-scrim: 30;
  --z-drawer: 35;
  --z-modal: 40;
  --z-toast: 50;

  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

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

html {
  color-scheme: dark;
}

/* Hidden elements carry classes that set `display`; a class beats the UA
   [hidden] rule, so this one has to be explicit. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Stops iOS/Android from reflowing text at its own scale in landscape. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-wrap: break-word;
}

/* Touch devices get bigger hit areas without changing the desktop density. */
@media (pointer: coarse) {
  .btn {
    min-height: 40px;
  }

  .btn--sm {
    min-height: 36px;
    padding: 0 12px;
  }

  .btn--icon {
    width: 36px;
  }

  .nav__link,
  .docs__link {
    min-height: 44px;
  }

  .seg button {
    min-height: 38px;
  }

  .role button {
    width: 24px;
    height: 24px;
  }

  input[type="text"],
  input[type="number"],
  input[type="search"],
  select {
    min-height: 40px;
  }

  /* Anything under 16px makes iOS zoom the page when the field is focused. */
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

a {
  color: var(--text);
  text-decoration-color: var(--line-2);
  text-underline-offset: 3px;
}

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

svg.i {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--data);
  outline-offset: 1px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: var(--z-toast);
  padding: 8px 12px;
  background: var(--text);
  color: var(--bg);
}

.skip-link:focus {
  left: 8px;
  top: 8px;
}

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

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

/* ----------------------------------------------------------------- crest */

/* The faction seal is the only full-colour element in the chrome, so it stays
   small and unadorned — no ring, no shadow, no backing plate. */
.crest {
  width: 28px;
  height: 28px;
  flex: none;
  object-fit: contain;
}

.crest--lg {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
}

/* ------------------------------------------------------------------ login */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login__card {
  width: min(360px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.login__card h1 {
  font-size: 18px;
}

.login__card p {
  margin: 6px 0 24px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ shell */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg);
  z-index: var(--z-sidebar);
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--bar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar__head strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__head span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.nav__group {
  padding: 16px 8px 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.nav__group:first-child {
  padding-top: 8px;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.nav__link span {
  flex: 1;
  min-width: 0;
}

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

.nav__link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav__link.is-active {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 500;
}

.nav__link.is-active .i {
  color: var(--text);
}

.nav__count {
  min-width: 20px;
  padding: 0 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.nav__count:empty {
  display: none;
}

.sidebar__foot {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: grid;
  gap: 10px;
}

.botline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.me {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.me img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.me span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

/* ------------------------------------------------------------------- main */

.main {
  min-width: 0;
}

.main:focus {
  outline: none;
}

.pagebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--bar-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.pagebar h1 {
  font-size: 15px;
}

.pagebar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagebar__menu {
  display: none;
}

.content {
  padding: 24px;
  max-width: 1400px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lead {
  color: var(--muted);
  max-width: 80ch;
}

/* ------------------------------------------------------------------ cards */

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  min-width: 0;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.card__head h2 {
  font-size: 13px;
}

.card__head .sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.card__head .end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card__body {
  padding: 16px;
}

.card__body + .card__body {
  border-top: 1px solid var(--line);
}

.card__body--flush {
  padding: 0;
}

.card__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

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

.grid--main {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: start;
}

.grid--duty {
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* --------------------------------------------------------------- KPI strip */

/* One bordered strip with hairline dividers reads as a single instrument. */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}

.kpi {
  padding: 16px;
  border-right: 1px solid var(--line);
  margin-right: -1px;
}

.kpi__label {
  font-size: 12px;
  color: var(--muted);
}

.kpi__value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.kpi__note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.btn--primary:hover:not(:disabled) {
  background: #d9d9d6;
  border-color: #d9d9d6;
}

.btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

.btn--quiet:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  color: #f07a7a;
}

.btn--danger:hover:not(:disabled) {
  border-color: var(--critical);
  background: rgba(208, 59, 59, 0.12);
}

.btn--danger-solid {
  background: var(--critical);
  border-color: var(--critical);
  color: #fff;
}

.btn--danger-solid:hover:not(:disabled) {
  background: #b83131;
  border-color: #b83131;
}

.btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn--icon {
  width: 28px;
  padding: 0;
}

.btn--block {
  width: 100%;
  height: 36px;
}

.btn.is-busy {
  color: transparent !important;
  position: relative;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--line-2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn--primary.is-busy::after {
  border-color: rgba(0, 0, 0, 0.2);
  border-top-color: var(--bg);
}

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

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

td .row {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

/* ----------------------------------------------------------------- forms */

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}

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

input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea {
  height: auto;
  min-height: 140px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.6;
}

.mono,
textarea.mono,
code {
  font-family: var(--mono);
  font-size: 12.5px;
}

select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23898781' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--text-2);
}

input::placeholder,
textarea::placeholder {
  color: #5f5e5a;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  cursor: pointer;
  user-select: none;
  color: var(--text-2);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch i {
  position: relative;
  width: 30px;
  height: 18px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface-3);
  flex: none;
  transition: background-color 0.12s, border-color 0.12s;
}

.switch i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.12s, background-color 0.12s;
}

.switch input:checked + i {
  background: var(--text);
  border-color: var(--text);
}

.switch input:checked + i::after {
  transform: translateX(12px);
  background: var(--bg);
}

.switch input:focus-visible + i {
  outline: 2px solid var(--data);
  outline-offset: 1px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.search .i {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.search input {
  padding-left: 30px;
}

.toolbar select {
  width: auto;
  min-width: 170px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  overflow: hidden;
}

.seg button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--line-2);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.seg button:last-child {
  border-right: 0;
}

.seg button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.seg button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 500;
}

/* ---------------------------------------------------------------- tables */

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

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

th,
td {
  height: 44px;
  padding: 8px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

th {
  height: 36px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  background: var(--surface);
}

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

tbody tr:hover td {
  background: var(--surface-2);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 24px;
  margin: 0;
}

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

.kv dd {
  margin: 0;
  text-align: right;
}

code {
  color: var(--text);
}

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

.sec {
  color: var(--text-2);
}

.small {
  font-size: 12px;
}

.nowrap {
  white-space: nowrap;
}

.truncate {
  display: block;
  max-width: 36ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.person img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: none;
}

.person__text {
  min-width: 0;
}

.person__name {
  font-weight: 500;
}

/* --------------------------------------------------------------- labels */

.label {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
}

/* Status: a small square plus the word — never colour alone. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--muted);
  flex: none;
}

.status--good::before {
  background: var(--good);
}
.status--warning::before {
  background: var(--warning);
}
.status--critical::before {
  background: var(--critical);
}

.roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.role::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chip, var(--muted));
}

.role button {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-right: -4px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.role button:hover {
  color: var(--text);
  background: var(--surface-3);
}

.role button .i {
  width: 10px;
  height: 10px;
  stroke-width: 2;
}

/* ------------------------------------------------------- empty / loading */

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.loading {
  padding: 40px 16px;
  color: var(--muted);
}

.note {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text-2);
}

/* ------------------------------------------------------------ task list */

.tasks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tasks li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}

.tasks li:last-child {
  border-bottom: 0;
}

.tasks li > span {
  flex: 1;
  min-width: 0;
}

/* ---------------------------------------------------------------- charts */

.chart {
  position: relative;
  padding: 16px 16px 12px;
}

.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart text {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart text.value {
  fill: var(--text);
  font-weight: 500;
}

.chart .hit {
  fill: transparent;
  cursor: default;
}

.chart .bar {
  fill: var(--data);
}

.chart .col.is-dim .bar {
  opacity: 0.45;
}

.tooltip {
  position: absolute;
  z-index: 5;
  padding: 6px 9px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface-3);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 8px));
}

.tooltip b {
  font-weight: 600;
}

.hbars {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.hbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
}

.hbar__label {
  color: var(--text-2);
}

.hbar__value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.hbar__track {
  grid-column: 1 / -1;
  height: 8px;
}

.hbar__fill {
  height: 8px;
  min-width: 0;
  background: var(--data);
  border-radius: 0 4px 4px 0;
}

/* ------------------------------------------------------------------ duty */

.duty-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

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

/* ----------------------------------------------------------------- modal */

.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
}

.modal--wide {
  width: min(880px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--line);
}

.modal__head h2 {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal__body {
  padding: 20px;
  overflow-y: auto;
  max-height: min(64vh, 620px);
}

.modal__body > .card + .card {
  margin-top: 12px;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}

.modal__foot:empty {
  display: none;
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: var(--z-toast);
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface-3);
}

.toast.status {
  display: flex;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  background: rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------- szabályzat oldal */

.docs-body {
  background: var(--bg);
}

.docs {
  --docs-bar-h: 60px;
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  grid-template-rows: var(--docs-bar-h) 1fr;
  grid-template-areas: "bar bar" "nav main";
  min-height: 100vh;
  min-height: 100dvh;
}

.docs__bar {
  grid-area: bar;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.docs__menu {
  display: none;
}

.docs__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}

.docs__brand .crest {
  width: 32px;
  height: 32px;
}

.docs__brand strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.docs__brand em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.docs__nav {
  grid-area: nav;
  position: sticky;
  top: var(--docs-bar-h);
  align-self: start;
  height: calc(100vh - var(--docs-bar-h));
  height: calc(100dvh - var(--docs-bar-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding-bottom: 32px;
  background: var(--bg);
  z-index: var(--z-sidebar);
}

.docs__search {
  position: sticky;
  top: 0;
  padding: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.docs__group {
  padding: 20px 20px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs__link {
  display: block;
  padding: 7px 20px 7px 19px;
  border-left: 2px solid transparent;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.4;
}

.docs__link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.docs__link.is-active {
  color: var(--text);
  border-left-color: var(--text);
  background: var(--surface-2);
  font-weight: 500;
}

.docs__empty {
  padding: 24px 20px;
  color: var(--muted);
  font-size: 13px;
}

.docs__main {
  grid-area: main;
  min-width: 0;
}

.docs__main:focus {
  outline: none;
}

.docs__article {
  max-width: 76ch;
  padding: 40px 40px 80px;
}

.doc__eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.doc__head h1 {
  margin-top: 8px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.doc__lead {
  margin-top: 12px;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.doc__meta {
  margin-top: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.doc__toc {
  margin: 28px 0;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.doc__toc p {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.doc__toc ol {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

.doc__toc a {
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
}

.doc__toc a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* The reading column: generous line height, restrained rhythm. */
.doc__body {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-2);
}

.doc__h2 {
  position: relative;
  margin: 40px 0 14px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 19px;
  color: var(--text);
}

.doc__h3 {
  position: relative;
  margin: 28px 0 10px;
  font-size: 15.5px;
  color: var(--text);
}

.doc__body > *:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.doc__anchor {
  position: absolute;
  left: -26px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--muted);
  transition: opacity 0.12s;
}

.doc__h2 .doc__anchor {
  top: auto;
  bottom: 4px;
  transform: none;
}

.doc__h2:hover .doc__anchor,
.doc__h3:hover .doc__anchor,
.doc__anchor:focus-visible {
  opacity: 1;
}

.doc__body p {
  margin: 14px 0;
}

.doc__body ul,
.doc__body ol {
  margin: 14px 0;
  padding-left: 24px;
  display: grid;
  gap: 7px;
}

.doc__body li {
  padding-left: 4px;
}

.doc__body li::marker {
  color: var(--muted);
}

.doc__body strong {
  color: var(--text);
  font-weight: 600;
}

.doc__body blockquote {
  margin: 20px 0;
  padding: 14px 20px;
  border-left: 2px solid var(--line-2);
  background: var(--surface);
  border-radius: 0 var(--r) var(--r) 0;
  color: var(--text);
  font-size: 15.5px;
}

.doc__body .table-wrap {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.doc__body table {
  font-size: 13.5px;
}

.doc__body th,
.doc__body td {
  height: 38px;
  padding: 6px 16px;
}

.doc__body td:first-child {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  width: 1%;
}

@media print {
  .docs__bar,
  .docs__nav,
  .doc__toc,
  .doc__anchor {
    display: none !important;
  }

  .docs {
    display: block;
  }

  .docs__article {
    max-width: none;
    padding: 0;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1180px) {
  .grid--main,
  .grid--duty {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1000px) {
  .docs {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "bar" "main";
  }

  .docs__menu {
    display: inline-flex;
  }

  .docs__nav {
    position: fixed;
    inset: var(--docs-bar-h) auto 0 0;
    width: min(296px, 86vw);
    /* Above the scrim, or taps land on the overlay instead of the links. */
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }

  .docs__nav.is-open {
    transform: none;
  }

  .docs__article {
    padding: 28px 20px 64px;
  }

  .doc__head h1 {
    font-size: 25px;
  }

  .doc__anchor {
    display: none;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-w), 86vw);
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }

  .sidebar.is-open {
    transform: none;
  }

  .pagebar__menu {
    display: inline-flex;
  }

  .pagebar,
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .content {
    padding-top: 16px;
  }

  .grid,
  .panel {
    gap: 12px;
  }
}

/* ------------------------------------------------------------- telefonok */

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  /* Respect the notch / home indicator. */
  .pagebar,
  .docs__bar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .content {
    padding: 14px max(14px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .pagebar h1 {
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* One primary action stays; the rest wrap under the title on the next row. */
  .pagebar {
    height: auto;
    min-height: var(--bar-h);
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
    row-gap: 8px;
  }

  .pagebar__actions {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }

  .pagebar__actions .btn {
    flex: 1 1 auto;
  }

  .pagebar__actions .btn--icon {
    flex: 0 0 auto;
  }

  /* KPI strip becomes two columns; the negative-margin divider trick only
     works in a row, so switch to plain borders. */
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi {
    margin-right: 0;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  .kpi:nth-child(2n) {
    border-right: 0;
  }

  .kpi__value {
    font-size: 22px;
  }

  .card__head {
    padding: 0 12px;
    flex-wrap: wrap;
    row-gap: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .card__head .end {
    margin-left: 0;
    width: 100%;
  }

  .card__head .end .seg {
    width: 100%;
  }

  .card__head .end .seg button {
    flex: 1;
  }

  .card__body {
    padding: 12px;
  }

  .toolbar > * {
    flex: 1 1 100%;
    min-width: 0;
  }

  .toolbar select,
  .seg {
    width: 100%;
  }

  .seg button {
    flex: 1;
  }

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

  .truncate {
    max-width: none;
    white-space: normal;
  }

  /* --------------------------------------------------- táblázat → kártya */

  /* Every panel table turns into a stack of labelled rows. The labels come
     from decorateTables() in app.js, so no renderer has to know about this. */
  .card .table-wrap {
    overflow-x: visible;
  }

  .card table,
  .card thead,
  .card tbody,
  .card tr,
  .card td {
    display: block;
    width: auto;
  }

  .card thead {
    display: none;
  }

  .card tbody tr {
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }

  .card tbody tr:last-child {
    border-bottom: 0;
  }

  .card tbody tr:hover td {
    background: transparent;
  }

  .card td {
    height: auto;
    padding: 3px 0;
    border: 0;
    text-align: left;
  }

  .card td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }

  /* The first cell reads as the row's title, so it needs no label. */
  .card td:first-child::before {
    display: none;
  }

  .card td:first-child {
    font-size: 15px;
    padding-bottom: 6px;
  }

  .card td.num {
    text-align: left;
  }

  .card td.actions,
  .card td.is-unlabelled {
    width: auto;
    padding-top: 10px;
  }

  .card td .row {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .card td .btn {
    flex: 1 1 auto;
  }

  .card td .btn--icon {
    flex: 0 0 auto;
  }

  /* An empty cell would otherwise leave a stray label and blank line. */
  .card td:empty {
    display: none;
  }

  /* ------------------------------------------------------------- modálok */

  /* Full-height sheet: a centred dialog with its own scroll area is awkward
     to reach one-handed. */
  .modal,
  .modal--wide {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .modal__head {
    padding-left: 16px;
    padding-top: env(safe-area-inset-top);
    height: auto;
    min-height: 52px;
  }

  .modal__body {
    flex: 1;
    max-height: none;
    padding: 16px;
  }

  .modal__foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }

  .modal__foot .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .toasts {
    right: 12px;
    left: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
  }

  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px 0;
  }

  .kv dt {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .kv dd {
    text-align: left;
    margin-bottom: 10px;
  }

  .chart {
    padding: 12px 8px 8px;
  }

  .duty-image {
    border-radius: 0;
    margin: 0 -12px;
    width: calc(100% + 24px);
    max-width: none;
  }
}

/* --------------------------------------------------- szabályzat telefonon */

@media (max-width: 640px) {
  .docs__article {
    padding: 20px max(16px, env(safe-area-inset-left)) 56px max(16px, env(safe-area-inset-right));
  }

  .doc__head h1 {
    font-size: 22px;
    line-height: 1.25;
  }

  .doc__lead {
    font-size: 14.5px;
  }

  .doc__body {
    font-size: 15px;
    line-height: 1.7;
  }

  .doc__h2 {
    margin-top: 28px;
    padding-top: 18px;
    font-size: 17.5px;
  }

  .doc__h3 {
    font-size: 15px;
  }

  .doc__body ul,
  .doc__body ol {
    padding-left: 20px;
  }

  .doc__body blockquote {
    padding: 12px 14px;
    font-size: 15px;
  }

  /* Code tables stay tables — they are two narrow columns — but they get
     their own scroll area with a hint that there is more to the right. */
  .doc__body .table-wrap {
    margin-inline: -4px;
    overflow-x: auto;
  }

  .doc__body th,
  .doc__body td {
    padding: 6px 12px;
  }

  .docs__search {
    padding: 12px;
  }

  .docs__bar {
    height: 56px;
  }

  .docs__brand strong {
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .kpis {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpi {
    border-right: 0;
  }

  .pagebar__actions .btn {
    flex: 1 1 100%;
  }
}
