* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  max-width: 1280px;
  margin: 32px auto;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.52);
  border-radius: 32px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 28px 20px;
  background: var(--surface-muted);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 650;
}

.brand-mark {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid var(--brand-secondary);
  border-radius: 50%;
  color: var(--brand-primary);
  font-size: 15px;
  font-weight: 750;
}

.sidebar-nav,
.sidebar-footer {
  display: grid;
  gap: 8px;
}

.sidebar-footer {
  margin-top: auto;
}

.main-area {
  min-width: 0;
  background: var(--surface-muted);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  padding: 20px var(--space-page);
}

.mobile-brand {
  display: none;
}

.content {
  display: grid;
  gap: 16px;
  padding: 0 var(--space-page) var(--space-page);
}

.page-heading,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-heading h1,
.panel-header h2 {
  margin: 0;
  font-weight: 620;
  letter-spacing: 0;
}

.page-heading h1 {
  font-size: clamp(2rem, 2rem + 0vw, 2rem);
}

.panel-header h2 {
  font-size: 1.25rem;
}

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

.bottom-nav {
  display: none;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

@media (max-width: 1023px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    display: none;
  }

  .mobile-brand {
    display: inline-flex;
  }
}

@media (max-width: 767px) {
  :root {
    --space-page: 16px;
  }

  .topbar {
    min-height: 68px;
  }

  .content {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .page-heading,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
}
