:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #eef2f7;
  --text: #172033;
  --text-muted: #657089;
  --text-faint: #8b95a8;
  --border: #e2e7ef;
  --accent: #2864dc;
  --accent-soft: #e8f0ff;
  --success: #197545;
  --success-soft: #e4f5eb;
  --sidebar: #fbfcfe;
  --shadow: 0 12px 32px rgba(29, 42, 68, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #13161c;
  --surface: #1b1f27;
  --surface-raised: #20252e;
  --surface-muted: #282e39;
  --text: #eef2fa;
  --text-muted: #aab4c6;
  --text-faint: #808b9f;
  --border: #303743;
  --accent: #78a6ff;
  --accent-soft: #263b65;
  --success: #70d39d;
  --success-soft: #1e3c2d;
  --sidebar: #171b22;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-width: 1140px;
}

.sidebar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 24px 16px 20px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 14px;
  line-height: 20px;
}

.brand > div > span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 9px;
  background: var(--accent);
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 32%, transparent);
}

.brand-mark span {
  width: 4px;
  border-radius: 2px 2px 1px 1px;
  background: #ffffff;
}

.brand-mark span:nth-child(1) {
  height: 8px;
}

.brand-mark span:nth-child(2) {
  height: 15px;
}

.brand-mark span:nth-child(3) {
  height: 11px;
}

.sample-pill {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  min-height: 28px;
  margin: 28px 8px 20px;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--success) 22%, var(--border));
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 650;
}

.sample-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent);
}

.page-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-label {
  margin: 0 10px 7px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  transition:
    color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.nav-icon {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
  color: currentColor;
}

.nav-icon::before,
.nav-icon::after {
  content: "";
  position: absolute;
  border: 1.7px solid currentColor;
}

.nav-icon--overview::before {
  inset: 3px;
  border-radius: 4px;
}

.nav-icon--overview::after {
  left: 8px;
  bottom: 6px;
  width: 2px;
  height: 6px;
  border: 0;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 4px -4px 0 currentColor, 8px -1px 0 currentColor;
}

.nav-icon--funnel::before {
  top: 3px;
  left: 3px;
  width: 16px;
  height: 5px;
  border-radius: 2px;
  box-shadow: 2px 6px 0 -1px var(--sidebar), 2px 6px 0 0 currentColor, 5px 12px 0 -1px var(--sidebar), 5px 12px 0 0 currentColor;
}

.nav-icon--funnel::after {
  display: none;
}

.nav-icon--pages::before {
  inset: 3px 5px;
  border-radius: 3px;
}

.nav-icon--pages::after {
  left: 8px;
  top: 8px;
  width: 6px;
  height: 1px;
  border-width: 1.5px 0 0;
  box-shadow: 0 4px 0 -0.25px currentColor, 0 8px 0 -0.25px currentColor;
}

.nav-icon--campaigns::before {
  left: 3px;
  bottom: 4px;
  width: 3px;
  height: 7px;
  border: 0;
  border-radius: 1px;
  background: currentColor;
  box-shadow: 6px -4px 0 currentColor, 12px -9px 0 currentColor;
}

.nav-icon--campaigns::after {
  left: 3px;
  top: 4px;
  width: 15px;
  height: 11px;
  border-width: 0 0 1.5px 1.5px;
  transform: skewY(-28deg);
}

.nav-icon--speed::before {
  inset: 3px;
  border-radius: 50%;
  border-bottom-color: transparent;
}

.nav-icon--speed::after {
  left: 10px;
  top: 7px;
  width: 1px;
  height: 7px;
  border: 0;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(42deg);
  transform-origin: bottom;
}

.nav-icon--data::before {
  left: 4px;
  top: 4px;
  width: 14px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 5px 0 -1px var(--sidebar), 0 5px 0 0 currentColor, 0 10px 0 -1px var(--sidebar), 0 10px 0 0 currentColor;
}

.nav-icon--data::after {
  display: none;
}

.sidebar-note {
  margin: auto 8px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.sidebar-note strong {
  font-size: 12px;
}

.sidebar-note p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 17px;
}

.workspace {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.topbar p {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.topbar strong {
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 0 11px 0 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle__track {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background 180ms ease;
}

.theme-toggle__track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition:
    left 180ms cubic-bezier(0.05, 0.7, 0.1, 1),
    background 180ms ease;
}

[data-theme="dark"] .theme-toggle__track {
  background: var(--accent-soft);
}

[data-theme="dark"] .theme-toggle__track span {
  left: 15px;
  background: var(--accent);
}

.reader-frame-wrap {
  min-width: 0;
  min-height: 0;
  padding: 12px;
  background: var(--bg);
}

#dashboard-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.desktop-gate {
  display: none;
}

@media (max-width: 1139px) {
  .app-shell {
    display: none;
  }

  .desktop-gate {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 32px;
    color: var(--text-muted);
    text-align: center;
  }
}

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