*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.62 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 500; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.2; }
h2 { font-size: clamp(24px, 3vw, 32px); line-height: 1.25; }
h3 { font-size: 20px; line-height: 1.35; }
h4 { font-size: 17px; line-height: 1.4; }
p { margin: 0; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; line-height: 20px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip-link:focus { top: 12px; }

/* ---------- appskal ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.shell.collapsed { grid-template-columns: 76px 1fr; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 22px 14px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; text-decoration: none; color: var(--sidebar-text); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: #1c1c1c; display: grid; place-items: center; flex: none; }
.brand-name { font-family: var(--font-head); font-size: 19px; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; }
.brand-name b { color: var(--accent); font-weight: 500; }
.side-label { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-muted); padding: 0 10px; margin: 6px 0 8px; }
.site-card { border: 1px solid var(--sidebar-line); background: #161616; border-radius: 12px; padding: 12px 14px; margin: 0 2px 22px; }
.site-card strong { display: block; font-weight: 500; font-size: 15px; }
.site-card span { color: var(--sidebar-muted); font-size: 13px; }
.site-select { display: block; width: calc(100% - 4px); margin: 0 2px 22px; appearance: none; min-height: 48px; padding: 12px 36px 12px 14px; border: 1px solid var(--sidebar-line); border-radius: 12px; color: var(--sidebar-text); font: 500 15px var(--font-body); cursor: pointer;
  background: #161616 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239a9a9a' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center; }
.site-select:hover { border-color: var(--sidebar-muted); }
.side-user { margin-top: 10px; overflow-wrap: anywhere; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px; color: var(--sidebar-text);
  text-decoration: none; font-weight: 500; font-size: 15px; white-space: nowrap;
}
.nav a svg { width: 20px; height: 20px; flex: none; stroke: currentColor; }
.nav a:hover { background: #1a1a1a; }
.nav a[aria-current="page"] { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav a[aria-current="page"]::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--sidebar-active-bar); }
.nav a:focus-visible { outline-color: var(--accent); }
.side-foot { margin-top: auto; border-top: 1px solid var(--sidebar-line); padding: 16px 10px 0; font-size: 12.5px; line-height: 1.6; color: var(--sidebar-muted); }
.side-foot b { color: var(--sidebar-text); font-weight: 500; }
.nav-group + .nav-group { margin-top: 18px; }
.nav [hidden] { display: none; }
.shell.collapsed .nav-group + .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--sidebar-line); }
.side-slot { min-height: 0; } /* plats för Logga ut / Anslutningar senare */
.shell.collapsed .brand-name, .shell.collapsed .side-label, .shell.collapsed .site-card, .shell.collapsed .site-select,
.shell.collapsed .nav a span, .shell.collapsed .side-foot { display: none; }
.shell.collapsed .nav a { justify-content: center; padding: 12px 0; }
.shell.collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px clamp(16px, 4vw, 48px) 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text);
}
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; }
.icon-btn:hover { border-color: var(--text-muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 13.5px; color: var(--text); white-space: nowrap; }
.content { width: 100%; max-width: calc(var(--content-max) + 2 * clamp(16px, 4vw, 48px)); padding: 26px clamp(16px, 4vw, 48px) 64px; }
.view-head { margin-bottom: 30px; }
.view-head p { color: var(--text-muted); margin-top: 6px; font-size: 17px; }
.stack > * + * { margin-top: var(--gap); }
.section { margin-top: 44px; }
.section > h3 { margin-bottom: 4px; }
.section > .section-sub { color: var(--text-muted); margin-bottom: 16px; }
.grid { display: grid; gap: var(--gap); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.mobile-bar { display: none; }
.scrim { display: none; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
  .shell.collapsed .brand-name, .shell.collapsed .side-label, .shell.collapsed .site-card, .shell.collapsed .site-select,
  .shell.collapsed .nav a span, .shell.collapsed .side-foot { display: revert; }
  .shell.collapsed .nav a { justify-content: flex-start; padding: 11px 12px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding-top: 14px; }
  .chip.domain { display: none; }
  .view-head p { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
