/* Asszisztens-admin – hűvös ásványszürke alap, fenyőzöld kiemelés, beszédbuborék-jelölők */
:root {
  --paper: #E8ECEE;
  --surface: #FFFFFF;
  --ink: #16222C;
  --muted: #5A6772;
  --line: #D2D8DD;
  --line-strong: #B7C0C7;
  --accent: #24594A;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDEAE4;
  --warn: #7F570B;
  --warn-soft: #F5EAD2;
  --danger: #A2332A;
  --danger-soft: #F6DFDB;
  --focus: #2F5FA7;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; margin-top: 1.5em; }
p { margin: 0 0 .75em; max-width: 72ch; }
a { color: var(--accent); text-underline-offset: 2px; }
code { font-size: .9em; background: var(--paper); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.lead { font-size: 1.0625rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- Beszédbuborék jelölő ---- */
.bubble {
  --c: var(--accent);
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 9px 9px 9px 2px;
  background: var(--c);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.bubble-md { width: 40px; height: 40px; border-radius: 12px 12px 12px 3px; font-size: .875rem; }
.bubble-lg { width: 56px; height: 56px; border-radius: 16px 16px 16px 4px; font-size: 1.125rem; }
.bubble-brand { background: var(--ink); }

/* ---- Keret ---- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; text-decoration: none; padding: 0 8px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a, .side-bot, .side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--ink); text-decoration: none;
}
.side-nav a:hover, .side-bot:hover, .side-user:hover { background: var(--paper); }
.side-nav a[aria-current="page"], .side-user[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-heading { margin: 0 0 6px; padding: 0 10px; font-size: .8125rem; color: var(--muted); }
.side-bots ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-bot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-bot.is-off .bubble { opacity: .45; }
.side-bot.is-off .side-bot-name { color: var(--muted); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 4px; }
.side-user { flex-direction: column; align-items: flex-start; gap: 0; }
.side-user span { font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.side-foot form { padding: 0 10px; }

.main { padding: 32px 40px 64px; max-width: 1040px; width: 100%; }
.bare .main { max-width: none; min-height: 100vh; display: grid; place-items: center; padding: 24px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.page-title-with-bubble { display: flex; align-items: center; gap: 14px; }

/* ---- Panelek ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 20px 24px;
  margin: 0 0 20px;
}
fieldset.panel { min-width: 0; }
.panel legend { float: left; width: 100%; padding: 0; margin: 0 0 14px; font-size: 1.125rem; font-weight: 650; }
.panel legend + * { clear: both; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-highlight { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.panel-danger { border-color: #E3B9B3; }
.narrow { max-width: 560px; }

/* ---- Beüzemelési lépések (valódi sorrend) ---- */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 12px; }
.steps li::before {
  content: counter(step);
  grid-column: 1; grid-row: 1;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); color: var(--muted); font-weight: 600; font-size: .875rem;
}
.steps li.is-done::before { content: "✓"; background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li > :not(.step-state) { grid-column: 2; grid-row: 1; }
.steps .step-state { grid-column: 3; grid-row: 1; font-size: .8125rem; color: var(--muted); }
.steps li.is-done > span:not(.step-state) { color: var(--muted); }

/* ---- Állapotsáv ---- */
.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
}
.facts > div { padding: 16px 24px; }
.facts > div + div { border-left: 1px solid var(--line); }
.facts dt { font-size: .8125rem; color: var(--muted); }
.facts dd { margin: 4px 0 0; font-size: 1.0625rem; font-weight: 600; }

/* ---- Címkék ---- */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.6; vertical-align: middle; white-space: nowrap; }
.tag-ok { background: var(--accent-soft); color: var(--accent); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-error { background: var(--danger-soft); color: var(--danger); }
.tag-muted { background: var(--paper); color: var(--muted); }

/* ---- Visszajelzések ---- */
.flash { padding: 10px 14px; border-radius: var(--radius-s); margin: 0 0 20px; border: 1px solid transparent; max-width: 72ch; }
.flash-ok { background: var(--accent-soft); border-color: #BBD5CA; }
.flash-warn { background: var(--warn-soft); border-color: #E6D3A8; }
.flash-error { background: var(--danger-soft); border-color: #E7BDB6; }

/* ---- Űrlapok ---- */
.stack { display: grid; gap: 14px; }
.stack-narrow { max-width: 420px; }
.form-grid { display: grid; }
.form-actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(to top, var(--paper) 70%, transparent); margin-bottom: 20px; }
.field { display: grid; gap: 5px; margin: 0 0 16px; }
.stack .field { margin: 0; }
.field > span:first-child { font-weight: 600; font-size: .9375rem; }
.field small { color: var(--muted); font-size: .8125rem; max-width: 72ch; }
.field-short input { max-width: 160px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  padding: 8px 10px;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(47, 95, 167, .18); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.error { color: var(--danger); font-style: normal; font-size: .8125rem; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; }

.row-form { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.row-form .field { margin: 0; flex: 1 1 220px; }
.row-form .field-grow { flex: 1 1 360px; }
.row-form > .button { margin-top: 28px; }
.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.inline-form .field { margin: 0; flex: 1 1 280px; }
.input-with-button { display: flex; gap: 6px; }
.input-with-button input { flex: 1; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch::before {
  content: ""; display: block; width: 30px; height: 30px;
  border-radius: 9px 9px 9px 2px; background: var(--c);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent;
}
.swatch:has(input:checked)::before { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.swatch:has(input:focus-visible)::before { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus); }

/* ---- Gombok ---- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .9375rem;
  padding: 8px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:hover { border-color: var(--ink); }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button-primary:hover { background: #1C4A3D; border-color: #1C4A3D; }
.button-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button-danger:hover { background: #87291F; border-color: #87291F; }
.button-danger-quiet { color: var(--danger); }
.button-danger-quiet:hover { border-color: var(--danger); }
.button-small { padding: 5px 10px; font-size: .8125rem; }
.button-wide { width: 100%; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.link-button { font: inherit; background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: .875rem; }
.link-button:hover { color: var(--ink); }

/* ---- Táblák és listák ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th { text-align: left; font-weight: 600; font-size: .8125rem; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .tag { margin-left: 6px; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline-block; margin-left: 6px; vertical-align: middle; }

.bot-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.bot-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 20px; }
.bot-row + .bot-row { border-top: 1px solid var(--line); }
.bot-name { font-weight: 650; font-size: 1.0625rem; color: var(--ink); text-decoration: none; }
.bot-name:hover { text-decoration: underline; }
.bot-main p { margin: 2px 0 0; }
.bot-actions { display: flex; align-items: center; gap: 10px; }

.kv { display: grid; gap: 8px; margin: 0 0 8px; }
.kv > div { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }

.checks { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.checks li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; align-items: start; }
.checks .tag { justify-self: start; margin-top: 2px; }
.checks strong { margin-right: 8px; }
.checks p { margin: 4px 0 0; }
.checks code { overflow-wrap: anywhere; }

.secret { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.secret code { font-size: 1.25rem; padding: 6px 12px; background: var(--paper); letter-spacing: .04em; }

.empty { text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-m); padding: 48px 24px; display: grid; justify-items: center; gap: 4px; }
.empty p { margin-left: auto; margin-right: auto; }

/* ---- Belépés ---- */
.auth { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; }
.auth-mark { margin-bottom: 16px; }
.auth h1 { margin-bottom: 2px; }
.auth > .muted { margin-bottom: 20px; }
.auth form { margin-bottom: 16px; }

/* ---- Mobil ---- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav { display: flex; flex-wrap: wrap; gap: 2px; order: 3; width: 100%; }
  .side-bots { display: none; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  .side-user span { display: none; }
  .side-user strong { font-weight: 600; }
  .side-foot { width: auto; }
  .main { padding: 20px 16px 48px; }
  .facts { grid-template-columns: 1fr; }
  .facts > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .bot-row { grid-template-columns: auto minmax(0, 1fr); }
  .bot-actions { grid-column: 2; }
  .kv > div { grid-template-columns: 1fr; gap: 2px; }
  .panel { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* ---- 2. modul: tudásbázis ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -8px 0 24px; }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

.source-list { list-style: none; margin: 12px 0 0; padding: 0; }
.source { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.source:first-child { border-top: 0; padding-top: 4px; }
.source-name { font-weight: 650; font-size: 1.0625rem; color: var(--ink); text-decoration: none; }
.source-name:hover { text-decoration: underline; }
.source-url { margin: 0 0 8px; overflow-wrap: anywhere; }
.source-main p { margin-bottom: 4px; }
.source-counts { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.source-counts a { color: var(--ink); text-decoration: none; }
.source-counts a:hover { text-decoration: underline; }
.source-actions { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; justify-content: flex-end; max-width: 320px; }
.source-actions form { display: contents; }
.text-danger, .source-counts a.text-danger { color: var(--danger); }

.progress { height: 6px; background: var(--paper); border-radius: 999px; overflow: hidden; margin: 6px 0; max-width: 460px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }

.upload { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; margin: 8px 0 16px; }
.upload-drop { flex: 1 1 360px; position: relative; display: grid; gap: 2px; padding: 14px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-m); cursor: pointer; background: var(--surface); }
.upload-drop:hover, .upload-drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.upload-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-drop:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.upload > .button { align-self: center; }

.results { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 14px; }
.results li::marker { color: var(--muted); font-weight: 600; }
.results p { margin: 2px 0; }
.result-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.results a { overflow-wrap: anywhere; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 16px; }
.mono-input { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .875rem; }
.form-grid .check { margin-bottom: 8px; }

.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.filter-chips a { padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: .875rem; }
.filter-chips a span { color: var(--muted); margin-left: 4px; }
.filter-chips a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.filter-chips a[aria-current="true"] span { color: #C9D1D8; }
.pages-table .page-cell { min-width: 260px; max-width: 460px; overflow-wrap: anywhere; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; }
.button-row-tight { margin-top: 0; }
.secret-wide code { font-size: .8125rem; letter-spacing: 0; overflow-wrap: anywhere; flex: 1 1 400px; }

@media (max-width: 860px) {
  .source { grid-template-columns: 1fr; }
  .source-actions { justify-content: flex-start; max-width: none; }
}

/* ---- 3. modul: tesztchat ---- */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.chat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); display: flex; flex-direction: column; height: min(72vh, 760px); min-height: 480px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-reset { margin-left: auto; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #F6F8F9; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-bot { align-self: flex-start; }
.msg-bubble { padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg-user .msg-bubble { background: var(--c, var(--accent)); border-color: transparent; color: #fff; border-radius: 14px 14px 4px 14px; }
.msg-bubble p { margin: 0 0 .5em; }
.msg-bubble p:last-child, .msg-bubble ul:last-child { margin-bottom: 0; }
.msg-bubble ul { margin: 0 0 .5em; padding-left: 20px; }
.status-no_answer .msg-bubble { border-style: dashed; }
.status-error .msg-bubble { border-color: #E7BDB6; background: var(--danger-soft); }
.cite { display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; margin-left: 2px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: .6875rem; font-weight: 700; text-decoration: none; vertical-align: 2px; }
a.cite:hover { background: var(--accent); color: #fff; }
.msg-sources { margin: 8px 0 0; padding: 8px 0 0 20px; border-top: 1px solid var(--line); font-size: .8125rem; }
.msg-sources a { overflow-wrap: anywhere; }
.msg-related { margin: 8px 0 0 !important; padding-top: 8px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); }
.msg-sources.is-related { border-top: 0; padding-top: 0; margin-top: 2px; }
.msg-debug { margin-top: 6px; font-size: .8125rem; max-width: 100%; }
.msg-debug summary { cursor: pointer; color: var(--muted); }
.msg-debug[open] { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 12px; }
.msg-debug p { margin: 4px 0; max-width: none; }
.debug-chunks { margin: 6px 0; padding-left: 18px; display: grid; gap: 6px; }
.debug-chunks li { overflow-wrap: anywhere; }
.debug-chunks li:not(.is-selected) { opacity: .75; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-form textarea { resize: none; min-height: 44px; max-height: 160px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-side .panel { padding: 16px 18px; }
.kv-compact > div { grid-template-columns: 1fr auto; }
.token-table { font-size: .8125rem; margin-top: 10px; }
.token-table th, .token-table td { padding: 4px 6px; }
@media (max-width: 1000px) { .chat-layout { grid-template-columns: 1fr; } .msg { max-width: 92%; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }

.debug-raw { white-space: pre-wrap; background: var(--paper); padding: 8px 10px; border-radius: var(--radius-s); font-size: .8125rem; margin: 4px 0; max-height: 240px; overflow: auto; }

.debug-part { margin-top: 10px !important; }
.debug-evidence { margin: 4px 0; padding-left: 18px; font-size: .8125rem; color: var(--muted); }

.extracted { max-height: 520px; overflow: auto; background: var(--paper); border-radius: var(--radius-s); padding: 12px 16px; }
.extracted p { margin: 0 0 6px; max-width: none; font-size: .9375rem; }
.extracted-h { font-weight: 700; margin-top: 12px !important; }
