*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* A színek a hírfolyaméval egyeznek, így a beágyazott oldal és a keret egy egésznek látszik. */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #1c1f2a;
  --text-2: #3a3f50;
  --muted: #6b7185;
  --border: #e3e6ee;
  --accent: #4f46e5;
  --accent-soft: #eceefe;
  --scrim: rgba(15, 17, 23, 0.45);
  --tooltip-bg: #1c1f2a;
  --tooltip-text: #ffffff;
  --shadow-drawer: 0 0 0 1px rgba(20, 24, 40, 0.04), 0 16px 48px rgba(20, 24, 40, 0.18);

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 68px;
  --head-h: 64px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1f2330;
    --text: #e7e9f0;
    --text-2: #c5c9d6;
    --muted: #9298ab;
    --border: #2a2f3d;
    --accent: #818cf8;
    --accent-soft: #252850;
    --scrim: rgba(0, 0, 0, 0.55);
    --tooltip-bg: #e7e9f0;
    --tooltip-text: #0f1117;
    --shadow-drawer: 0 16px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Betöltéskor ne animáljon (például a megjegyzett összecsukott menü ne csukódjon be a szemed előtt). */
.no-anim *,
.no-anim *::before,
.no-anim *::after {
  transition: none !important;
}

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Menü (bal oldali sáv) ---------- */

.sidebar {
  display: flex;
  flex: none;
  flex-direction: column;
  width: var(--sidebar-w);
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 0.24s var(--ease);
}

.sidebar-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: var(--head-h);
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-collapse path:last-child {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.24s var(--ease);
}

.icon-close {
  display: none;
}

.brand {
  overflow: hidden;
  border-radius: 6px;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s, visibility 0.15s;
}

.brand-tld {
  color: var(--accent);
}

.nav {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 14px 20px;
  scrollbar-width: thin;
}

.nav-group + .nav-group {
  margin-top: 14px;
}

.nav-label {
  position: relative;
  display: flex;
  align-items: center;
  height: 28px;
  margin: 0;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-label-text {
  transition: opacity 0.15s;
}

/* Összecsukva a csoport címe helyett egy vékony vonal választja el a csoportokat. */
.nav-label::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 8px;
  width: 24px;
  height: 1px;
  background: var(--border);
  opacity: 0;
  transition: opacity 0.15s;
}

.nav-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-entry {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 0.94rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 20px;
  height: 20px;
}

.nav-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding-right: 26px;
  text-overflow: ellipsis;
  transition: opacity 0.15s;
}

/* „Megnyitás új lapon”: a mintán látható × helyén, csak rámutatáskor jelenik meg. */
.nav-ext {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 0.15s, background-color 0.15s, color 0.15s;
}

.nav-entry:hover .nav-ext,
.nav-ext:focus-visible {
  opacity: 1;
}

.nav-ext:hover {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text);
}

@media (hover: none) {
  .nav-ext {
    opacity: 0.8;
  }
}

/* ---------- Összecsukott menü (csak széles képernyőn) ---------- */

@media (min-width: 768px) {
  .menu-collapsed .sidebar {
    width: var(--sidebar-w-collapsed);
  }

  .menu-collapsed .icon-collapse path:last-child {
    transform: scaleX(-1);
  }

  .menu-collapsed .brand,
  .menu-collapsed .nav-ext {
    visibility: hidden;
    opacity: 0;
  }

  .menu-collapsed .nav-text,
  .menu-collapsed .nav-label-text {
    opacity: 0;
  }

  .menu-collapsed .nav-label::after {
    opacity: 1;
  }

  .menu-collapsed .nav {
    scrollbar-width: none;
  }
}

/* ---------- Tartalom ---------- */

.main {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.topbar,
.scrim {
  display: none;
}

.frames {
  position: relative;
  flex: 1;
  min-height: 0;
}

.frames iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

/* Betöltés közben vékony csík fut a tartalom tetején (csak ha a betöltés nem azonnali). */
.progress {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  animation: progress-in 0.2s 0.15s forwards;
  pointer-events: none;
}

.progress::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: progress-run 1.1s ease-in-out infinite;
}

@keyframes progress-in {
  to {
    opacity: 1;
  }
}

@keyframes progress-run {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

.message {
  margin: auto;
  max-width: 420px;
  padding: 24px 16px;
  text-align: center;
}

.message h1 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.message p {
  margin: 0;
  color: var(--muted);
}

/* ---------- Buborék (összecsukott menüben a menüpont neve) ---------- */

.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  max-width: 260px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  animation: tooltip-in 0.12s var(--ease);
}

@keyframes tooltip-in {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
}

/* ---------- Keskeny képernyő: a menü kihúzható fiók ---------- */

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(300px, 86vw);
    border-right: 0;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 0.26s var(--ease), visibility 0s 0.26s;
  }

  .drawer-open .sidebar {
    visibility: visible;
    transform: none;
    box-shadow: var(--shadow-drawer);
    transition: transform 0.26s var(--ease);
  }

  .icon-collapse {
    display: none;
  }

  .icon-close {
    display: block;
  }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.26s var(--ease);
  }

  .drawer-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar {
    display: flex;
    flex: none;
    align-items: center;
    gap: 4px;
    height: 52px;
    padding: 0 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .progress::before {
    animation: none;
    width: 100%;
    opacity: 0.6;
  }
}

/* ---------- A menü alja: a belépett felhasználó vagy a Belépés gomb ---------- */

.sidebar-foot {
  flex: none;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

.sidebar-foot .account {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

button.nav-link {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.94rem;
  text-align: left;
  cursor: pointer;
}

.account-name {
  color: var(--text);
  font-weight: 600;
}

.login-link {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.login-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
  filter: brightness(0.97);
}

.message-action {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 22px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.message-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
