/* App shell + auth layouts */

.page {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell {
  display: flex;
  flex: 1;
  min-height: 0;
}

.shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--canvas);
}

.app-main {
  flex: 1;
  padding: 0;
}

.app-main > .content.wrap,
.content.wrap {
  padding-top: var(--space-32);
  padding-bottom: calc(var(--space-48) + 4.5rem);
}

@media (min-width: 900px) {
  .app-main > .content.wrap,
  .content.wrap {
    padding-top: var(--space-40, 2.5rem);
    padding-bottom: var(--space-48);
  }
}

/* Sidebar */
.sidebar-nav {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--bdr);
  padding: 1.5rem 1rem 1.25rem;
  display: none;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

@media (min-width: 900px) {
  .sidebar-nav.desktop-only {
    display: flex;
  }
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  margin: 0 .5rem 1.75rem;
  color: var(--ink);
  text-decoration: none;
}

.sidebar-brand img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.sidebar-brand-text {
  font-family: var(--fh);
  font-weight: 650;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem .85rem;
  border-radius: 12px;
  color: var(--ink2);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 520;
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-link .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: .8;
}

.nav-link .nav-icon svg {
  width: 20px;
  height: 20px;
}

.nav-link:hover {
  background: var(--surface2);
  color: var(--ink);
}

.nav-link.active {
  background: var(--blue-soft);
  color: var(--blue2);
  font-weight: 650;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--blue);
}

.nav-link.active .nav-icon {
  opacity: 1;
  color: var(--blue);
}

.nav-badge {
  background: var(--blue2);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .45rem;
  border-radius: var(--r-pill);
  margin-left: auto;
  min-width: 1.25rem;
  text-align: center;
}

.nav-dropdown { position: relative; }

.nav-dropdown-menu {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  margin: .2rem 0 .35rem .55rem;
  padding-left: .55rem;
  border-left: 1px solid var(--bdr);
}

.nav-dropdown-menu a {
  color: var(--ink2);
  text-decoration: none;
  padding: .5rem .7rem;
  border-radius: 10px;
  font-size: .9rem;
}

.nav-dropdown-menu a:hover {
  background: var(--surface2);
  color: var(--ink);
}

.nav-caret {
  margin-left: auto;
  opacity: .55;
  font-size: .75rem;
}

.sidebar-footer {
  padding-top: 1rem;
  margin-top: .5rem;
  border-top: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding-inline: .5rem;
}

.sidebar-footer-user {
  font-size: .85rem;
  font-weight: 560;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-signout {
  align-self: flex-start;
  font-size: .85rem;
  color: var(--ink2) !important;
}

.sidebar-signout:hover { color: var(--ink) !important; }

/* Mobile header */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.15rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bdr);
  position: sticky;
  top: 0;
  z-index: 30;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-family: var(--fh);
  font-weight: 650;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.1rem;
}

.app-brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.app-header-user {
  margin-left: auto;
  font-size: .85rem;
}

/* Bottom tabs */
.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--bdr);
  z-index: 100;
  padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
}

.tab-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  padding: .45rem .2rem;
  color: var(--ink3);
  text-decoration: none;
  border: none;
  background: none;
  font: inherit;
  font-size: .68rem;
  font-weight: 560;
  cursor: pointer;
  position: relative;
  border-radius: 10px;
}

.tab-link .tab-icon,
.tab-link .tab-icon svg {
  width: 22px;
  height: 22px;
}

.tab-link.active {
  color: var(--blue2);
}

.tab-link.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 28%;
  right: 28%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--blue);
}

.tab-link .nav-badge {
  position: absolute;
  top: .2rem;
  right: calc(50% - 1.4rem);
  margin: 0;
  font-size: .65rem;
  min-width: 1.05rem;
  padding: .1rem .3rem;
}

.more-sheet {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  animation: fadeUp .2s ease;
}

.more-sheet-panel {
  width: 100%;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: .15rem;
  box-shadow: var(--shadow3);
}

.more-sheet-panel a {
  padding: .95rem 1rem;
  border-radius: 12px;
  color: var(--ink);
  font-weight: 550;
  text-decoration: none;
}

.more-sheet-panel a:hover { background: var(--surface2); }

/* Banners */
.offline-banner {
  background: #0f172a;
  color: #f8fafc;
  padding: .65rem 1rem;
  text-align: center;
  font-size: .875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  z-index: 50;
}

.session-unavailable-banner { background: #7c2d12; }

/* Auth split layout */
.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--canvas, var(--cream, #faf8f5));
}

.auth-brand-panel {
  display: none;
  background: var(--auth-panel, linear-gradient(145deg, #0b1a2e 0%, #12263f 48%, #0e3a5c 100%));
  color: #f8fafc;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.auth-brand-panel::after {
  content: '';
  position: absolute;
  inset: auto -20% -30% 20%;
  height: 70%;
  background: radial-gradient(circle at center, rgba(0, 212, 255, .22), transparent 65%);
  pointer-events: none;
}

.auth-brand-panel-inner {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  margin: auto 0;
  animation: fadeUp .55s ease both;
}

.auth-brand-panel .brand-mark { color: #fff; margin-bottom: 2.5rem; }
.auth-brand-panel .brand-mark-text { color: #fff; font-size: 1.45rem; }

.auth-brand-headline {
  font-family: var(--fh);
  font-size: clamp(2rem, 3vw, 2.65rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  color: #fff;
}

.auth-brand-copy {
  color: rgba(248, 250, 252, .78);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 24rem;
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 2.5rem;
}

.auth-form-inner {
  width: 100%;
  max-width: 420px;
  animation: fadeUp .45s ease both;
}

.auth-mobile-brand {
  display: inline-flex;
  margin-bottom: 1.75rem;
  color: var(--ink);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--bdr-card);
  border-radius: calc(var(--r2) + 4px);
  box-shadow: var(--shadow2);
  padding: 1.75rem 1.6rem 1.5rem;
  margin-bottom: 0;
}

.auth-card .page-header {
  margin-bottom: 1.5rem;
}

.auth-card .page-header h1 {
  font-size: 1.75rem;
}

.auth-links {
  margin-top: 1.25rem;
  text-align: center;
  color: var(--ink2);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .9rem;
}

@media (min-width: 960px) {
  .auth-layout {
    grid-template-columns: minmax(320px, 1.05fr) minmax(380px, 1fr);
  }

  .auth-brand-panel { display: flex; }

  .auth-mobile-brand { display: none; }

  .auth-form-panel {
    padding: 3rem;
    background: var(--canvas, var(--cream, #faf8f5));
  }

  .auth-card {
    box-shadow: var(--shadow3);
    padding: 2rem 2rem 1.75rem;
  }
}
