/* ============================================================
   DevPortal — App Shell (sidebar, topbar, palette)
   ============================================================ */

.app {
  display: grid; grid-template-columns: auto 1fr;
  height: 100%; background: var(--bg);
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 230px; flex-shrink: 0; height: 100%;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .2s cubic-bezier(.3,.7,.4,1);
}
.sidebar.collapsed { width: 60px; }

.sidebar-top {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 var(--space-3) 0 var(--space-4); flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.sidebar.collapsed .sidebar-top { padding: 0; justify-content: center; }
.sidebar.collapsed .collapse-btn { display: none; }

.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #8b5cf6));
  box-shadow: 0 2px 8px var(--accent-ring);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-size: var(--fs-lg); font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.brand-name span { color: var(--accent); }

.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--space-3); display: flex; flex-direction: column; gap: 2px; }
.nav-group { display: flex; flex-direction: column; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%;
  height: calc(38px * var(--d)); padding: 0 var(--space-3); border: 0; background: transparent;
  border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s; position: relative;
}
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-ico { display: flex; flex-shrink: 0; color: var(--nav-c, var(--text-3)); transition: color .12s; }
.nav-ico svg { width: 18px; height: 18px; }
.nav-item:hover .nav-ico, .nav-item.active .nav-ico { color: var(--nav-c, var(--accent)); }
.nav-item.active {
  background: color-mix(in srgb, var(--nav-c) 11%, transparent); color: var(--text);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -3px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px; background: var(--nav-c);
}
.nav-label { flex: 1; text-align: left; }
.nav-caret { width: 15px; height: 15px; color: var(--text-3); transition: transform .2s; }
.nav-caret.open { transform: rotate(180deg); }

.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 2px 26px; padding-left: var(--space-3); border-left: 1.5px solid var(--border); }
.nav-subitem {
  display: flex; align-items: center; gap: var(--space-2); width: 100%; min-width: 0;
  height: calc(30px * var(--d)); padding: 0 var(--space-2); border: 0; background: transparent;
  border-radius: var(--r-xs); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500;
  cursor: pointer; transition: background .12s, color .12s; text-align: left;
}
.nav-subitem:hover { background: var(--surface-2); color: var(--text); }
.nav-subitem.active { color: var(--accent); font-weight: 700; }
.nav-sub-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong); flex-shrink: 0; }
.nav-subitem.active .nav-sub-dot { background: var(--accent); }

.sidebar-foot { padding: var(--space-3); border-top: 1px solid var(--border); }
.sso-card {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3);
  background: color-mix(in srgb, var(--ok) 9%, transparent); border-radius: var(--r-md);
  border: 1px solid color-mix(in srgb, var(--ok) 22%, transparent);
}
.sso-card.mini { justify-content: center; padding: var(--space-2); }
.sso-ico { color: var(--ok); display: flex; flex-shrink: 0; }
.sso-ico svg { width: 18px; height: 18px; }
.sso-title { font-size: var(--fs-xs); font-weight: 700; color: var(--text); }
.sso-sub { font-size: var(--fs-2xs); color: var(--text-2); font-weight: 600; }

/* ---------- Main area ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; }

/* ---------- TopBar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--space-3);
  height: 52px; flex-shrink: 0; padding: 0 var(--space-5);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar > .btn.icon { display: none; }
.crumbs { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.crumb-home { width: 16px; height: 16px; color: var(--text-3); }
.crumb-sep { width: 13px; height: 13px; color: var(--text-3); }
.crumb { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.crumb-cur { font-size: var(--fs-sm); color: var(--text); font-weight: 700; }

.global-search {
  display: flex; align-items: center; gap: var(--space-3); margin-left: auto;
  width: min(360px, 38vw); height: 34px; padding: 0 var(--space-3);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text-3); font-size: var(--fs-sm); cursor: pointer; transition: border-color .14s, background .14s;
}
.global-search:hover { border-color: var(--border-strong); background: var(--surface); }
.global-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.global-search span { flex: 1; text-align: left; }
.global-search kbd { font-family: var(--font-mono); font-size: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: var(--text-3); }

.topbar-actions { display: flex; align-items: center; gap: var(--space-2); }
.notif-btn { position: relative; }
.notif-dot {
  position: absolute; top: -2px; right: -2px; min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--err); color: #fff; font-size: 9px; font-weight: 800; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; border: 1.5px solid var(--surface);
}

.avatar-btn {
  display: flex; align-items: center; gap: var(--space-2); height: 38px; padding: 0 var(--space-2) 0 4px;
  border: 0; background: transparent; border-radius: var(--r-md); cursor: pointer; transition: background .12s;
}
.avatar-btn:hover { background: var(--surface-2); }
.avatar-meta { line-height: 1.2; max-width: 130px; }
.avatar-name { font-size: var(--fs-xs); font-weight: 700; color: var(--text); text-align: left; }
.avatar-role { font-size: 10px; color: var(--text-3); text-align: left; }
@media (max-width: 920px) { .avatar-meta { display: none; } }

.menu-user { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); }

/* notif popover */
.notif-pop { padding: 0; overflow: hidden; }
.notif-hd { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.notif-hd b { font-size: var(--fs-sm); }
.link-btn { border: 0; background: transparent; color: var(--accent); font-size: var(--fs-2xs); font-weight: 700; cursor: pointer; }
.notif-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.notif-row:last-child { border-bottom: 0; }
.notif-row:hover { background: var(--surface-2); }
.notif-row.unread { background: var(--accent-softer); }
.notif-ico { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-ico svg { width: 15px; height: 15px; }
.notif-title { font-size: var(--fs-xs); font-weight: 700; }
.notif-body { font-size: 10.5px; color: var(--text-2); }
.notif-time { font-size: 10px; color: var(--text-3); flex-shrink: 0; }

/* ---------- Content scroller ---------- */
.content { flex: 1; overflow-y: auto; overflow-x: hidden; }
.page { padding: var(--space-5); max-width: 1440px; margin: 0 auto; animation: slideUp .26s cubic-bezier(.3,.7,.4,1) backwards; }
.page-hd { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-hd h1 { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; }
.page-hd .page-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 3px; }
.page-hd-actions { display: flex; align-items: center; gap: var(--space-2); }

/* ---------- Command Palette ---------- */
.palette-overlay { align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette { width: min(580px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 60vh; }
.palette-input { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.palette-input svg { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.palette-input input { flex: 1; border: 0; background: transparent; outline: none; font-size: var(--fs-lg); color: var(--text); }
.palette-input input::placeholder { color: var(--text-3); }
.palette-input kbd { font-family: var(--font-mono); font-size: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; color: var(--text-3); }
.palette-results { overflow-y: auto; padding: var(--space-2); }
.palette-group { margin-bottom: var(--space-2); }
.palette-gh { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: var(--space-2) var(--space-3) var(--space-1); }
.palette-item { display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: var(--space-2) var(--space-3); border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm); color: var(--text); transition: background .1s; }
.palette-item:hover { background: var(--accent-softer); }
.palette-ico { width: 28px; height: 28px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.palette-ico svg { width: 15px; height: 15px; }
.palette-sub { font-size: var(--fs-2xs); color: var(--text-3); font-family: var(--font-mono); }
.palette-arrow { width: 14px; height: 14px; color: var(--text-3); opacity: 0; }
.palette-item:hover .palette-arrow { opacity: 1; }
.palette-foot { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: var(--surface-2); font-size: 10.5px; color: var(--text-3); }
.palette-foot kbd { font-family: var(--font-mono); font-size: 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; margin-right: 2px; }

/* ---------- Responsive sidebar ---------- */
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 200; box-shadow: var(--shadow-lg); }
  .sidebar.collapsed { width: 0; border: 0; overflow: hidden; }
  .topbar > .btn.icon { display: inline-flex; }
}
