:root {
  --topbar-height: 46px;
  --bottom-nav-height: 46px;
  --app-max-width: 1680px;
  --app-min-width: 1024px;
  --app-min-height: 640px;
  --app-max-height: 1080px;
}

html { height: 100%; overflow: hidden; }
body { min-height: 100%; overflow: hidden; overflow-x: hidden; }
.app-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 100dvh; height: 100dvh; overflow: hidden; }
.auth-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 100dvh; height: 100dvh; overflow: hidden; }
.topbar { position: static; z-index: 30; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-height: 42px; padding: 2px 8px 2px 10px; background: rgba(247,249,253,.80); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(221,227,239,.9); gap: 8px; }
.brand { font-weight: 800; letter-spacing: .02em; line-height: 1; font-size: 15px; color: #18213a; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; justify-content: flex-end; min-width: 0; flex-shrink: 0; grid-column: 2; }
.topbar-status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid #d9e2f5; background: rgba(255,255,255,.95); color: #344054; font-size: 12px; font-weight: 700; white-space: nowrap; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
.language-form { margin: 0; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; min-width: 0; white-space: nowrap; }
.language-select { min-height: 34px; padding: 7px 10px; border: 1px solid #cfd7e6; border-radius: 12px; background: #fff; font: inherit; width: 126px; max-width: 126px; box-shadow: 0 1px 2px rgba(17,24,39,.04); display: block; flex: 0 0 126px; }
.menu-button { display: grid; place-items: center; width: 40px; height: 40px; border: 0; background: linear-gradient(180deg, #eff3ff, #e3e8fb); border-radius: 12px; padding: 0; font-size: 18px; line-height: 1; flex: 0 0 40px; box-shadow: 0 1px 2px rgba(17,24,39,.06); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: min(82vw, 300px); max-width: calc(100vw - 24px); background: #fff; padding: 66px 14px 14px; transform: translateX(-110%); transition: transform .2s ease; z-index: 40; box-shadow: 12px 0 40px rgba(16,24,40,.16); display: grid; gap: 6px; align-content: start; overflow: hidden; }
.sidebar.open { transform: translateX(0); }
.sidebar form { margin: 0; }
.nav-item { display: flex; align-items: center; width: 100%; min-height: 38px; text-align: left; padding: 8px 11px; border-radius: 12px; background: #f3f6fb; border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; line-height: 1.15; color: #172033; box-shadow: 0 1px 2px rgba(17,24,39,.04); }
.nav-item:hover, .nav-item:focus-visible { background: #eef3ff; border-color: #d9e5ff; outline: none; }
.nav-item.is-active { background: linear-gradient(180deg, #ecebff, #e2e7ff); border-color: #c9d2ff; color: #4433b8; box-shadow: inset 0 0 0 1px rgba(90,69,214,.06), 0 1px 2px rgba(17,24,39,.04); }
.nav-item--logout { background: linear-gradient(180deg, #fff1f3, #ffe2e7); color: #b42318; border-color: #f3c1cb; }
.nav-item--logout:hover, .nav-item--logout:focus-visible { background: linear-gradient(180deg, #ffe7ec, #ffd7df); border-color: #ef9cab; }
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.38); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 35; }
.overlay.open { opacity: 1; pointer-events: auto; }

.page-fit-shell {
  --page-fit-scale: 1;
  --page-fit-expand: 1;
  min-height: 0;
  width: 100%;
  display: block;
}

.page-fit-body {
  min-height: 0;
  width: 100%;
}

body.page-fit-full .content {
  overflow: hidden;
}

body.page-fit-full .page-fit-body {
  width: calc(100% / var(--page-fit-scale));
  transform: scale(var(--page-fit-scale));
  transform-origin: top center;
  will-change: transform;
}

@media (max-width: 899px) {
  .page-fit-shell {
    display: block;
  }

  .page-fit-shell[data-page-fit-mode="full"] {
    display: grid;
    align-items: start;
    justify-items: center;
    height: 100%;
    overflow: hidden;
  }

  body.page-fit-full .page-fit-body {
    max-width: 100%;
  }
}

.content { width: min(100%, 1100px); margin: 0 auto; padding: 6px 5px; display: grid; gap: 6px; box-sizing: border-box; min-height: 0; overflow-x: hidden; overflow-y: auto; align-content: start; }
.page-panel { width: 100%; min-height: min-content; display: grid; gap: 12px; box-sizing: border-box; grid-template-rows: auto auto; align-content: start; }
.page-title-section { padding: 8px 12px 12px; margin-bottom: 12px; border-bottom: 1px solid #e3e8f3; }
.page-title, .page-title-section h1 { color: #4433b8; font-size: 1.8rem; line-height: 1.05; margin: 0; }
.page-content { min-height: 0; display: grid; gap: 12px; overflow: visible; align-content: start; }
.auth-card { min-height: 0; display: grid; grid-template-rows: auto 1fr; padding: 0; overflow: hidden; }
.auth-card-body { min-height: 0; display: grid; align-content: start; padding: 0; overflow-y: auto; overflow-x: hidden; }
.auth-form { width: min(100%, 420px); margin: 12px 12px 12px 8px; display: grid; gap: 12px; }
.auth-form label { gap: 6px; }
.bottom-nav { position: static; z-index: 45; height: var(--bottom-nav-height); padding: 0; background: rgba(247,249,253,.98); border-top: 1px solid rgba(217,226,245,.95); box-shadow: 0 -2px 10px rgba(17,24,39,.05); display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; }
.bottom-nav-inner { width: min(100%, 540px); margin: 0 auto; padding: 0 8px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; align-items: center; justify-items: center; height: 100%; box-sizing: border-box; flex-wrap: nowrap; }
.bottom-nav-item,
.bottom-nav-spacer { min-width: 0; min-height: 0; }
.bottom-nav-item { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border-radius: 999px; background: #ffffff; border: 1px solid #d6dfef; box-shadow: 0 1px 2px rgba(17,24,39,.04); color: #243146; text-align: center; box-sizing: border-box; justify-self: center; }
.bottom-nav-spacer { display: block; }
.bottom-nav-item.is-active { background: #ecebff; border-color: #c9d2ff; color: #4433b8; }
.bottom-nav-item--context { background: #f6f8ff; }
.bottom-nav-icon { width: 15px; height: 15px; flex: 0 0 15px; display: block; }
.bottom-nav-label { display: none; }

@media (max-width: 899px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .language-form { max-width: calc(100vw - 84px); overflow: hidden; }
  .language-select { width: auto; max-width: 100%; flex: 0 1 126px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(82vw, 300px); max-width: calc(100vw - 24px); padding: 66px 14px 14px; transform: translateX(-110%); }
  .sidebar.open { transform: translateX(0); }
  .overlay { display: block; }
  .content { padding: 4px 3px; gap: 5px; min-height: 0; width: 100%; max-width: 100%; overflow-x: hidden; overflow-y: auto; }
  .auth-card-body { overflow-y: auto; overflow-x: hidden; }
  .auth-shell,
  .app-shell {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .auth-form {
    width: calc(100% - 16px);
    max-width: 100%;
    margin: 10px 8px 12px;
  }
  .auth-form .input,
  .auth-form select.input,
  .auth-form textarea.input {
    min-height: 30px;
    padding: 5px 8px;
  }
}

@media (min-width: 900px) {
  body {
    padding: 18px;
    display: grid;
    place-items: center;
    overflow: auto;
    min-width: var(--app-min-width);
    min-height: var(--app-min-height);
  }
  .app-shell,
  .auth-shell {
    width: min(var(--app-max-width), calc(100vw - 36px));
    min-width: var(--app-min-width);
    min-height: var(--app-min-height);
    max-width: var(--app-max-width);
    max-height: min(var(--app-max-height), calc(100vh - 36px));
    margin: 0;
    border-radius: 24px;
    box-shadow: 0 18px 40px rgba(19,30,61,.08);
    background: rgba(248, 250, 255, .78);
    backdrop-filter: blur(18px);
    overflow: hidden;
  }
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: start;
    overflow: hidden;
  }
  .auth-shell { overflow: hidden; }
  .topbar { grid-column: 1 / -1; grid-row: 1; }
  .sidebar { position: static; transform: none; width: auto; padding: 18px; margin: 12px 0 12px 12px; height: calc(100% - 24px); max-height: calc(100% - 24px); border-radius: 20px; box-shadow: 0 8px 24px rgba(19,30,61,.04); grid-column: 1; grid-row: 2; align-self: stretch; align-content: start; overflow: auto; }
  .menu-button { display: none; }
  .overlay { display: none; }
  .content { grid-column: 2; grid-row: 2; align-self: stretch; min-width: 0; min-height: 0; width: 100%; max-width: none; padding: 12px 12px 12px 8px; overflow-x: hidden; overflow-y: auto; }
  .bottom-nav { grid-column: 1 / -1; grid-row: 3; }
  .bottom-nav-inner { width: min(100%, 600px); }
  .auth-shell .content { min-height: 0; padding: 12px 12px 12px 8px; display: grid; align-items: start; overflow: hidden; }
  .auth-shell .page-panel { min-width: 0; min-height: 0; }
  .auth-shell .page-content { min-width: 0; }
  .page-panel { min-width: 0; }
  .page-content { align-content: start; }
  .auth-shell .page-panel { grid-template-rows: auto minmax(0, 1fr); }
  .auth-shell .page-content { padding: 0; }
  .auth-shell .auth-card-body { padding: 0; }
  .auth-shell .auth-form { margin: 12px 12px 12px 8px; }
}

@media (max-width: 899px) and (max-height: 760px) {
  :root {
    --topbar-height: 42px;
    --bottom-nav-height: 42px;
  }

  .topbar {
    min-height: 38px;
    padding: 2px 6px 2px 8px;
    gap: 6px;
  }

  .brand {
    font-size: 14px;
  }

  .topbar-actions,
  .language-form {
    gap: 4px;
  }

  .language-select {
    min-height: 30px;
    padding: 5px 8px;
    border-radius: 10px;
  }

  .menu-button {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 10px;
    font-size: 16px;
  }

  .content {
    padding: 3px;
    gap: 4px;
  }

  .page-panel {
    gap: 8px;
  }

  .page-title-section {
    padding: 6px 10px 8px;
    margin-bottom: 8px;
  }

  .page-title,
  .page-title-section h1 {
    font-size: 1.2rem;
    line-height: 1.04;
  }

  .page-content {
    gap: 8px;
  }

  .auth-form {
    gap: 10px;
    margin: 8px 8px 10px;
  }

  .bottom-nav-inner {
    padding: 0 6px;
    gap: 4px;
  }

  .bottom-nav-item {
    width: 34px;
    height: 34px;
  }

  .bottom-nav-icon {
    width: 14px;
    height: 14px;
    flex-basis: 14px;
  }
}

@media (max-width: 899px) and (max-height: 680px) {
  .page-title-section {
    padding: 5px 9px 7px;
    margin-bottom: 6px;
  }

  .page-title,
  .page-title-section h1 {
    font-size: 1.08rem;
  }

  .auth-form {
    gap: 8px;
    margin: 6px 6px 8px;
  }

  .helper-text,
  .muted {
    font-size: 0.84rem;
  }
}
