/* Shared sidebar + top bar. Self-contained so /reports pages can include this
   file without the chart pages' styles. Colors follow html[data-theme]. */

:root, [data-theme="light"] {
  --shell-sidebar: #ffffff;
  --shell-top: #f7f7f8;
  --shell-ink: #1a1a1a;
  --shell-nav: #3d4450;
  --shell-muted: #6d7580;
  --shell-border: #e4e6ea;
  --shell-hover: #f0f2f4;
  --shell-active-bg: #eef5e4;
  --shell-active: #3f6b1d;
  --shell-page: #f2f2f2;
  --shell-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
[data-theme="dark"] {
  --shell-sidebar: #171a1f;
  --shell-top: #12151a;
  --shell-ink: #e9ebee;
  --shell-nav: #c5cad1;
  --shell-muted: #8b939e;
  --shell-border: #2b3038;
  --shell-hover: #22262d;
  --shell-active-bg: rgba(140, 193, 82, 0.16);
  --shell-active: #c6e89a;
  --shell-page: #0e1013;
  --shell-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

html, body {
  margin: 0;
  height: 100%;
}
body {
  background: var(--shell-page);
  color: var(--shell-ink);
}
.app-frame {
  display: flex;
  align-items: stretch;
  height: 100vh;
  height: 100dvh;
  background: var(--shell-page);
  color: var(--shell-ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.app-sidebar {
  box-sizing: border-box;
  width: 248px;
  flex: 0 0 248px;
  display: flex;
  flex-direction: column;
  background: var(--shell-sidebar);
  border-right: 1px solid var(--shell-border);
  color: var(--shell-ink);
  overflow: hidden;
  transition: width 0.18s ease, flex-basis 0.18s ease;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 12px 6px;
  padding: 4px 6px;
  min-height: 40px;
  color: var(--shell-ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  line-height: 1.2;
  border-radius: 8px;
}
.app-brand:hover { background: var(--shell-hover); }
.app-brand img {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
  display: block;
}
.app-brand-name { min-width: 0; }
.app-nav {
  flex: 1 1 auto;
  overflow: auto;
  padding: 6px 0 10px;
}
.app-section {
  margin: 16px 18px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--shell-muted);
}
.app-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1px 8px;
  padding: 0 10px;
  min-height: 38px;
  border-radius: 8px;
  color: var(--shell-nav);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.app-nav a svg { width: 18px; height: 18px; flex: 0 0 18px; }
.app-nav a:hover { background: var(--shell-hover); color: var(--shell-ink); }
.app-nav a[aria-current="page"] {
  background: var(--shell-active-bg);
  color: var(--shell-active);
}
.app-nav a:focus-visible,
.app-brand:focus-visible,
.app-collapse:focus-visible,
.app-menu:focus-visible,
.app-theme:focus-visible {
  outline: 2px solid #7fb0ff;
  outline-offset: 2px;
}
.app-collapse {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px 18px 14px;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--shell-border);
  background: transparent;
  color: var(--shell-muted);
  font: 600 13px/1 "Helvetica Neue", Helvetica, Arial, sans-serif;
  cursor: pointer;
  text-align: left;
}
.app-collapse:hover { color: var(--shell-ink); background: var(--shell-hover); }
.app-collapse svg { width: 18px; height: 18px; flex: 0 0 18px; transition: transform 0.18s ease; }
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.app-topbar {
  box-sizing: border-box;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 12px 0 18px;
  background: var(--shell-top);
  border-bottom: 1px solid var(--shell-border);
  color: var(--shell-ink);
}
.app-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.app-menu, .app-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--shell-border);
  background: var(--shell-sidebar);
  color: var(--shell-ink);
  cursor: pointer;
}
.app-menu { display: none; }
.app-menu:hover, .app-theme:hover { background: var(--shell-hover); }
.app-menu svg, .app-theme svg { width: 18px; height: 18px; display: block; }
[data-theme="dark"] .app-theme .icon-moon { display: none; }
[data-theme="light"] .app-theme .icon-sun { display: none; }
.app-content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}
.app-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.48);
  cursor: pointer;
}

@media (min-width: 801px) {
  html[data-sidebar="collapsed"] .app-sidebar { width: 72px; flex-basis: 72px; }
  html[data-sidebar="collapsed"] .app-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  html[data-sidebar="collapsed"] .app-brand-name,
  html[data-sidebar="collapsed"] .app-section,
  html[data-sidebar="collapsed"] .app-label,
  html[data-sidebar="collapsed"] .app-collapse-label { display: none; }
  html[data-sidebar="collapsed"] .app-nav a,
  html[data-sidebar="collapsed"] .app-collapse { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
  html[data-sidebar="collapsed"] .app-collapse svg { transform: rotate(180deg); }
}

@media (max-width: 800px) {
  .app-menu { display: inline-flex; }
  .app-collapse { display: none; }
  .app-sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    flex: none;
    height: auto;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: none;
  }
  html[data-drawer="open"] .app-sidebar {
    transform: translateX(0);
    box-shadow: var(--shell-shadow);
  }
  html[data-drawer="open"] .app-backdrop { display: block; }
  html[data-drawer="open"] .app-content { overflow: hidden; }
  .app-topbar { padding-left: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar, .app-collapse svg { transition: none; }
}
