.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  display: flex; flex-direction: column; padding: 20px 14px;
  background: linear-gradient(180deg, #1b1f4b 0%, #121538 100%); color: #c9cdf2;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; color: #fff; }
.brand strong { display: block; font-size: 15px; line-height: 1.2; }
.brand small { color: #8f95d1; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, .45); }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #b5baea; font-weight: 500; transition: .15s; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, .13); color: #fff; box-shadow: inset 3px 0 0 #8b8ffa; }
.nav-badge { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; background: #f59e0b; color: #1b1f4b; padding: 1px 8px; border-radius: 99px; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 14px; display: grid; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; color: #fff; padding: 0 6px; }
.user-chip strong { display: block; font-size: 13px; }
.user-chip small { color: #9aa0d8; text-transform: capitalize; }
.sidebar .logout { color: #c9cdf2; border-color: rgba(255, 255, 255, .15); }
.sidebar .logout:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: rgba(245, 246, 251, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.topbar .menu-btn { display: none; }
.content { padding: 28px; max-width: 1400px; width: 100%; margin: 0 auto; }
.scrim { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 12, 30, .5); z-index: 30; }
  .topbar { padding: 0 16px; }
  .topbar-user span { display: none; }
  .content { padding: 16px; }
}

/* ---- Bottom tab bar (body.touch-nav is set for phones and tablets) ---- */
.tabbar { display: none; }
.touch-nav .sidebar { display: none; }
.touch-nav .main { margin-left: 0; }
.touch-nav .topbar .menu-btn { display: none; }
.touch-nav .topbar-user span { display: none; }
.touch-nav .topbar { padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); height: calc(60px + env(safe-area-inset-top)); }
.touch-nav .topbar-install { display: inline-flex; }
.touch-nav .content { padding: 16px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.touch-nav input:not([type=checkbox]):not([type=color]), .touch-nav select, .touch-nav textarea { font-size: 16px; }
.touch-nav .toast-host { left: 12px; right: 12px; bottom: calc(88px + env(safe-area-inset-bottom)); }
.touch-nav .tabbar {
  display: flex; position: fixed; z-index: 35; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; padding: 6px; gap: 2px;
  background: rgba(255, 255, 255, .88); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid rgba(21, 26, 48, .08); border-radius: 22px; box-shadow: 0 12px 36px rgba(21, 26, 48, .18);
}
.tab-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px 6px; border: 0; border-radius: 16px; background: none; color: var(--muted); font-size: 10.5px; font-weight: 600; transition: color .15s, background .15s; -webkit-tap-highlight-color: transparent; }
.tab-item:active { transform: scale(.94); }
.tab-icon { position: relative; width: 44px; height: 28px; display: grid; place-items: center; border-radius: 14px; transition: background .2s, color .2s, transform .2s; }
.tab-item.active { color: var(--primary); }
.tab-item.active .tab-icon { background: var(--primary-soft); transform: translateY(-1px); }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-badge { position: absolute; top: -7px; left: calc(50% + 5px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: #f59e0b; color: #1b1f4b; font-size: 10.5px; font-weight: 700; font-style: normal; display: grid; place-items: center; border: 2px solid #fff; box-sizing: content-box; line-height: 13px; }

/* "More" bottom sheet */
.sheet-overlay { position: fixed; inset: 0; z-index: 120; display: flex; align-items: flex-end; justify-content: center; background: rgba(15, 18, 42, .5); backdrop-filter: blur(3px); animation: fade-in .15s; }
.sheet-overlay.leaving { opacity: 0; transition: opacity .18s; }
.sheet { width: 100%; max-width: 640px; padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-lg); animation: sheet-up .25s cubic-bezier(.2, .8, .2, 1); max-height: 88vh; overflow-y: auto; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-grip { width: 42px; height: 5px; border-radius: 99px; background: var(--border); margin: 2px auto 14px; }
.sheet-user { display: flex; align-items: center; gap: 12px; padding: 8px 4px 14px; }
.sheet-user strong, .sheet-user small { display: block; }
.sheet-user small { text-transform: capitalize; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 6px 0 14px; }
.sheet-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 16px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; text-align: center; }
.sheet-item:active { transform: scale(.96); }
.sheet-icon { position: relative; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.sheet-actions { display: grid; gap: 10px; padding-top: 4px; }

/* Every page already has its own big heading, so the small duplicate title in the top bar is hidden on phones/tablets.
   visibility keeps the flex spacing so the install button and avatar stay on the right. */
.touch-nav .topbar-title { visibility: hidden; }

/* Phones/tablets: no top bar at all, so the page heading starts at the top and the screen is used in full.
   Install and profile live in the "More" sheet. A thin brand-coloured strip covers the status-bar area
   when the installed app draws under it (iPhone notch / Dynamic Island). */
.touch-nav .topbar { display: none; }
.touch-nav .content { padding-top: calc(env(safe-area-inset-top) + 14px); }
.touch-nav::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top); background: #4f46e5; z-index: 60; }
.touch-nav .page-header { margin-top: 0; }

/* ======== Admin shell polish: grouped sidebar, search, notifications ======== */
.sidebar { background: linear-gradient(185deg, #1d2150 0%, #14173f 55%, #101334 100%); }
.sidebar-search { padding: 0 4px 12px; }
.search-trigger { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06); color: #aab0e6; font-weight: 500; transition: .15s; }
.search-trigger:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger kbd, .palette-input kbd, .palette-item kbd { font: 600 11px/1 inherit; padding: 3px 6px; border-radius: 6px; background: rgba(255, 255, 255, .12); color: inherit; }
.nav { gap: 2px; padding-right: 2px; }
.nav::-webkit-scrollbar { width: 6px; } .nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 99px; }
.nav-group { margin: 14px 10px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #6f76b8; }
.nav-group:first-child { margin-top: 2px; }
.nav-link { position: relative; padding: 7px 10px 7px 8px; gap: 11px; border-radius: 12px; transition: background .18s, color .18s, transform .18s; }
.nav-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .07); transition: background .18s, transform .18s, box-shadow .18s; flex: none; }
.nav-link:hover { background: rgba(255, 255, 255, .06); transform: translateX(2px); }
.nav-link:hover .nav-ico { background: rgba(255, 255, 255, .14); }
.nav-link.active { background: linear-gradient(90deg, rgba(139, 143, 250, .28), rgba(139, 143, 250, .06)); box-shadow: none; color: #fff; }
.nav-link.active .nav-ico { background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 6px 16px rgba(99, 102, 241, .5); transform: scale(1.04); }
.nav-link.active::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: #a5a8ff; }
.nav-badge { animation: badge-pop 2.4s infinite; }
@keyframes badge-pop { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }

.topbar { gap: 16px; }
.topbar-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.2; }
.crumb { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.topbar-heading .topbar-title { flex: none; font-size: 18px; letter-spacing: -.01em; }
.topbar-user { padding: 4px 12px 4px 4px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); transition: .15s; }
.topbar-user:hover { box-shadow: var(--shadow); }
.bell { position: relative; }
.bell .icon-btn { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.bell.ring .icon-btn .icon { animation: bell-ring 3.2s infinite; transform-origin: 50% 0; }
@keyframes bell-ring { 0%, 86%, 100% { transform: rotate(0); } 88% { transform: rotate(14deg); } 90% { transform: rotate(-12deg); } 92% { transform: rotate(8deg); } 94% { transform: rotate(-6deg); } }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; font-style: normal; display: grid; place-items: center; border: 2px solid var(--bg); box-sizing: content-box; }
.bell-menu { position: absolute; right: 0; top: calc(100% + 10px); width: 320px; z-index: 50; padding: 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: fade-up .18s; }
.bell-title { display: block; padding: 4px 8px 10px; font-size: 13px; }
.bell-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; transition: background .15s; }
.bell-item:hover { background: var(--surface-2); }
.bell-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.bell-ico.amber { background: var(--amber-soft); color: var(--amber); } .bell-ico.violet { background: var(--violet-soft); color: var(--violet); }
.bell-ico.blue { background: var(--blue-soft); color: var(--blue); } .bell-ico.red { background: var(--red-soft); color: var(--red); }
.bell-clear { display: flex; align-items: center; gap: 8px; padding: 12px 8px; color: var(--green); font-weight: 600; }

/* Command palette */
.palette-overlay { position: fixed; inset: 0; z-index: 250; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(15, 18, 42, .55); backdrop-filter: blur(4px); animation: fade-in .12s; }
.palette-overlay.leaving { opacity: 0; transition: .14s; }
.cmdk { width: 100%; max-width: 620px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden; animation: fade-up .18s; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette-input input { border: 0; box-shadow: none; padding: 4px 0; font-size: 16px; flex: 1; background: none; }
.palette-input input:focus { box-shadow: none; }
.palette-input kbd { background: var(--gray-soft); color: var(--muted); }
.palette-list { max-height: 55vh; overflow-y: auto; padding: 8px; }
.palette-group small { display: block; padding: 10px 12px 4px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 10.5px; }
.palette-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-radius: 12px; background: none; text-align: left; }
.palette-item.active { background: var(--primary-soft); }
.palette-item strong, .palette-item small { display: block; }
.palette-item small { padding: 0; text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 400; }
.palette-item > div { flex: 1; min-width: 0; }
.palette-item kbd { background: var(--gray-soft); color: var(--muted); opacity: 0; }
.palette-item.active kbd { opacity: 1; }
.palette-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--gray-soft); color: var(--primary); flex: none; }
.touch-nav .sidebar-search, .touch-nav .bell { display: none; }
/* Compact enough that all 13 admin links fit on a laptop screen */
.nav-link { padding: 5px 10px 5px 8px; }
.nav-ico { width: 28px; height: 28px; border-radius: 9px; }
.nav-group { margin: 10px 10px 3px; }
.brand { padding: 2px 8px 14px; }
.sidebar { padding-top: 16px; padding-bottom: 14px; }
.sidebar-foot { padding-top: 10px; gap: 8px; }
.sidebar-search { padding-bottom: 8px; }
