/* ==========================================================================
   Application shell — top bar, left navigation, content frame
   ========================================================================== */

.app { min-height: 100vh; }

.sh { display: flex; flex-direction: column; min-height: 100vh; }

/* ------------------------------------------------------------- top bar --- */
.sh-top {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: var(--s-6);
  height: var(--topbar-h);
  padding: 0 var(--s-8) 0 var(--s-6);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--br-1);
  flex: none;
}
.sh-brand {
  display: flex; align-items: center; gap: var(--s-5);
  color: var(--a-500); text-decoration: none; padding: var(--s-2) var(--s-3);
  border-radius: var(--r-6); flex: none;
}
.sh-brand:hover { text-decoration: none; background: var(--bg-hover); }
.sh-brand__name {
  font-size: var(--fs-15); font-weight: 660; letter-spacing: -.02em;
  color: var(--tx-1); white-space: nowrap;
}
.sh-brand__name b { color: var(--a-600); font-weight: 660; }

.sh-search { flex: 1 1 auto; max-width: 520px; margin-inline: var(--s-6); }
.sh-search__btn {
  display: flex; align-items: center; gap: var(--s-5);
  width: 100%; height: 32px; padding: 0 var(--s-4) 0 var(--s-6);
  border: 1px solid var(--br-2); border-radius: var(--r-8);
  background: var(--bg-sunken); color: var(--tx-3);
  font-size: var(--fs-13);
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.sh-search__btn:hover { background: var(--bg-surface); border-color: var(--br-3); }
.sh-search__btn kbd { margin-left: auto; }

.sh-top__actions { display: flex; align-items: center; gap: var(--s-3); margin-left: auto; flex: none; }
.sh-bell { position: relative; }
.sh-bell__badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 999px; background: var(--err-500); color: #fff;
  font-size: 9.5px; font-weight: 700; line-height: 15px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg-topbar);
}
.sh-avatarbtn { border-radius: 50%; padding: 0; }
.sh-avatarbtn:hover .avatar { box-shadow: 0 0 0 2px var(--a-200); }

.sh-main { display: flex; flex: 1 1 auto; min-height: 0; align-items: stretch; }

/* ---------------------------------------------------------- navigation --- */
.sh-nav {
  position: sticky; top: var(--topbar-h);
  width: var(--nav-w); flex: none;
  height: calc(100vh - var(--topbar-h));
  background: var(--bg-nav);
  border-right: 1px solid var(--br-1);
  display: flex; flex-direction: column;
  transition: width var(--dur-3) var(--ease);
  overflow: hidden;
}
:root[data-nav="collapsed"] .sh-nav { width: var(--nav-w-collapsed); }

.sh-nav__start { padding: var(--s-8) var(--s-6) var(--s-6); flex: none; }
.sh-nav__scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 0 var(--s-6) var(--s-8); }
.sh-nav__foot { flex: none; padding: var(--s-6); border-top: 1px solid var(--br-1); }

.sh-navgroup + .sh-navgroup { margin-top: var(--s-8); }
.sh-navgroup__label {
  font-size: var(--fs-11); font-weight: 620; color: var(--tx-4);
  text-transform: uppercase; letter-spacing: .06em;
  padding: var(--s-4) var(--s-5) var(--s-3);
  display: flex; align-items: center; gap: var(--s-4);
}
:root[data-nav="collapsed"] .sh-navgroup__label { opacity: 0; height: 12px; padding: 0; }

.sh-navitem {
  display: flex; align-items: center; gap: var(--s-6);
  width: 100%; height: 34px; padding: 0 var(--s-5);
  border-radius: var(--r-6);
  font-size: var(--fs-13); font-weight: 520; color: var(--tx-2);
  text-decoration: none; position: relative;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.sh-navitem:hover { background: var(--bg-hover); color: var(--tx-1); text-decoration: none; }
.sh-navitem svg { color: var(--tx-3); flex: none; }
.sh-navitem:hover svg { color: var(--tx-2); }
.sh-navitem.is-active { background: var(--bg-selected); color: var(--tx-accent); font-weight: 600; }
.sh-navitem.is-active svg { color: var(--a-500); }
.sh-navitem.is-active::before {
  content: ""; position: absolute; left: -6px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--a-500);
}
.sh-navitem__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-navitem__count {
  font-size: var(--fs-11); font-weight: 620; color: var(--tx-3);
  font-variant-numeric: tabular-nums; flex: none;
}
.sh-navitem.is-active .sh-navitem__count { color: var(--tx-accent); }
.sh-navitem--sub { height: 30px; padding-left: var(--s-9); font-size: var(--fs-12); }
.sh-navitem--sub svg { display: none; }
:root[data-nav="collapsed"] .sh-navitem__label,
:root[data-nav="collapsed"] .sh-navitem__count,
:root[data-nav="collapsed"] .sh-navitem--sub { display: none; }
:root[data-nav="collapsed"] .sh-navitem { justify-content: center; padding: 0; }
:root[data-nav="collapsed"] .sh-nav__start .btn__label { display: none; }
:root[data-nav="collapsed"] .sh-nav__start .btn { padding: 0; }

.sh-navdot { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.sh-navdot--plum { background: var(--plum-500); }
.sh-navdot--info { background: var(--info-500); }
.sh-navdot--ok { background: var(--ok-500); }

.sh-storage { font-size: var(--fs-11); color: var(--tx-3); }
.sh-storage__bar { height: 4px; border-radius: 999px; background: var(--n-150); overflow: hidden; margin: var(--s-4) 0 var(--s-3); }
.sh-storage__fill { height: 100%; background: var(--a-500); border-radius: 999px; }
:root[data-nav="collapsed"] .sh-storage { display: none; }

.sh-collapse { width: 100%; justify-content: flex-start; }
:root[data-nav="collapsed"] .sh-collapse svg { transform: rotate(180deg); }

/* ------------------------------------------------------------- content --- */
.sh-content {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column;
}
.page {
  flex: 1 1 auto;
  width: 100%; max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-10) var(--s-10) var(--s-14);
}
.page--wide { max-width: none; }
.page--flush { padding: 0; }

.ph { display: flex; align-items: flex-start; gap: var(--s-8); margin-bottom: var(--s-9); }
.ph__title { font-size: var(--fs-24); font-weight: 640; letter-spacing: -.02em; line-height: 1.2; }
.ph__sub { font-size: var(--fs-13); color: var(--tx-3); margin-top: var(--s-3); line-height: 1.5; }
.ph__actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-5); flex: none; }
.ph__crumbs { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-12); color: var(--tx-3); margin-bottom: var(--s-4); }
.ph__crumbs a { color: var(--tx-3); }
.ph__crumbs a:hover { color: var(--tx-accent); }
.ph__crumbs svg { color: var(--tx-4); }

/* --------------------------------------------------------- mobile nav --- */
.sh-navscrim { display: none; }
.sh-hamburger { display: none; }

@media (max-width: 1080px) {
  .sh-search { max-width: none; }
}
@media (max-width: 900px) {
  .sh-hamburger { display: inline-flex; }
  .sh-nav {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
    width: 280px; z-index: calc(var(--z-drawer) + 1);
    transform: translateX(-100%);
    box-shadow: var(--sh-xl);
    transition: transform var(--dur-4) var(--ease-out);
  }
  :root[data-nav-open="1"] .sh-nav { transform: none; }
  :root[data-nav="collapsed"] .sh-nav { width: 280px; }
  :root[data-nav="collapsed"] .sh-navitem { justify-content: flex-start; padding: 0 var(--s-5); }
  :root[data-nav="collapsed"] .sh-navitem__label,
  :root[data-nav="collapsed"] .sh-navitem__count,
  :root[data-nav="collapsed"] .sh-navitem--sub { display: flex; }
  :root[data-nav="collapsed"] .sh-navgroup__label { opacity: 1; height: auto; padding: var(--s-4) var(--s-5) var(--s-3); }
  .sh-collapse { display: none; }
  :root[data-nav-open="1"] .sh-navscrim {
    display: block; position: fixed; inset: 0; z-index: var(--z-drawer);
    background: var(--bg-scrim); animation: fadeIn var(--dur-3) var(--ease-out);
  }
  .page { padding: var(--s-8) var(--s-8) var(--s-14); }
  .ph { flex-wrap: wrap; }
  .ph__actions { margin-left: 0; width: 100%; }
}
@media (max-width: 640px) {
  .sh-top { padding-inline: var(--s-5); gap: var(--s-4); }
  .sh-brand__name { display: none; }
  .sh-search { margin-inline: 0; }
  .sh-search__btn kbd { display: none; }
  .page { padding: var(--s-7) var(--s-6) var(--s-13); }
  .ph__title { font-size: var(--fs-20); }
}

/* --------------------------------------------------- command palette --- */
.cmdk { width: 100%; max-width: 620px; }
.cmdk__input {
  width: 100%; height: 52px; border: 0; border-bottom: 1px solid var(--br-1);
  padding: 0 var(--s-10); font-size: var(--fs-15); background: transparent;
}
.cmdk__input:focus { outline: none; }
.cmdk__list { max-height: 52vh; overflow-y: auto; padding: var(--s-4); }
.cmdk__group { font-size: var(--fs-11); font-weight: 620; color: var(--tx-4); text-transform: uppercase; letter-spacing: .06em; padding: var(--s-5) var(--s-6) var(--s-3); }
.cmdk__row {
  display: flex; align-items: center; gap: var(--s-6);
  width: 100%; padding: var(--s-5) var(--s-6); border-radius: var(--r-6);
  text-align: left; font-size: var(--fs-13);
}
.cmdk__row:hover, .cmdk__row.is-active { background: var(--bg-hover); }
.cmdk__row svg { color: var(--tx-3); }
.cmdk__row small { display: block; font-size: var(--fs-11); color: var(--tx-3); }
.cmdk__foot {
  display: flex; gap: var(--s-8); padding: var(--s-5) var(--s-9);
  border-top: 1px solid var(--br-1); font-size: var(--fs-11); color: var(--tx-4);
}
.hl { background: var(--a-100); color: var(--a-800); border-radius: 2px; padding: 0 1px; }
:root[data-theme="dark"] .hl { background: var(--a-800); color: #fff; }

/* ------------------------------------------------ notifications panel --- */
.ntf { width: 380px; max-width: calc(100vw - 24px); }
.ntf__head { display: flex; align-items: center; gap: var(--s-5); padding: var(--s-6) var(--s-7); border-bottom: 1px solid var(--br-1); }
.ntf__list { max-height: 60vh; overflow-y: auto; }
.ntf__row {
  display: flex; gap: var(--s-6); width: 100%; text-align: left;
  padding: var(--s-6) var(--s-7); border-bottom: 1px solid var(--br-1);
  transition: background var(--dur-1) var(--ease);
}
.ntf__row:hover { background: var(--bg-hover); }
.ntf__row:last-child { border-bottom: 0; }
.ntf__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--a-500); flex: none; margin-top: 6px; }
.ntf__dot--read { background: transparent; }
.ntf__ic { width: 28px; height: 28px; border-radius: var(--r-6); display: grid; place-content: center; flex: none; }
.ntf__ic--action { background: var(--a-50); color: var(--a-600); }
.ntf__ic--ok { background: var(--ok-50); color: var(--ok-500); }
.ntf__ic--warn { background: var(--warn-50); color: var(--warn-500); }
.ntf__ic--err { background: var(--err-50); color: var(--err-500); }
.ntf__ic--info { background: var(--info-50); color: var(--info-500); }
.ntf__t { font-size: var(--fs-13); font-weight: 570; line-height: 1.35; }
.ntf__b { font-size: var(--fs-12); color: var(--tx-3); line-height: 1.45; margin-top: 2px; }
.ntf__when { font-size: var(--fs-11); color: var(--tx-4); margin-top: 3px; }

/* Compact search affordance on narrow screens (the label would overflow) */
@media (max-width: 760px) {
  .sh-search { flex: 0 0 auto; width: 34px; margin-inline: 0; }
  .sh-search__btn { width: 34px; padding: 0; justify-content: center; border-radius: var(--r-6); }
  .sh-search__btn span, .sh-search__btn kbd { display: none; }
}
