:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-soft: #faf8f4;
    --border: #e6e1d6;
    --line: #ebe7df;
    --text: #13202b;
    --text-soft: #4a5560;
    --muted: #6f7780;
    --primary: #0d5486;
    --primary-hover: #0a456f;
    --primary-soft: #e7f0f7;
    --ok: #067647;
    --ok-soft: #e7f6ee;
    --danger: #b42318;
    --danger-soft: #fdeceb;
    --radius-card: 28px;
    --radius-pill: 16px;
    --radius-ctrl: 12px;
    --shadow: 0 1px 2px rgba(19, 32, 43, .04), 0 10px 30px rgba(19, 32, 43, .05);
    --sidebar-w: 282px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-underline-offset: 2px; }
img { max-width: 100%; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }

/* ---------- Váz ---------- */
.shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 16px 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 40;
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 24px;
    color: inherit;
    text-decoration: none;
}
.brand > span { display: flex; flex-direction: column; min-width: 0; }
.brand-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.25; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
    display: block;
    padding: 13px 16px;
    border-radius: var(--radius-pill);
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
    transition: background-color .15s;
}
.nav-link:hover { background: var(--surface-soft); }
.nav-link.is-active { background: var(--primary); color: #fff; font-weight: 700; }
.nav-link.is-muted:not(.is-active) { color: #9aa1a8; }

.nav-group { margin: 0; }
.nav-group[open] { display: flex; flex-direction: column; gap: 2px; padding-bottom: 4px; }
.nav-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.nav-group-label::-webkit-details-marker { display: none; }
.nav-group-label::after {
    content: '';
    width: 7px;
    height: 7px;
    margin-right: 4px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    opacity: .5;
    transition: transform .15s;
}
.nav-group[open] > .nav-group-label::after { transform: rotate(-135deg); }
.nav-sub {
    margin-left: 16px;
    padding: 9px 14px;
    font-size: 14px;
    color: var(--text-soft);
    border-left: 2px solid var(--line);
    border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
}
.nav-sub.is-active { border-left-color: var(--primary); }

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-soft);
    font-weight: 600;
    text-decoration: none;
}
.sidebar-logout:hover { background: var(--surface-soft); color: var(--text); }
.sidebar-logout svg { width: 18px; height: 18px; }

.main { margin-left: var(--sidebar-w); min-width: 0; }
.container {
    max-width: 768px;
    margin: 0 auto;
    padding: 38px 20px 72px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.container.is-wide { max-width: 1100px; }
.container.is-full { max-width: 1600px; padding-left: 28px; padding-right: 28px; }

.topbar { display: none; }

.limited-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.limited-bar .brand { padding: 0; }
.limited-bar .sidebar-logout { padding: 9px 14px; }
.backdrop { display: none; }

/* ---------- Kártyák ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    padding: 28px 24px;
}
.card-frame { padding: 0; overflow: hidden; }
.embed-frame { display: block; width: 100%; height: calc(100vh - 120px); min-height: 520px; border: 0; }
.card-hero { text-align: center; padding: 34px 24px 26px; }
.card-intro { padding: 28px 24px; }
.card-title { font-size: 18px; font-weight: 800; margin: 0 0 14px; letter-spacing: -.005em; }
.card-title .muted { font-weight: 500; font-size: 15px; }
.card-title-spaced { margin-top: 32px; }
.page-title { font-size: 24px; font-weight: 800; margin: 0 0 8px; }
.lead { font-size: 17px; margin: 0 0 6px; }
.card p:last-child { margin-bottom: 0; }

.hero-name { font-size: 24px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.hero-sub { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.eyebrow { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.avatar {
    display: block;
    width: 96px;
    height: 96px;
    margin: 0 auto 14px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px var(--border);
}
.badge {
    display: inline-block;
    margin-top: 10px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    vertical-align: middle;
}
.card-title .badge { margin: 0 0 0 8px; }

.code-block { margin-top: 36px; }
.code-label { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.barcode { display: block; height: auto; margin: 0 auto; image-rendering: pixelated; }
.code-value {
    margin-top: 6px;
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 18px;
    letter-spacing: .06em;
}

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }

.qr { margin-top: 20px; font-size: 14px; }
.qr summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--muted);
    list-style: none;
}
.qr summary::-webkit-details-marker { display: none; }
.qr summary svg { width: 16px; height: 16px; }
.qr summary:hover { color: var(--text); }
.qr-img { display: block; margin: 14px auto 4px; }

.back-link { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.back-link:hover { color: var(--text); }

/* ---------- Gombok ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-ctrl);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s, border-color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-secondary {
    background: var(--surface-soft);
    border-color: var(--border);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(19, 32, 43, .06);
}
.btn-secondary:hover { background: #f2efe8; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.inline-form { display: inline; margin: 0; }
.link-btn {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.link-btn.is-ok { color: var(--ok); }
.link-btn.is-danger { color: var(--danger); margin-left: 6px; }

/* ---------- Űrlap, kulcs-érték sorok ---------- */
.kv-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 1.4fr;
    gap: 16px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.kv-row:last-of-type { border-bottom: 0; }
.kv-label { font-size: 13px; color: var(--text-soft); }
.kv-value { font-size: 16px; }
.kv-end { justify-self: end; text-align: right; }
.kv-center { max-width: 480px; margin: 22px auto 0; text-align: left; }
.hint { display: block; font-size: 12px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 13px; color: var(--text-soft); }
.field-grow { flex: 1; margin-bottom: 0; }

.input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 16px;
}
.input:focus { outline: 3px solid rgba(13, 84, 134, .18); border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 84px; }

.check {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin: 20px 0 6px;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-soft);
    font-size: 14px;
    color: var(--text-soft);
}
.check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--primary); flex-shrink: 0; }

.form-foot { display: flex; justify-content: flex-end; margin-top: 20px; }

.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-ctrl);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 14px;
    font-weight: 600;
}
.alert-info { background: var(--primary-soft); color: var(--primary); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 700;
}
.pill-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 18px; }
.stat { padding: 12px 14px; border-radius: 16px; background: var(--surface-soft); display: flex; flex-direction: column; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-weight: 700; }

/* ---------- Táblázat ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}
.table th.center { text-align: center; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfbf8; }
.table .links a { display: block; }
.table-section td { background: var(--surface-soft) !important; font-weight: 700; }
.table tr.is-highlight td { background: #f1f9e6; }
.table tr.is-target td { background: #fff7d6; }

/* ---------- Bejelentkezés ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 410px; padding: 34px 28px 28px; }
.login-head { text-align: center; margin-bottom: 22px; }
.login-logo { width: 96px; height: 96px; object-fit: contain; }
.login-title { font-size: 24px; font-weight: 800; margin: 12px 0 2px; }
.login-sub { margin: 0; color: var(--muted); font-size: 14px; }
.login-card .btn-block { margin-top: 8px; padding: 12px 16px; font-size: 15px; }

/* ---------- Értesítés ---------- */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 11px 20px;
    border-radius: 14px;
    background: var(--ok);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
    z-index: 60;
    transition: opacity .3s, transform .3s;
}
.toast.is-error { background: var(--danger); }
.toast.is-hiding { opacity: 0; transform: translate(-50%, -10px); }

/* ---------- Mobil ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: none; }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
    body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(19, 32, 43, .35); z-index: 35; }
    .main { margin-left: 0; }
    .topbar {
        position: sticky;
        top: 0;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        background: rgba(255, 255, 255, .92);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--border);
        z-index: 30;
    }
    .topbar-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 12px; background: #fff; color: var(--text); cursor: pointer; }
    .topbar-btn svg { width: 20px; height: 20px; }
    .topbar-title { font-weight: 700; flex: 1; }
    .topbar-logo { width: 36px; height: 36px; object-fit: contain; }
    .container { padding: 20px 14px 56px; gap: 16px; }
}

@media (max-width: 640px) {
    .card { padding: 22px 18px; border-radius: 22px; }
    .kv-row { grid-template-columns: 1fr; gap: 6px; }
    .kv-end { justify-self: start; text-align: left; }

    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
    .table-stack td { border: 0; padding: 4px 0 4px 42%; position: relative; text-align: left !important; }
    .table-stack td[data-title]::before {
        content: attr(data-title);
        position: absolute;
        left: 0;
        width: 38%;
        font-size: 12px;
        color: var(--muted);
    }
    .table-stack td[colspan] { padding-left: 0; }
}

/* ---------- Nyomtatás ---------- */
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .backdrop, .toast, .no-print, .back-link { display: none !important; }
    .main { margin: 0; }
    .container > :not(.print-area) { display: none !important; }
    .print-area { border: 0; box-shadow: none; }
}
