* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  font-size: 14px;
  font-family: "Roboto", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  color: var(--text);
  background: var(--bg-page);
}

body.app-page {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.public-page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

a {
  text-decoration: none;
}

.page-enter {
  animation: pageEnter 240ms ease both;
}

body.page-leaving .page-enter {
  opacity: 0.16;
  transition: opacity 180ms ease;
}

@keyframes pageEnter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.public-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: auto;
  background: var(--bg-page);
}

.app-layout {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #F5F7FA 0%, #EEF5FA 100%);
}

.mobile-app-header,
.sidebar-backdrop {
  display: none;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid rgba(226, 232, 240, 0.9);
  padding: 16px 12px;
  transition: width 220ms ease;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

.main-area {
  flex: 1;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 14px 18px 18px;
  position: relative;
  overflow: hidden;
}

.topbar {
  height: 18px;
  margin-bottom: 8px;
}

.content-shell {
  position: relative;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-lg);
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  min-height: 0;
  padding: 20px 22px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.07);
  overflow: auto;
  overscroll-behavior: contain;
}

.content-shell::before {
  display: none;
}

.page-header {
  margin-bottom: 14px;
}

.page-header-compact {
  margin-bottom: 12px;
}

.page-title {
  margin: 0;
  font-size: 1.34rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.page-subtitle {
  margin-top: 5px;
  max-width: 860px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

@media (max-width: 900px) {
  body.public-page:not(.auth-body) {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.public-page:not(.auth-body) .public-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  body.app-page {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.app-page.mobile-sidebar-open {
    overflow: hidden;
  }

  .app-layout {
    position: relative;
    inset: auto;
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .mobile-app-header {
    position: sticky;
    top: 0;
    z-index: 1100;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.95);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  }

  .mobile-sidebar-toggle {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--green-50);
    color: var(--green-700);
    cursor: pointer;
  }

  .mobile-sidebar-toggle .material-icons {
    font-size: 24px;
  }

  .mobile-app-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  .mobile-app-brand img {
    width: min(144px, 44vw);
    max-height: 38px;
    object-fit: contain;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: block;
    background: rgba(15, 23, 42, 0.32);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .app-layout.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar,
  .sidebar-collapsed .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1300;
    width: min(318px, calc(100vw - 44px));
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    border-right: 1px solid rgba(226, 232, 240, 0.95);
    border-bottom: 0;
    box-shadow: 18px 0 42px rgba(15, 23, 42, 0.18);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform 220ms ease, visibility 0s linear 220ms;
  }

  .app-layout.sidebar-mobile-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    transition-delay: 0s;
  }

  .main-area {
    height: auto;
    min-height: calc(100vh - 56px);
    min-height: calc(100dvh - 56px);
    overflow: visible;
    padding: 10px;
  }

  .content-shell {
    height: auto;
    min-height: calc(100vh - 76px);
    min-height: calc(100dvh - 76px);
    overflow: visible;
    padding: 16px;
    border-radius: var(--radius-lg);
  }

  .topbar {
    display: none;
  }
}
