:root {
  --bg: #0f1420;
  --surface: #171e2e;
  --surface-2: #1f283c;
  --line: #2a3550;
  --text: #e8ecf5;
  --muted: #9aa6bf;
  --accent: #d4a84b;
  --accent-ink: #1a1405;
  --danger: #ff8a8a;
  --focus: #8ab4ff;
  --radius: 14px;
  --tabs-h: 64px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #eef0f6;
    --line: #d6dbe8;
    --text: #151a28;
    --muted: #5a6479;
    --accent: #9a6d00;
    --accent-ink: #ffffff;
    --danger: #b3261e;
    --focus: #1a5fd0;
  }
}
:root[data-theme="light"] {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #eef0f6; --line: #d6dbe8;
  --text: #151a28; --muted: #5a6479; --accent: #9a6d00; --accent-ink: #ffffff;
  --danger: #b3261e; --focus: #1a5fd0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
/* Nincs nagyítás: sem csippentés, sem dupla koppintás (a beviteli mezők betűmérete 16px, így az iPhone fókuszkor sem nagyít). */
html, body { touch-action: manipulation; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.4rem; line-height: 1.2; }
h2 { font-size: 1.25rem; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.center {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

/* belépés */
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 6px; }
.login-card .logo { border-radius: 14px; margin-bottom: 6px; }
.login-card label { margin-top: 12px; font-size: .9rem; color: var(--muted); }
input {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit;
}
input:focus-visible { outline-offset: 0; }
.msg { margin-top: 10px; font-size: .92rem; color: var(--danger); }
.msg.info { color: var(--muted); }

.btn {
  min-height: 46px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { margin-top: 16px; background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { min-height: 38px; padding: 0 12px; background: transparent; font-weight: 500; }
.btn:disabled { opacity: .6; cursor: progress; }

/* alkalmazáskeret */
#app { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.brand img { border-radius: 7px; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
#userEmail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted);
  font: inherit; font-size: .74rem; font-weight: 600; cursor: pointer;
  min-height: var(--tabs-h);
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); }

.view { padding: 20px 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); width: 100%; max-width: 860px; margin: 0 auto; outline: none; }
.view > header { margin-bottom: 16px; display: flex; flex-direction: column; gap: 4px; }
.empty { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.empty .tag {
  font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
}
.foot { padding: 0 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 8px); text-align: center; }

/* keskeny telefon: az e-mail-cím nem fér el a fejlécben */
@media (max-width: 520px) { #userEmail { display: none; } }

/* események és értesítések */
.view-head { flex-direction: row !important; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px !important; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.btn.primary.small { margin-top: 0; }
.card + .card, .card + .events, .card + .msg { margin-top: 14px; }
.push { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.push h3 { margin: 0; font-size: 1rem; }
.note { font-size: .92rem; color: var(--muted); }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ev {
  position: relative; width: 100%; text-align: left;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px 12px 28px; min-height: 56px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; cursor: pointer;
}
.ev-title { font-weight: 600; overflow-wrap: anywhere; }
.ev-sum { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.ev-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; color: var(--muted); font-size: .8rem; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.ev.unread { border-color: var(--accent); }
.ev.unread::before {
  content: ""; position: absolute; left: 11px; top: 17px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
}
.ev:not(.unread) .ev-title { font-weight: 500; }

/* Esemény részletei */
.det-title { overflow-wrap: anywhere; }
.line.det { align-items: baseline; }
.det-v { font-weight: 600; text-align: right; overflow-wrap: anywhere; min-width: 0; }
.view-head + .card { margin-top: 12px; }

/* Archiválás */
.ev-row { display: flex; gap: 8px; align-items: stretch; }
.ev-row .ev { flex: 1; min-width: 0; width: auto; }
.ev-act {
  flex: none; width: 68px; padding: 0 4px;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: .74rem; font-weight: 600; cursor: pointer;
}
.seg { display: flex; gap: 6px; margin: 0 0 12px; }
.seg-b {
  flex: 1; min-height: 40px; padding: 0 10px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: .92rem; cursor: pointer;
}
.seg-b.on { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
.det-act { margin-top: 14px; }
.view-head + .seg { margin-top: 12px; }

.tab { position: relative; }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: .68rem; font-weight: 800; line-height: 18px; text-align: center;
}

/* Teljesítmény, Postaláda, Hozzáférések */
.block { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.block h3 { margin: 0; font-size: 1.05rem; }
.block h4 { margin: 10px 0 0; font-size: .95rem; }
.view-head p { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.kpi strong { font-size: 1.25rem; line-height: 1.25; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.line-l { display: flex; flex-direction: column; min-width: 0; }
.line-name { font-weight: 600; overflow-wrap: anywhere; }
.line-v { font-weight: 700; white-space: nowrap; text-align: right; }
.obs { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.obs p { margin: 0; color: var(--muted); font-size: .95rem; }
.acc { padding: 8px 0; border-top: 1px solid var(--line); }
.acc p { margin: 2px 0 0; font-size: .92rem; }
.acc-t { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: #4caf7a; } .dot.resz { background: #e3a33b; } .dot.nincs { background: #d96b6b; }
.push-chip { color: var(--accent); border-color: var(--accent); }
:root { --c0: #d4a84b; --c1: #5aa9e6; --c2: #7bc67e; --c3: #e07a5f; --c4: #b08fd8; --c5: #8c97ad; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --c0: #9a6d00; --c1: #1f6fb5; --c2: #2f8f4e; --c3: #c2492b; --c4: #7a55b3; --c5: #5a6479; } }
:root[data-theme="light"] { --c0: #9a6d00; --c1: #1f6fb5; --c2: #2f8f4e; --c3: #c2492b; --c4: #7a55b3; --c5: #5a6479; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 6px; }
.bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 4px; }
.bar-stack { flex: 1; display: flex; flex-direction: column-reverse; justify-content: flex-start; }
.bar { width: 100%; min-height: 1px; }
.bar.c0 { background: var(--c0); } .bar.c1 { background: var(--c1); } .bar.c2 { background: var(--c2); }
.bar.c3 { background: var(--c3); } .bar.c4 { background: var(--c4); } .bar.c5 { background: var(--c5); }
.bar-label { font-size: .62rem; color: var(--muted); text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .8rem; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.c0 { background: var(--c0); } .sw.c1 { background: var(--c1); } .sw.c2 { background: var(--c2); }
.sw.c3 { background: var(--c3); } .sw.c4 { background: var(--c4); } .sw.c5 { background: var(--c5); }
@media (max-width: 520px) { .tab { font-size: .64rem; letter-spacing: -.01em; } .bar-label { font-size: .55rem; } }
@media (max-width: 360px) { .tab { font-size: .58rem; } }

/* Utasítások, Beállítások */
textarea, select {
  width: 100%; padding: 10px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 16px; /* 16px: az iPhone fókuszkor nem nagyít */
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
select { min-height: 46px; }
.compose .row { justify-content: flex-start; }
.compose .btn.primary.small { margin-left: auto; }
.btn.listening { border-color: var(--accent); color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.field label { font-size: .9rem; }
.note a { color: var(--accent); font-weight: 600; }
.cmd { cursor: default; gap: 8px; }
.cmd-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmd-valasz { border-left: 3px solid var(--accent); padding: 6px 10px; background: var(--surface-2); border-radius: 8px; }
.cmd-valasz strong { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 2px; }
.cmd-valasz p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmd-naplo { font-size: .85rem; color: var(--muted); }
.cmd-naplo summary { cursor: pointer; }
.cmd-naplo ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.chip.st-uj { color: var(--accent); border-color: var(--accent); }
.chip.st-folyamatban { color: var(--c1); border-color: var(--c1); }
.chip.st-kesz { color: var(--c2); border-color: var(--c2); }
.chip.st-hiba { color: var(--danger); border-color: var(--danger); }
.card.block .msg { margin-top: 0; }

/* széles képernyő: oldalsáv */
@media (min-width: 860px) {
  #app { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto 1fr auto; }
  .top { grid-column: 1 / -1; }
  .tabs {
    position: sticky; top: 58px; align-self: start; grid-column: 1; grid-row: 2 / 4;
    height: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
    background: transparent; border-top: 0; border-right: 1px solid var(--line);
    min-height: calc(100dvh - 58px);
  }
  .tab { flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; font-size: .95rem; }
  .tab[aria-current="page"] { background: var(--surface-2); }
  .badge { position: static; margin-left: auto; }
  .view { grid-column: 2; grid-row: 2; margin: 0; padding-bottom: 32px; max-width: 960px; }
  .foot { grid-column: 2; padding-bottom: 12px; text-align: left; }
  #userEmail { max-width: 260px; }
}

/* Hirdetések: Aktív / Összes szűrő és lenyitható kampányrészletek (<details>, szkript nélkül) */
.ad-seg { margin: 4px 0 6px; }
.camp { border-top: 1px solid var(--line); }
.camp-sum { list-style: none; cursor: pointer; }
.camp-sum::-webkit-details-marker { display: none; }
.camp-sum .line { border-top: 0; }
.camp-sum .line-name::after { content: " ›"; color: var(--muted); font-weight: 400; }
.camp[open] .camp-sum .line-name::after { content: " ⌄"; }
.camp-sum .chip { align-self: flex-start; margin-top: 4px; }
.chip.st-nem { color: var(--muted); }
.camp-body { padding: 2px 0 12px 10px; border-left: 2px solid var(--line); margin-bottom: 8px; }
.camp-r { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; padding: 6px 0; }
.camp-r + .camp-r { border-top: 1px dashed var(--line); }
.camp-k { font-weight: 600; font-size: .92rem; }
.camp-v { font-weight: 700; font-size: .92rem; text-align: right; overflow-wrap: anywhere; }
.camp-mi { grid-column: 1 / -1; }
