/* ==========================================================================
   App shell — topbar, sidebar, content frame
   ========================================================================== */

.app {
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: relative;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 6px;
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 2px 8px rgba(8, 20, 32, .28);
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.topbar__right { margin-left: auto; gap: 6px; }

.topbar__divider {
  width: 1px;
  height: 20px;
  margin: 0 8px;
  background: rgba(255, 255, 255, .26);
  flex: 0 0 auto;
}

.topbar__company {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  opacity: .94;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  color: var(--brand-ink);
  text-decoration: none;
}
.brand:hover { background: rgba(255, 255, 255, .1); text-decoration: none; }
.brand__mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .22);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
  flex: 0 0 auto;
}
.brand__name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.topbar .icon-btn { color: rgba(255, 255, 255, .88); }
.topbar .icon-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger-solid);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  border: 1.5px solid var(--brand);
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  min-width: 218px;
  padding: 0 8px 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .86);
  font-size: 12.5px;
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.search-trigger:hover { background: rgba(255, 255, 255, .2); }
.search-trigger span { flex: 1 1 auto; }
.search-trigger kbd {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .16);
}

.punch-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, .5);
  background: #fff;
  color: #1b4a71;
  font-size: 12.5px;
  font-weight: 680;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 1px 3px rgba(8, 20, 32, .22);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.punch-btn:hover { background: #eaf3fb; transform: translateY(-1px); }
.punch-btn[data-active="true"] {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .4);
  color: #fff;
  box-shadow: none;
}
.punch-btn[data-active="true"]:hover { background: rgba(255, 255, 255, .22); }

/* profile */
.profile { position: relative; }
.profile__btn {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 10px 0 6px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--brand-ink);
  transition: background var(--dur) var(--ease);
}
.profile__btn:hover { background: rgba(255, 255, 255, .14); }
.profile__meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.profile__name { font-size: 12.5px; font-weight: 650; }
.profile__role { font-size: 10.5px; opacity: .82; }

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
  transition: grid-template-columns var(--dur) var(--ease);
}

.app[data-rail="true"] { --sidebar-w: var(--sidebar-rail); }

.main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 20px 56px;
  scroll-behavior: smooth;
}
.main:focus { outline: none; }

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.sidebar__search {
  padding: 12px 12px 6px;
  flex: 0 0 auto;
}
.sidebar__search .input { height: 34px; font-size: 12.5px; }

.sidebar__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 10px 14px;
}

.nav-group { margin-top: 10px; }
.nav-group:first-child { margin-top: 4px; }
.nav-group__label {
  padding: 6px 10px 6px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 550;
  text-align: left;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item + .nav-item { margin-top: 1px; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item__icon { width: 18px; height: 18px; flex: 0 0 auto; opacity: .78; }
.nav-item__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item__badge {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.5;
}

.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 680;
}
.nav-item[aria-current="page"] .nav-item__icon { opacity: 1; }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.sidebar__footer {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.foot-card {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.foot-card__title { font-size: 12px; font-weight: 680; color: var(--text); }
.foot-card__body { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }

/* rail mode */
.app[data-rail="true"] .sidebar__search,
.app[data-rail="true"] .nav-group__label,
.app[data-rail="true"] .nav-item__text,
.app[data-rail="true"] .sidebar__footer { display: none; }
.app[data-rail="true"] .sidebar__scroll { padding: 10px 8px; }
.app[data-rail="true"] .nav-item { justify-content: center; padding: 10px 0; }
.app[data-rail="true"] .nav-item__badge {
  position: absolute;
  top: 3px;
  right: 6px;
  margin: 0;
}
.app[data-rail="true"] .nav-item[aria-current="page"]::before { left: -8px; }

/* scrim for the mobile drawer */
.scrim { display: none; }

/* ---------------------------------------------------------------- page head */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 690;
  letter-spacing: -.015em;
  margin-top: 3px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-sub { margin-top: 5px; font-size: 13px; color: var(--muted); max-width: 62ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .search-trigger { min-width: 0; }
  .search-trigger span { display: none; }
  .search-trigger kbd { display: none; }
  .search-trigger { width: 36px; padding: 0; justify-content: center; }
  .topbar__company { max-width: 140px; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: var(--topbar-h) auto 0 0;
    width: 272px;
    transform: translateX(-104%);
    transition: transform 200ms var(--ease);
    box-shadow: var(--shadow-pop);
    z-index: 70;
  }
  .app[data-nav="open"] .sidebar { transform: none; }
  .app[data-nav="open"] .scrim {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: var(--scrim);
    z-index: 60;
  }
  .main { padding: 16px 14px 48px; }
  .page-head h1 { font-size: 20px; }
  .profile__meta { display: none; }
  .profile__btn { padding: 0 4px; }
}

@media (max-width: 620px) {
  .topbar__company, .topbar__divider { display: none; }
  .brand__name { font-size: 14px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }
}
