/* Porta Nyilvántartó – felület
   Világos, nagy érintési felületű, mobilon és asztali gépen is jól olvasható. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #17203a;
  --ink-2: #4a5470;
  --muted: #7a839c;
  --line: #e3e7f0;
  --primary: #1f4fd1;
  --primary-ink: #ffffff;
  --primary-soft: #e8eefc;
  --ok: #157a46;      --ok-soft: #e3f5ea;
  --warn: #a35a00;    --warn-soft: #fff3df;
  --bad: #c02631;     --bad-soft: #fde8ea;
  --info: #1f5fa8;    --info-soft: #e5f0fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 32, 58, .06), 0 4px 14px rgba(23, 32, 58, .05);
  --side: 256px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
.mt { margin-top: 1.4rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.ico { width: 20px; height: 20px; flex: none; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Keret ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side); background: #fff; border-right: 1px solid var(--line);
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40;
  transition: transform .2s ease;
}
.brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1.1rem .9rem; }
.brand img { border-radius: 9px; }
.brand strong { display: block; font-size: 1rem; }
.brand small { color: var(--muted); font-size: .8rem; display: block; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .3rem .6rem; }
.sidebar nav a {
  display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; margin-bottom: 2px;
}
.sidebar nav a:hover { background: var(--bg); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-user { border-top: 1px solid var(--line); padding: .9rem 1.1rem; font-size: .88rem; }
.sidebar-user strong { display: block; }
.sidebar-user small { color: var(--muted); display: block; margin-bottom: .3rem; }
.main { flex: 1; margin-left: var(--side); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(244, 246, 251, .92); backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: .8rem; padding: .9rem 1.6rem; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.3rem; margin: 0; flex: 1; }
.topbar-right { display: flex; gap: 1rem; align-items: center; color: var(--ink-2); font-size: .92rem; }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.content { padding: 1.4rem 1.6rem 2rem; max-width: 1280px; width: 100%; }
.foot { padding: 1rem 1.6rem 1.6rem; color: var(--muted); font-size: .8rem; }
.menu-btn { display: none; }
.icon-btn { background: none; border: 0; padding: .4rem; border-radius: 8px; color: var(--ink); cursor: pointer; }
.backdrop { display: none; }
.bottomnav { display: none; }

/* ---------- Kártyák, rács ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem; margin-bottom: 1.1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; margin-bottom: 1.1rem; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .2rem; color: var(--ink); border-left: 4px solid var(--primary);
}
a.stat:hover { text-decoration: none; transform: translateY(-1px); }
.stat-label { color: var(--ink-2); font-size: .88rem; }
.stat-value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.warn { border-left-color: var(--warn); }
.stat.bad { border-left-color: var(--bad); }
.stat.ok { border-left-color: var(--ok); }
.stat.muted-stat { border-left-color: var(--line); }

/* Gyorsgombok a porta kezdőlapon */
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.quick a {
  background: var(--primary); color: #fff; border-radius: var(--radius); padding: 1.1rem 1rem;
  display: flex; flex-direction: column; gap: .5rem; font-weight: 600; font-size: 1.05rem; box-shadow: var(--shadow);
}
.quick a .ico { width: 28px; height: 28px; }
.quick a:hover { text-decoration: none; filter: brightness(1.06); }
.quick a.alt { background: #fff; color: var(--ink); }
.quick a.alt .ico { color: var(--primary); }

/* ---------- Táblázat ---------- */
.table-wrap { overflow-x: auto; margin: 0 -.3rem; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .94rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.row-warn td { background: var(--warn-soft); }
.tbl tr.row-bad td { background: var(--bad-soft); }
.tbl td small { color: var(--muted); display: block; }
.empty { text-align: center; color: var(--muted); padding: 1.6rem .5rem; }

/* ---------- Jelvények ---------- */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-gray { background: #eef0f5; color: var(--ink-2); }

/* ---------- Üzenetek ---------- */
.alert { padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #bfe6cf; }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: #f6c3c8; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: #f5d9a8; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #c6dcf3; }
.warnbox { background: var(--bad-soft); border: 2px solid var(--bad); color: #7c1820; border-radius: 12px; padding: 1rem; margin: 1rem 0; }
.warnbox strong { display: flex; align-items: center; gap: .4rem; font-size: 1.05rem; margin-bottom: .3rem; }

/* ---------- Űrlapok ---------- */
.form { display: grid; gap: .9rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; color: var(--ink); cursor: pointer; }
label.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); width: 100%; padding: .7rem .8rem; min-height: 46px;
  border: 1px solid #cfd5e3; border-radius: 10px; background: #fff;
}
.input:focus, select:focus, textarea:focus { outline: 3px solid var(--primary-soft); border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 1rem; display: grid; gap: .8rem; margin: 0; }
legend { font-weight: 700; padding: 0 .4rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600;
  min-height: 44px; padding: .55rem 1.05rem; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  background: var(--primary-soft); color: var(--primary); text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-light { background: #fff; color: var(--ink); border-color: #cfd5e3; }
.btn-lg { min-height: 54px; font-size: 1.08rem; padding: .7rem 1.4rem; }
.btn-sm { min-height: 36px; padding: .3rem .75rem; font-size: .88rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.toolbar .input, .toolbar select { width: auto; min-width: 160px; flex: 1; }

/* ---------- Fülek ---------- */
.tabs { display: flex; gap: .3rem; margin-bottom: 1.1rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: .65rem 1rem; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Választólista (kulcs, személy) ---------- */
.picker { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.picker-search { padding: .6rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; border-radius: 12px 12px 0 0; }
.picker-list { max-height: 340px; overflow-y: auto; padding: .4rem; }
.pick { display: flex; align-items: center; gap: .7rem; padding: .7rem .75rem; border-radius: 10px; cursor: pointer; border: 2px solid transparent; font-weight: 500; color: var(--ink); }
.pick:hover { background: var(--bg); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.pick .pick-main { flex: 1; min-width: 0; }
.pick .pick-main strong { display: block; }
.pick .pick-main small { color: var(--muted); font-weight: 400; display: block; }
.pick.is-hidden, .check-row.is-hidden, tr.is-hidden { display: none; }
.pick.pick-disabled { opacity: .55; cursor: not-allowed; }
.selected-summary { margin-top: .5rem; font-size: .92rem; color: var(--ink-2); }

/* ---------- Szekrény-ellenőrzés ---------- */
.check-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; }
.check-toolbar .input { flex: 1; min-width: 200px; }
.check-list { display: grid; gap: .4rem; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.check-info { min-width: 0; }
.check-info strong { display: block; }
.check-info small { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid #cfd5e3; border-radius: 10px; overflow: hidden; flex: none; }
.seg label { display: block; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .55rem .85rem; min-width: 92px; text-align: center; }
.seg label + label span { border-left: 1px solid #cfd5e3; }
.seg input:checked + span { background: var(--ok); color: #fff; }
.seg .seg-bad input:checked + span { background: var(--bad); color: #fff; }

/* Szekrény rácsnézet */
.cabinet { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .55rem; }
.hook { border-radius: 12px; padding: .65rem .6rem; background: var(--ok-soft); border: 1px solid #bfe6cf; min-height: 84px; }
.hook strong { display: block; font-size: 1.15rem; }
.hook span { display: block; font-size: .82rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hook.out { background: var(--warn-soft); border-color: #f5d9a8; }
.hook.miss { background: var(--bad-soft); border-color: #f6c3c8; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); margin-bottom: .8rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }

/* ---------- Oszlopdiagram (vezérlőpult) ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bar { width: 100%; max-width: 30px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-col:hover .bar { background: #163ba3; }
.bar-col .tip { position: absolute; bottom: calc(100% + 4px); background: var(--ink); color: #fff; font-size: .78rem; padding: .25rem .5rem; border-radius: 6px; white-space: nowrap; display: none; z-index: 2; }
.bar-col:hover .tip { display: block; }
.bar-labels { display: flex; gap: 6px; font-size: .72rem; color: var(--muted); margin-top: .35rem; }
.bar-labels span { flex: 1; text-align: center; }

/* ---------- Bejelentkezés ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 2rem; width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 620px; }
.auth-card h1 { font-size: 1.45rem; }
.auth-logo { display: flex; gap: .8rem; align-items: center; margin-bottom: 1.3rem; }
.auth-logo img { border-radius: 12px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .35rem; max-height: 420px; overflow-y: auto; padding: .3rem; border: 1px solid var(--line); border-radius: 12px; }
.perm-grid label { font-weight: 500; color: var(--ink); padding: .4rem .5rem; border-radius: 8px; }
.perm-grid label:hover { background: var(--bg); }

/* ---------- Mobil ---------- */
@media (max-width: 960px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.18); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(23,32,58,.35); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 1.12rem; }
  .topbar .who { display: none; }
  .content { padding: 1rem 1rem 6rem; }
  .foot { padding-bottom: 6rem; }
  .card { padding: 1rem; }
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff;
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem 0 .45rem; font-size: .72rem; color: var(--ink-2); font-weight: 600; }
  .bottomnav a:hover { text-decoration: none; }
  .bottomnav .ico { width: 23px; height: 23px; }
  .check-row { flex-direction: column; align-items: stretch; }
  .seg { width: 100%; }
  .seg label { flex: 1; }
  .seg span { min-width: 0; }
  /* Táblázatból kártyalista mobilon */
  table.tbl.responsive thead { display: none; }
  table.tbl.responsive, .tbl.responsive tbody, .tbl.responsive tr, .tbl.responsive td { display: block; width: 100%; }
  .tbl.responsive tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; padding: .4rem .2rem; background: #fff; }
  .tbl.responsive tr.row-warn { background: var(--warn-soft); }
  .tbl.responsive tr.row-bad { background: var(--bad-soft); }
  .tbl.responsive tr td { background: transparent !important; }
  .tbl.responsive td { border: 0; padding: .3rem .7rem; }
  .tbl.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .tbl.responsive td.actions-cell .btn { width: 100%; }
  .stat-value { font-size: 1.6rem; }
}

@media print {
  .sidebar, .topbar, .bottomnav, .foot, .no-print, .tabs, .toolbar { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}
