/* App shell: sidebar (>=1024px), top bar + bottom nav (<1024px), page frame,
   and the sign-in screens. */

/* ------------------------------------------------------------ lockup --- */
.lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.2em;
  font-size: 28px; /* = wordmark size; the mark is 1.4x */
  color: inherit;
  text-decoration: none;
}
.lockup:hover { text-decoration: none; }
.lockup__mark { width: 1.4em; height: 1.4em; }
.lockup__wordmark {
  font-family: var(--font-wordmark);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--color-brand-blue);
  /* optical alignment: the lowercase x-height sits slightly high */
  transform: translateY(-0.04em);
}

/* ------------------------------------------------------------ shell --- */
.main {
  padding: var(--space-4) var(--space-4) calc(var(--bottom-nav-height) + var(--space-5) + env(safe-area-inset-bottom));
}
.main__inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Top bar (phones and tablets) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: calc(var(--topbar-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--space-4) 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-strong);
}
.topbar .lockup { font-size: 26px; }

/* Bottom nav (phones and tablets) */
.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-strong);
}
.bottom-nav__link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: 0;
  color: var(--color-muted-foreground);
  font-size: var(--fs-caption);
  font-weight: 500;
  transition: color var(--motion-ui) var(--ease-standard);
}
.bottom-nav__link:hover { text-decoration: none; color: var(--color-foreground); }
.bottom-nav__link .icon { width: 22px; height: 22px; }
.bottom-nav__link[aria-current='page'] { color: var(--color-action); font-weight: 600; }
.bottom-nav__link[aria-current='page']::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  width: 32px;
  height: 2px;
  margin-left: -16px;
  border-radius: 0 0 2px 2px;
  background: var(--color-action);
}
.bottom-nav__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 400px) {
  .bottom-nav__label { letter-spacing: -0.025em; }
}

/* Sidebar + page bar (desktop) */
.sidebar, .pagebar { display: none; }

@media (min-width: 1024px) {
  .topbar, .bottom-nav { display: none; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    padding: var(--space-6) var(--space-4) var(--space-4);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border-strong);
    overflow-y: auto;
  }
  .main {
    margin-left: var(--sidebar-width);
    padding: 0;
  }
  .main__inner { padding: var(--space-6) var(--space-6) var(--space-7); }

  /* Breadcrumb + refresh, across the top of the content. */
  .pagebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    height: var(--topbar-height);
    padding: 0 var(--space-5) 0 var(--space-6);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-strong);
  }
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-ui);
}
.breadcrumb li { display: flex; align-items: center; gap: var(--space-2); }
.breadcrumb a { color: var(--color-muted-foreground); }
.breadcrumb a:hover { color: var(--color-action); }
.breadcrumb [aria-current='page'] { font-weight: 600; color: var(--color-foreground); }
.breadcrumb__sep { color: var(--color-muted-foreground); }

.sidebar__brand {
  padding: 0 var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
/* The app's name under the logo, as in the other Pribadi apps. */
.sidebar__system {
  margin: var(--space-5) var(--space-3) var(--space-5);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--color-foreground);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-foreground-alt);
  font-weight: 500;
  transition: background-color var(--motion-ui) var(--ease-standard), color var(--motion-ui) var(--ease-standard);
}
.nav__link:hover { background: var(--color-surface-page); text-decoration: none; }
.nav__link[aria-current='page'] {
  background: var(--color-action-tint);
  color: var(--color-action);
  font-weight: 600;
}

.nav__link--button {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 500;
  text-align: left;
}

/* Bottom of the sidebar: who is signed in, and Sign out. */
.sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}
.sidebar__user-meta {
  padding: 0 var(--space-3) var(--space-2);
  font-size: var(--fs-caption);
  color: var(--color-muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__user-meta strong { font-weight: 600; color: var(--color-foreground); }

/* Account menu (phones and tablets): a native popover, no JS needed. */
.account-menu {
  position: fixed;
  inset: calc(var(--topbar-height) + env(safe-area-inset-top) + var(--space-1)) var(--space-4) auto auto;
  width: min(300px, calc(100vw - 2 * var(--space-4)));
  margin: 0;
  padding: var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-foreground-alt);
  box-shadow: var(--shadow-e4);
}
.account-menu__who {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
  border-bottom: 1px solid var(--color-border);
}
.account-menu__who > div { min-width: 0; }
.account-menu__name {
  font-weight: 600;
  color: var(--color-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu__meta { font-size: var(--fs-caption); color: var(--color-muted-foreground); }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--touch-target);
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-foreground-alt);
  font-weight: 500;
  text-align: left;
}
.menu-item:hover { background: var(--color-surface-page); text-decoration: none; }

/* ------------------------------------------------------- page frame --- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
}
.page-title {
  font-size: var(--fs-page-title);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-subtitle {
  margin-top: var(--space-1);
  color: var(--color-muted-foreground);
}

/* ------------------------------------------------------ sign-in pages --- */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  padding: calc(var(--space-5) + env(safe-area-inset-top)) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
  background: var(--color-navy);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-6) var(--space-5) var(--space-5);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
}
@media (min-width: 480px) {
  .auth-card { padding: 40px var(--space-6) var(--space-6); }
}
.auth-card__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  text-align: center;
}
.auth-card__brand .lockup { font-size: 40px; }
.auth-card__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-1);
}
.auth-card__lead {
  color: var(--color-muted-foreground);
  margin-bottom: var(--space-5);
}
.auth-card__hint {
  margin-top: var(--space-4);
  font-size: var(--fs-ui);
  color: var(--color-muted-foreground);
}
.auth-footer {
  font-size: var(--fs-ui);
  color: var(--color-on-navy-muted);
  text-align: center;
}
.auth-card > .notice, .auth-card > .flashes { margin-bottom: var(--space-5); }
