:root {
  --navy: #16233b;
  --navy-2: #24344f;
  --navy-soft: #3a4a66;
  --orange: #f5a623;
  --orange-2: #e2900d;
  --bg: #eef1f6;
  --panel: #ffffff;
  --ink: #1c2634;
  --muted: #667487;
  --border: #dbe1ea;
  --user-bg: #16233b;
  --error: #b1301f;
  --ok: #1f7a4d;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(22, 35, 59, .10);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }

/* ---------- Prekės ženklas (logotipas) ---------- */
.brand-lockup { display: inline-flex; align-items: center; gap: .55rem; }
.brand-logo { height: 26px; width: auto; display: block; }
.login-card .brand-logo { height: 40px; }
.brand-mark { flex: none; display: block; }
.brand-word {
  font-weight: 700; letter-spacing: .14em; color: var(--navy);
  text-transform: uppercase; line-height: 1; white-space: nowrap;
}
.brand-word b { color: var(--navy); font-weight: 700; }

/* ---------- Login ---------- */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1200px 500px at 50% -10%, #24344f 0%, #16233b 60%, #0f1a2c 100%);
  padding: 1rem;
}
.login-card {
  background: var(--panel); padding: 2.4rem 2.2rem; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35); width: min(380px, 92vw);
  display: flex; flex-direction: column; gap: 1rem;
}
.login-card .brand-lockup { justify-content: center; margin-bottom: .2rem; }
.login-card .brand-word { font-size: 1.15rem; }
.login-card .subtitle { text-align: center; color: var(--muted); margin: -.4rem 0 .6rem; font-size: .92rem; }
.login-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--navy-soft); font-weight: 600; }
.login-card input {
  padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,166,35,.18); }
.btn-primary {
  background: var(--orange); color: #241a00; border: none; padding: .75rem 1rem;
  border-radius: 10px; font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn-primary:hover { background: var(--orange-2); }
.btn-primary:active { transform: translateY(1px); }
.error { background: #fdecea; color: var(--error); padding: .55rem .75rem; border-radius: 10px; font-size: .9rem; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); padding: .7rem 1.2rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 0 rgba(22,35,59,.04);
}
.topbar .brand-word { font-size: .95rem; }
.topbar .tag { color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; font-size: .8rem; margin-left: .1rem; }
.user { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .9rem; }
.user .who { display: inline-flex; align-items: center; gap: .4rem; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--navy);
  color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700;
}
.linkbtn { background: none; border: none; color: var(--navy-soft); padding: 0; font-size: .9rem; cursor: pointer; }
.linkbtn:hover { color: var(--orange-2); text-decoration: underline; }

/* ---------- Chat ---------- */
.chat {
  max-width: 840px; margin: 0 auto; padding: 1.4rem 1.1rem 8rem;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.msg { padding: 1rem 1.15rem; border-radius: var(--radius); }
.msg-row { display: flex; flex-direction: column; gap: .3rem; }
.msg-row.user-row { align-items: flex-end; }
.msg-label { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 0 .4rem; }
.msg.user { background: var(--user-bg); color: #fff; max-width: 82%; border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.msg.error { background: #fdecea; color: var(--error); border: 1px solid #f3c6c0; }

/* Markdown turinys atsakyme */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h3 { font-size: 1.08rem; color: var(--navy); margin: 1.1rem 0 .5rem; }
.md h4 { font-size: .98rem; color: var(--navy-2); margin: .9rem 0 .4rem; }
.md p { margin: .55rem 0; }
.md ul, .md ol { margin: .5rem 0 .5rem 1.3rem; padding: 0; }
.md li { margin: .28rem 0; }
.md strong { color: var(--navy); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.md code { background: #eef1f6; padding: .05em .35em; border-radius: 5px; font-size: .9em; }
.cite { color: var(--orange-2); font-weight: 700; font-size: .82em; vertical-align: super; }

.disclaimer { margin-top: .8rem; font-size: .85rem; color: var(--muted); font-style: italic; border-top: 1px dashed var(--border); padding-top: .6rem; }

/* Šaltiniai */
.sources { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.sources h4 { margin: 0 0 .5rem; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.src { display: flex; gap: .55rem; padding: .35rem 0; font-size: .9rem; align-items: baseline; }
.src .n { flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--navy); color: #fff; font-size: .74rem; font-weight: 700; display: grid; place-items: center; }
.src a { color: var(--navy-2); text-decoration: none; font-weight: 600; }
.src a:hover { color: var(--orange-2); text-decoration: underline; }
.src .meta { color: var(--muted); font-weight: 400; }

/* Sistemos / pasveikinimo blokas + pavyzdžiai */
.welcome { text-align: center; color: var(--muted); padding: 1.5rem 1rem .5rem; }
.welcome h2 { color: var(--navy); font-size: 1.25rem; margin: .4rem 0; }
.welcome p { margin: .3rem auto; max-width: 560px; font-size: .95rem; }
.examples { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1rem; }
.chip {
  background: var(--panel); border: 1px solid var(--border); color: var(--navy-2);
  padding: .5rem .8rem; border-radius: 999px; font-size: .88rem; cursor: pointer;
  transition: border-color .15s, color .15s, box-shadow .15s;
}
.chip:hover { border-color: var(--orange); color: var(--orange-2); box-shadow: 0 2px 8px rgba(245,166,35,.15); }

/* „rašo..." animacija */
.typing { display: inline-flex; gap: .3rem; align-items: center; color: var(--muted); }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); animation: bounce 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

/* ---------- Composer ---------- */
.composer-wrap { position: fixed; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, var(--bg) 65%, rgba(238,241,246,0)); padding: .8rem 1rem 1.1rem; }
.composer { max-width: 840px; margin: 0 auto; display: flex; gap: .6rem; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: .5rem .5rem .5rem .9rem; box-shadow: var(--shadow); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: none; outline: none; font-size: 1rem; font-family: inherit; padding: .5rem 0; max-height: 160px; background: transparent; color: var(--ink); }
.send-btn { flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--orange); border: none; cursor: pointer; display: grid; place-items: center; transition: background .15s; }
.send-btn:hover { background: var(--orange-2); }
.send-btn:disabled { background: #cdd4de; cursor: not-allowed; }
.send-btn svg { width: 20px; height: 20px; fill: #241a00; }
.hint { text-align: center; color: var(--muted); font-size: .75rem; margin: .5rem auto 0; max-width: 840px; }

@media (max-width: 600px) {
  .topbar .tag { display: none; }
  .msg.user { max-width: 90%; }
}

/* Lentelės atsakymuose (slenksčiai, galios ribos, kriterijai) */
.table-wrap { overflow-x: auto; margin: 14px 0; }
.msg table { border-collapse: collapse; width: 100%; font-size: 14px; }
.msg th, .msg td {
  border: 1px solid #dde3ec; padding: 8px 10px;
  text-align: left; vertical-align: top;
}
.msg th { background: #16233b; color: #fff; font-weight: 600; }
.msg tbody tr:nth-child(even) { background: #f6f8fb; }

/* Pranešimas apie klaidingą atsakymą */
.fb { margin-top: 14px; padding-top: 12px; border-top: 1px solid #e7ecf3; }
.fb-open {
  background: none; border: 1px solid #d6dde8;
  color: #5b6b82; font-size: 13px; padding: 6px 12px;
  border-radius: 999px; cursor: pointer;
}
.fb-open:hover { border-color: #f5a623; color: #16233b; background: #fff8ec; }
.fb-form { margin-top: 12px; }
.fb-form label { display: block; font-size: 13px; color: #5b6b82; margin-bottom: 6px; }
.fb-comment {
  width: 100%; padding: 10px; border: 1px solid #d6dde8; border-radius: 8px;
  font: inherit; font-size: 14px; resize: vertical; box-sizing: border-box;
}
.fb-comment:focus { outline: none; border-color: #f5a623; }
.fb-actions { display: flex; gap: 8px; margin-top: 8px; }
.fb-send, .fb-cancel {
  font-size: 13px; padding: 7px 16px; border-radius: 8px; cursor: pointer; border: none;
}
.fb-send { background: #f5a623; color: #16233b; font-weight: 600; }
.fb-send:disabled { opacity: .6; cursor: default; }
.fb-cancel { background: #eef1f6; color: #5b6b82; }
.fb-done { font-size: 13px; color: #1c7a4a; font-weight: 500; }
.fb-err { font-size: 13px; color: #c0392b; margin-top: 8px; }

/* --- Administratoriaus pranešimų puslapis --- */
.admin { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; }
.admin-head { display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.admin-head h2 { margin: 0; font-size: 20px; color: #16233b; }
.filters { display: flex; gap: 8px; }
.filter { font-size: 13px; padding: 6px 14px; border-radius: 999px; text-decoration: none;
  color: #5b6b82; border: 1px solid #d6dde8; }
.filter.on { background: #16233b; color: #fff; border-color: #16233b; }
.badge { background: #f5a623; color: #16233b; font-weight: 700; font-size: 11px;
  padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.empty { color: #5b6b82; }

.fb-card { background: #fff; border: 1px solid #e7ecf3; border-left: 3px solid #f5a623;
  border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; }
.fb-card.done { border-left-color: #cbd5e1; opacity: .72; }
.fb-card-head { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 12px; }
.fb-card .when { font-size: 12px; color: #8794a8; margin-left: 10px; }
.fb-card .mark { font-size: 12px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid #d6dde8; background: none; color: #5b6b82; cursor: pointer; }
.fb-card .mark:hover { border-color: #16233b; color: #16233b; }
.fb-card .block { margin-top: 12px; }
.fb-card h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: #8794a8; }
.fb-card .block p { margin: 0; font-size: 14px; line-height: 1.55; }
.fb-card .note { background: #fff8ec; border-radius: 8px; padding: 10px 12px; }
.fb-card summary { font-size: 13px; color: #5b6b82; cursor: pointer; padding: 4px 0; }
.fb-card summary:hover { color: #16233b; }
.fb-card pre { white-space: pre-wrap; word-wrap: break-word; font: inherit;
  font-size: 13px; line-height: 1.55; background: #f6f8fb; border-radius: 8px;
  padding: 12px; margin: 6px 0 0; max-height: 420px; overflow-y: auto; }

/* --- Srautinis atsakymas + šaltinių išskleidimas --- */
/* Kad scrollIntoView neužlįstų po lipnia viršutine juosta */
.msg-row { scroll-margin-top: 70px; }

/* Būsena („Ieškoma…") kol modelis dirba */
.status { color: var(--muted); font-size: .92rem; display: flex; align-items: center; gap: .4rem; padding: .1rem 0; }

/* Gyvai rašomas (dar neapdorotas markdown) tekstas */
.md-live { white-space: pre-wrap; line-height: 1.55; }
.md-live::after { content: "▋"; color: var(--orange); animation: caret 1s steps(1) infinite; margin-left: 1px; }
@keyframes caret { 50% { opacity: 0; } }

/* Šaltinių išskleidimas */
.src-toggle {
  margin-top: .5rem; background: none; border: 1px solid var(--border);
  color: var(--navy-soft); font-size: .82rem; padding: .3rem .7rem;
  border-radius: 999px; cursor: pointer;
}
.src-toggle:hover { border-color: var(--orange); color: var(--orange-2); }
.src-more { margin-top: .2rem; }
