/* Lakossági asszisztens – nyugodt, megbízható, közszolgálati megjelenés */
:root {
    --brand: #2f6f5e;
    --brand-ink: color-mix(in srgb, var(--brand) 82%, #000);
    --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
    --bg: #f5f3ee;
    --surface: #ffffff;
    --surface-soft: #faf8f4;
    --ink: #1f2a26;
    --muted: #66706b;
    --line: #e4e0d7;
    --danger: #b3412f;
    --warn-bg: #fff4e5;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(31, 42, 38, .05), 0 6px 20px rgba(31, 42, 38, .06);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.55 var(--font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1; }
a { color: var(--brand-ink); }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 62ch; margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Fejléc */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 1.15rem; flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { color: var(--muted); font-size: .82rem; }
.public-nav, .admin-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.public-nav a, .admin-nav a {
    text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: 999px; font-size: .95rem;
}
.public-nav a:hover, .admin-nav a:hover { background: var(--brand-soft); }
.admin-nav a.muted { color: var(--muted); }

.footer { margin-top: 48px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 18px; font-size: .9rem; color: var(--muted); }

/* Kártyák, gombok, űrlapok */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; }
.card-soft { background: var(--surface-soft); box-shadow: none; }
.card-title { margin: 0 0 10px; font-size: 1.02rem; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--brand); color: #fff; border: 0; border-radius: 999px;
    padding: 11px 20px; font: 600 .97rem/1.2 var(--font); text-decoration: none; cursor: pointer;
    transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .chip:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px;
}
.btn-secondary { background: var(--brand-soft); color: var(--brand-ink); }
.btn-secondary:hover { background: color-mix(in srgb, var(--brand) 18%, #fff); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-soft); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 80%, #000); }
.btn-small { padding: 7px 14px; font-size: .88rem; }
.btn-large { padding: 14px 26px; font-size: 1.05rem; width: 100%; }
.btn.is-copied::after { content: " ✓"; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input:not([type]), textarea, select {
    width: 100%; font: inherit; color: var(--ink); background: #fff;
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px;
}
textarea { resize: vertical; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field small { display: block; margin-top: 6px; }
fieldset { border: 0; padding: 0; margin: 0 0 26px; }
legend { font-weight: 700; font-size: 1.08rem; margin-bottom: 12px; padding: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; text-transform: none; }
.alert { background: var(--warn-bg); border: 1px solid #f2d2a6; color: #6b4210; border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; }
.alert p { margin: 4px 0; }
.flash { margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.flash-error { background: var(--warn-bg); color: #6b4210; }
.chip {
    display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink);
    border-radius: 999px; padding: 7px 14px; font: .9rem/1.3 var(--font); cursor: pointer; text-decoration: none;
}
.chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.chip.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.small-link { font-size: .9rem; }

/* Főoldal */
.home-intro { padding: 36px 0 20px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.card.card-chat { padding: 0; overflow: hidden; }
.card-action { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--ink); border-color: transparent; background: var(--brand); color: #fff; }
.card-action small { display: block; opacity: .88; font-size: .9rem; margin-top: 2px; }
.card-action:hover { background: var(--brand-ink); }
.card-icon { width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: none; }
.checklist { list-style: none; padding: 0; margin: 0 0 10px; }
.checklist li { position: relative; padding-left: 26px; margin-bottom: 8px; font-size: .94rem; }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: var(--brand); font-weight: 700; }

/* Chat */
.chat { display: flex; flex-direction: column; height: min(70vh, 640px); min-height: 460px; }
.chat-log { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 86%; padding: 12px 16px; border-radius: 18px; font-size: .98rem; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 4px 0 8px; padding-left: 20px; }
.msg-bot { background: var(--surface-soft); border: 1px solid var(--line); border-bottom-left-radius: 6px; align-self: flex-start; }
.msg-user { background: var(--brand); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; white-space: pre-wrap; }
.msg-error { background: var(--warn-bg); border-color: #f2d2a6; }
.msg .sources { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }
.msg .btn-inline { margin-top: 10px; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-suggestions .chip { text-align: left; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.chat-form textarea { flex: 1; resize: none; border-radius: 22px; padding: 11px 16px; max-height: 140px; min-height: 46px; }
.btn-send { width: 46px; height: 46px; padding: 0; flex: none; }
.chat-note { margin: 0; padding: 0 16px 12px; font-size: .78rem; color: var(--muted); background: #fff; }
.dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .4; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }

/* Beágyazott (iframe) nézet */
.page-embed { background: #fff; height: 100vh; }
.embed-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.embed-head .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
.embed-head small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.2; }
.chat-compact { height: calc(100vh - 59px); min-height: 0; }
.chat-compact .chat-log { padding: 14px; }
.chat-compact .msg { max-width: 92%; font-size: .95rem; }

/* Bejelentés */
.page-report main, .page-home main { padding-bottom: 8px; }
.page-report h1 { margin-top: 32px; }
.form-card { padding: 26px; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.category-option { position: relative; }
.category-option input { position: absolute; opacity: 0; }
.category-option span {
    display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer; background: #fff; font-size: .95rem; transition: border-color .15s, background .15s;
}
.category-option input:checked + span { border-color: var(--brand); background: var(--brand-soft); font-weight: 600; box-shadow: inset 0 0 0 1px var(--brand); }
.category-option input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); }
.map { height: 320px; border-radius: var(--radius-sm); border: 1px solid var(--line); margin-bottom: 10px; z-index: 0; }
.map-small { height: 240px; }
.map-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.photo-preview { max-width: 100%; max-height: 260px; border-radius: var(--radius-sm); margin-top: -4px; }
.anon-box { background: var(--brand-soft); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 20px; font-size: .93rem; }
.anon-box p { margin: 4px 0 0; }
.success-card { text-align: center; margin-top: 40px; padding: 36px 26px; }
.success-icon { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 1.8rem; font-weight: 700; }
.code-box { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; background: var(--surface-soft); border: 1px dashed var(--brand); border-radius: var(--radius); padding: 16px 28px; margin: 10px 0; }
.code-box strong { font-size: 2rem; letter-spacing: .12em; font-family: ui-monospace, Menlo, Consolas, monospace; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* Állapot */
.page-report h1, main.narrow > h1 { margin-top: 32px; }
.status-card .status-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.office-reply { background: var(--brand-soft); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 18px; }
.office-reply p { margin: 6px 0 0; }
.progress-steps { list-style: none; display: flex; padding: 0; margin: 0; counter-reset: step; }
.progress-steps li { flex: 1; text-align: center; position: relative; font-size: .88rem; color: var(--muted); padding-top: 34px; }
.progress-steps li::before {
    counter-increment: step; content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 26px; height: 26px; border-radius: 50%; background: var(--line); color: var(--muted); display: grid; place-items: center; font-weight: 700; font-size: .8rem; z-index: 1;
}
.progress-steps li + li::after { content: ""; position: absolute; top: 12px; right: 50%; width: 100%; height: 2px; background: var(--line); }
.progress-steps li.is-done { color: var(--ink); font-weight: 600; }
.progress-steps li.is-done::before { background: var(--brand); color: #fff; }
.progress-steps li.is-done::after { background: var(--brand); }

/* Jelvények */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--line); color: var(--ink); }
.badge-new { background: #fdeccf; color: #7a4b09; }
.badge-in_progress { background: #dfeafb; color: #1e4c8a; }
.badge-done, .badge-kb-done { background: var(--brand-soft); color: var(--brand-ink); }
.badge-rejected, .badge-kb-skipped { background: #ecebe8; color: #55534e; }
.badge-kb-pending { background: #dfeafb; color: #1e4c8a; }
.badge-kb-error { background: #f9dfda; color: #8a2b1c; }

/* Szöveges oldalak */
.prose h2 { margin-top: 28px; margin-bottom: 6px; }
.prose p { max-width: 68ch; }

/* Admin */
.admin h1 { margin-top: 28px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 18px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--ink); }
a.stat:hover { border-color: var(--brand); }
.stat span { display: block; color: var(--muted); font-size: .88rem; }
.stat strong { font-size: 1.8rem; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.list { list-style: none; margin: 10px 0 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li a { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; text-decoration: none; color: var(--ink); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.list-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters select { width: auto; }
.table-wrap { overflow-x: auto; }
.table-wrap.card { padding: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; background: var(--surface-soft); }
.table tbody tr[onclick] { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-soft); }
.table td a { overflow-wrap: anywhere; }
.code { background: #1f2a26; color: #e8efe9; padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; font-size: .88rem; }
.crawl-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.crawl-secondary { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress-bar { height: 100%; width: 0; background: var(--brand); transition: width .3s; }
.report-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0 16px; }
.report-head h1 { margin: 0; }
.report-photo { max-width: 100%; border-radius: var(--radius-sm); }
.danger-zone { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.login-wrap { max-width: 440px; padding-top: 40px; }

@media (max-width: 860px) {
    .home-grid, .admin-grid { grid-template-columns: 1fr; }
    .home-intro { padding-top: 24px; }
    .chat { height: 72vh; }
}
@media (max-width: 520px) {
    .card { padding: 18px; }
    .msg { max-width: 94%; }
    .inline-form { flex-direction: column; }
    .public-nav { width: 100%; }
    .public-nav a { padding: 6px 10px; font-size: .9rem; }
    .code-box strong { font-size: 1.6rem; }
}

/* ---------- SaaS: platform és közös elemek ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 28px 0 8px; }
.page-head h1 { margin: 0; }
.acting-bar { background: #fff4e5; border-bottom: 1px solid #f2d2a6; color: #6b4210; font-size: .9rem; }
.acting-bar .wrap { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.acting-bar a { color: #6b4210; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(3, 1fr) auto; align-items: end; }
.form-section { font-size: 1rem; margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.color-row { display: flex; gap: 12px; align-items: center; }
.color-row input[type=color] { width: 56px; height: 44px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.link-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 4px; }
.link-list a { overflow-wrap: anywhere; }
.alert-inline { background: var(--warn-bg); color: #6b4210; padding: 8px 12px; border-radius: var(--radius-sm); margin-top: 12px; }
.danger-card { border-color: #efc9c1; }
.danger-card .inline-form { max-width: 520px; }
.badge-tenant-active { background: var(--brand-soft); color: var(--brand-ink); }
.badge-tenant-suspended { background: #f9dfda; color: #8a2b1c; }
.wrap-actions { flex-wrap: wrap; align-items: center; }
.inline-form.compact input { width: 150px; padding: 7px 10px; font-size: .88rem; }
.add-user { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.add-user .field { margin-bottom: 0; }
.card.empty { text-align: center; padding: 40px 24px; }
.area-platform .brand-mark { background: #3b4a6b; }
.landing { padding-top: 48px; }
.landing .checklist li { font-size: 1.02rem; }
.code + .btn { margin-top: 10px; }
.stat strong small { font-size: 1rem; font-weight: 500; }
@media (max-width: 860px) {
    .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
    .add-user .field { margin-bottom: 12px; }
}
