/* Shell layout: fixed sidebar + scrollable content column */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}

.brand {
  padding: 6px 10px 22px;
}
.brand .brand-name { font-family: var(--font-display); font-size: 19px; color: var(--text); }
.brand .brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; letter-spacing: .02em; }

.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 0 10px 8px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: background .12s, color .12s;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent-text); }
.nav-link .nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.nav-link .nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; background: var(--surface-3);
  color: var(--text-dim); border-radius: 0; padding: 1px 7px; min-width: 18px; text-align: center;
}
.nav-link.active .nav-badge { background: var(--accent); color: #1a0f08; }

.sidebar-footer { margin-top: auto; padding: 10px; font-size: 11px; color: var(--muted); }
.sidebar-footer button {
  width: 100%; margin-top: 8px; background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: var(--radius-sm); padding: 7px; font-size: 12px; cursor: pointer;
}
.sidebar-footer button:hover { color: var(--text); border-color: var(--border-strong); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 36px 44px 80px;
}

.content-col { max-width: var(--content-max); margin: 0 auto; }

.page-header { margin-bottom: 28px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 28px; }
.page-header .page-sub { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
/* Wraps rather than pushing the viewport: .page-header already wraps, but this
   row is a single non-wrapping flex line, so a fourth button (the Value Page
   editor's "Aufrufe zurücksetzen") dragged the whole page 240px sideways at
   390px. Same failure the .tabs row had. */
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Mobile top bar + hamburger: hidden entirely above the breakpoint so it never
   affects desktop. Sits above the .sidebar drawer (higher z-index) so the
   button stays clickable while the drawer is closed or open. */
.mobile-topbar { display: none; }

@media (max-width: 1000px) {
  /* The old rule here (position: static; width: 100%; flex-direction: row)
     tried to lay the sidebar out as a horizontal strip, but only the sidebar's
     *direct* children (.brand/#nav-container/.sidebar-footer) are flex items —
     the actual nav links one level down stay a plain vertical block list. With
     the sidebar back in normal flow at width:100%, it and .main (flex:1) both
     fight for the same row and the sidebar's full-height nav column wins,
     which is the "nav takes over the whole screen, content unreachable" bug.
     Fix: keep the sidebar a fixed-position drawer (as it already is on
     desktop) but park it off-screen by default and slide it in on demand,
     instead of trying to reflow it inline. */
  .sidebar {
    z-index: 700;
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: min(82vw, 300px);
    box-shadow: var(--shadow);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 650;
  }
  .sidebar-backdrop.mobile-open { display: block; }

  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 300;
    margin: -24px -20px 20px;
    padding: 14px 20px;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mobile-topbar .brand-name { font-family: var(--font-display); font-size: 17px; }
  .mobile-menu-btn {
    background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); padding: 7px; cursor: pointer; display: inline-flex; flex-shrink: 0;
  }
  .mobile-menu-btn:hover { border-color: var(--border-strong); }

  .main { margin-left: 0; padding: 24px 20px 60px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Nothing collapsed to a single column before, so on a phone two cards shared
   ~420px and their contents pushed the whole page into horizontal scroll
   (found on the Analytics gauges, but the Dashboard had it too). */
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Gate screen */
.gate-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 0%, #1a1310 0%, var(--bg) 60%);
}
.gate-card { width: 340px; text-align: center; }
.gate-card .brand-name { font-family: var(--font-display); font-size: 26px; margin-bottom: 6px; }
.gate-card .gate-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* The sidebar is flat now (no group labels, see NAV in app.js), so the only
   thing separating the bottom block is this rule. .nav-group-label above is
   kept for the per-client contextual sidebar that will replace all of this. */
.nav-group + .nav-group { border-top: 1px solid var(--border); padding-top: 18px; }
