/* ============================================================
   Wren Shell v2 — section-tab SPA styles
   Loaded AFTER wren.css; overrides sidebar + layout for admin SPA
   Scoped to body.v2-shell to avoid affecting legacy pages
   ============================================================ */

/* ── Layout reset for new shell ─────────────────────────────────────────────── */
body.v2-shell {
  --v2-sidebar-w:       60px;
  --v2-sidebar-full-w:  220px;
  --v2-tab-active:      var(--c-orange);
  --v2-section-active:  var(--c-blue);
}

/* Override old sidebar width so #wren-main sits at 60px not 220px */
body.v2-shell #wren-main {
  margin-left: var(--v2-sidebar-w) !important;
  max-width: calc(100% - var(--v2-sidebar-w)) !important;
  padding: 0 !important;   /* sections handle their own padding */
  overflow-x: hidden;
}

/* ── Topbar tweaks ────────────────────────────────────────────────────────────── */
body.v2-shell #wren-topbar {
  gap: 8px;
}
.topbar-icon-btn {
  background: none;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
  font-size: .85rem;
}
.topbar-icon-btn:hover { background: rgba(255,255,255,.08); color: var(--c-text); }
.topbar-icon-btn:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }

.topbar-section-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--c-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.topbar-search-btn { gap: 6px; }
.topbar-search-label { display: none; }
@media (min-width: 900px) { .topbar-search-label { display: inline; } }
.topbar-kbd {
  font-size: .68rem;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--c-muted);
  font-family: monospace;
  display: none;
}
@media (min-width: 900px) { .topbar-kbd { display: inline; } }

.topbar-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.topbar-logo .wren-logo { font-size: 1.1rem; }
.topbar-logo .logo-w { font-size: 1.35rem !important; }
.topbar-logo .logo-ren { font-size: 1.1rem !important; }

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--c-blue);
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.topbar-avatar:hover { opacity: .85; }
.topbar-avatar:focus-visible { outline: 2px solid var(--c-orange); outline-offset: 2px; }

.v2-notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--c-red);
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  padding: 0 3px;
  pointer-events: none;
}
#wren-notif-btn { position: relative; }

/* ── Sidebar v2 ─────────────────────────────────────────────────────────────── */
body.v2-shell #wren-sidebar {
  width: var(--v2-sidebar-w) !important;  /* icon-only by default */
  overflow: hidden;
  transition: width .2s ease;
  display: flex !important;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
body.v2-shell #wren-sidebar.v2-expanded,
body.v2-shell #wren-sidebar:focus-within {
  width: var(--v2-sidebar-full-w) !important;
  box-shadow: 4px 0 24px rgba(0,0,0,.3);
  z-index: 160;
}
@media (min-width: 768px) {
  body.v2-shell #wren-sidebar:hover {
    width: var(--v2-sidebar-full-w) !important;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
    z-index: 160;
  }
  body.v2-shell #wren-sidebar:hover .v2-section-label {
    opacity: 1;
  }
}

.v2-section-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.v2-section-list::-webkit-scrollbar { display: none; }

.v2-section-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 0 10px 18px;
  background: none;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: background var(--transition), color var(--transition);
  min-height: 44px;
}
.v2-section-btn:hover { background: rgba(255,255,255,.06); color: var(--c-text); }
.v2-section-btn:focus-visible { outline: 2px solid var(--c-blue); outline-offset: -2px; }
.v2-section-btn.v2-active {
  background: rgba(91,143,255,.12);
  color: var(--v2-section-active);
}
.v2-section-btn.v2-active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--v2-section-active);
  border-radius: 0 2px 2px 0;
}
.v2-section-btn.v2-signout-btn:hover { color: var(--c-red); }

.v2-section-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.v2-section-label {
  font-size: .85rem;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  white-space: nowrap;
}
body.v2-shell #wren-sidebar.v2-expanded .v2-section-label,
body.v2-shell #wren-sidebar:focus-within .v2-section-label {
  opacity: 1;
}

.v2-sidebar-footer {
  padding: 6px 0 10px;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* Mobile sidebar */
@media (max-width: 767px) {
  body.v2-shell #wren-sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease, width .22s ease;
    width: var(--v2-sidebar-full-w) !important;
    z-index: 500;
  }
  body.v2-shell #wren-sidebar.v2-mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.5);
  }
  body.v2-shell #wren-sidebar.v2-mobile-open .v2-section-label { opacity: 1; }
  body.v2-shell #wren-main {
    margin-left: 0 !important;
    max-width: 100% !important;
  }
}

/* ── Section content area ────────────────────────────────────────────────────── */
#section-content {
  min-height: calc(100vh - var(--topbar-h));
  padding-top: 16px;    /* breathing room: content never abuts topbar bottom edge */
}

.v2-section {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h));
}

/* Cancel the padding for sections whose first element is a sticky tab bar */
#section-content > .v2-section > .wren-tab-bar {
  margin-top: -16px;
}

/* ── Tab bar ─────────────────────────────────────────────────────────────────── */
.wren-tab-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 10;
  background: var(--c-bg);
  border-bottom: 2px solid rgba(255,255,255,.07);
  display: flex;
  align-items: stretch;
  padding: 0 8px;
  gap: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.tab-bar-track {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  gap: 0;
  flex: 1;
  min-width: 0;
}
.tab-bar-track::-webkit-scrollbar { display: none; }

.wren-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
  position: relative;
  flex-shrink: 0;
  min-height: 44px;
}
.wren-tab:hover { color: var(--c-text); }
.wren-tab:focus-visible { outline: 2px solid var(--c-blue); outline-offset: -2px; border-radius: 4px 4px 0 0; }
.wren-tab.wren-tab-active {
  color: var(--v2-tab-active);
  font-weight: 700;
  border-bottom-color: var(--v2-tab-active);
}

.tab-scroll-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  transition: color var(--transition);
  visibility: hidden;
}
.tab-scroll-arrow:hover { color: var(--c-text); }

/* ── Tab panels ─────────────────────────────────────────────────────────────── */
.wren-tab-panels {
  flex: 1;
}
.wren-tab-panel {
  padding: 24px;
  min-height: 200px;
}
.wren-tab-panel[hidden] { display: none; }

/* ── Section loading skeletons ───────────────────────────────────────────────── */
@keyframes v2-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.v2-sk {
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.05) 75%);
  background-size: 800px 100%;
  animation: v2-shimmer 1.4s infinite;
  border-radius: 6px;
}
.v2-section-loading {
  padding: 24px;
}
.v2-sk-bar {
  height: 28px;
  border-radius: 6px;
  margin-bottom: 24px;
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.05) 75%);
  background-size: 800px 100%;
  animation: v2-shimmer 1.4s infinite;
}
.v2-sk-bar.wide { width: 40%; }
.v2-sk-tabs {
  height: 44px;
  border-radius: 6px;
  margin-bottom: 20px;
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.05) 75%);
  background-size: 800px 100%;
  animation: v2-shimmer 1.4s infinite;
}
.v2-sk-body {
  height: 300px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.05) 75%);
  background-size: 800px 100%;
  animation: v2-shimmer 1.4s infinite;
}

/* Tab-level skeleton */
.tab-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tab-sk-row {
  height: 20px;
  border-radius: 4px;
  animation: v2-shimmer 1.4s infinite;
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.05) 75%);
  background-size: 800px 100%;
}
.tab-sk-row.w60 { width: 60%; }
.tab-sk-row.w80 { width: 80%; }
.tab-sk-row.w40 { width: 40%; }
.tab-sk-card {
  height: 80px;
  border-radius: 10px;
  animation: v2-shimmer 1.4s infinite;
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.05) 75%);
  background-size: 800px 100%;
}
.tab-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

/* "Coming soon" placeholder */
.tab-coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  color: var(--c-muted);
  gap: 12px;
}
.tab-coming-soon .coming-icon { font-size: 2.5rem; opacity: .5; }
.tab-coming-soon h3 { font-size: 1.1rem; color: var(--c-text); font-family: var(--font-heading); }
.tab-coming-soon p  { font-size: .875rem; max-width: 320px; }

/* ── Section error ───────────────────────────────────────────────────────────── */
.v2-section-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  gap: 12px;
  color: var(--c-muted);
}
.v2-section-error h2 { color: var(--c-text); }

/* ── Drawer ──────────────────────────────────────────────────────────────────── */
.wren-drawer {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: none;
}
.wren-drawer.open { display: flex; }

.drawer-backdrop {
  flex: 1;
  background: rgba(0,0,0,.55);
  cursor: pointer;
  opacity: 0;
  transition: opacity .26s ease;
}
.wren-drawer.open .drawer-backdrop { opacity: 1; }

.drawer-panel {
  width: 520px;
  max-width: 95vw;
  background: var(--c-card);
  border-left: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .26s ease;
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.wren-drawer.open .drawer-panel { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  background: var(--c-card);
  z-index: 1;
}
.drawer-title {
  flex: 1;
  font-weight: 700;
  font-size: 1rem;
  color: var(--c-text);
}
.drawer-close {
  background: none;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.drawer-close:hover { background: rgba(255,255,255,.08); color: var(--c-text); }

.drawer-body {
  flex: 1;
  padding: 20px;
}

/* Drawer tab bar — reuses wren-tab-bar but inside the drawer */
.drawer-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.drawer-tab-bar::-webkit-scrollbar { display: none; }
.drawer-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.drawer-tab.active { color: var(--v2-tab-active); border-bottom-color: var(--v2-tab-active); font-weight: 700; }

/* ── Global search overlay ───────────────────────────────────────────────────── */
#wren-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  opacity: 0;
  transition: opacity .18s ease;
}
#wren-search-overlay.open { opacity: 1; }

.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(3px);
  cursor: pointer;
}
.search-panel {
  position: relative;
  width: 540px;
  max-width: 94vw;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  overflow: hidden;
}
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
}
.search-input-icon { flex-shrink: 0; color: var(--c-muted); }
.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: .95rem;
  color: var(--c-text);
  font-family: inherit;
}
.search-input::placeholder { color: var(--c-muted); }
.search-esc {
  font-size: .7rem;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--c-muted);
  font-family: monospace;
  flex-shrink: 0;
}
.search-results { padding: 6px 0; min-height: 60px; max-height: 340px; overflow-y: auto; }
.search-hint { padding: 16px; color: var(--c-muted); font-size: .85rem; text-align: center; margin: 0; }
.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--c-text);
  font-family: inherit;
  font-size: .875rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.search-result:hover { background: rgba(255,255,255,.06); }
.search-result-icon { font-size: 1rem; flex-shrink: 0; width: 24px; text-align: center; }
.search-result-label { flex: 1; }

/* ── Notifications panel ─────────────────────────────────────────────────────── */
#wren-notif-panel {
  position: fixed;
  top: 52px;
  right: 8px;
  width: 340px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 700;
}
.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 700;
  color: var(--c-text);
  font-size: .875rem;
  position: sticky;
  top: 0;
  background: var(--c-card);
}
.notif-mark-all {
  font-size: .78rem;
  color: var(--c-blue);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.notif-item {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  cursor: pointer;
  display: flex;
  gap: 10px;
  transition: background var(--transition);
}
.notif-item:hover { background: rgba(255,255,255,.04); }
.notif-item.read { opacity: .6; }
.notif-cat { font-size: 1.1rem; flex-shrink: 0; padding-top: 1px; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: .82rem; font-weight: 600; color: var(--c-text); }
.notif-text { font-size: .76rem; color: var(--c-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: .72rem; color: #64748b; margin-top: 3px; }
.notif-empty { padding: 24px; text-align: center; color: var(--c-muted); font-size: .85rem; }

/* ── Session warning bar ─────────────────────────────────────────────────────── */
#wren-session-warning {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--c-amber);
  color: #000;
  text-align: center;
  padding: 10px 16px;
  font-size: .875rem;
  font-weight: 600;
  z-index: 9998;
}
#wren-session-warning a { color: #000; text-decoration: underline; }
#wren-session-warning[hidden] { display: none; }

/* ── Toast notifications ─────────────────────────────────────────────────────── */
#wren-toasts {
  position: fixed;
  bottom: 24px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.wren-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: all;
  max-width: 340px;
}
.wren-toast.visible { opacity: 1; transform: translateY(0); }
.wren-toast-info    { background: var(--c-card); color: var(--c-text); border: 1px solid var(--c-border); }
.wren-toast-success { background: rgba(34,197,94,.15); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.wren-toast-error   { background: rgba(248,113,113,.15); color: var(--c-red); border: 1px solid rgba(248,113,113,.3); }
.wren-toast-warning { background: rgba(251,191,36,.15); color: var(--c-amber); border: 1px solid rgba(251,191,36,.3); }

/* ── Children section — fast list styles ─────────────────────────────────────── */
.v2-list-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 16px;
  flex-wrap: wrap;
}
.v2-search-input {
  flex: 1;
  min-width: 200px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: inherit;
  font-size: .875rem;
  outline: none;
  transition: border-color var(--transition);
}
.v2-search-input:focus { border-color: var(--c-blue); }
.v2-search-input::placeholder { color: var(--c-muted); }

.v2-filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.v2-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--c-border);
  background: none;
  color: var(--c-muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
}
.v2-chip:hover { border-color: var(--c-blue); color: var(--c-blue); }
.v2-chip.active { background: rgba(91,143,255,.15); border-color: var(--c-blue); color: var(--c-blue); }

.v2-sort-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: inherit;
  font-size: .8rem;
  cursor: pointer;
  outline: none;
}

.v2-virtual-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.v2-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--c-surface);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  min-height: 52px;
}
.v2-list-row:hover { background: rgba(91,143,255,.07); border-color: rgba(91,143,255,.2); }
.v2-list-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--c-blue-light);
  color: var(--c-blue-dark);
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.v2-list-name { font-weight: 600; font-size: .875rem; color: var(--c-text); }
.v2-list-meta { font-size: .75rem; color: var(--c-muted); }
.v2-list-badges { margin-left: auto; display: flex; gap: 4px; }

/* Virtual scroll sentinel */
.v2-list-sentinel { height: 1px; }

/* ── Page-level search input in tab panel ────────────────────────────────────── */
.tab-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

/* ── Modal overrides (v2-shell context) ──────────────────────────────────────── */
body.v2-shell .wren-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;        /* respect [hidden] attribute; was display:flex which overrode wren.css fix */
  align-items: center;
  justify-content: center;
  z-index: 850;
  animation: none;      /* suppress wren.css fadeIn that caused 0.2s flash on page load */
}
body.v2-shell .wren-modal-overlay:not([hidden]),
body.v2-shell .wren-modal-overlay.open { display: flex; }
body.v2-shell .wren-modal {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .wren-tab { padding: 10px 12px; font-size: .8rem; }
  .wren-tab-panel { padding: 14px; }
  .drawer-panel { width: 100vw; max-width: 100vw; }
}

/* ── Section content utilities — prompt 02 additions ─────────────────────── */

/* Drawer panel toggle */
.drawer-panel.hidden { display: none; }
.drawer-panels { padding: 16px 0 0; }

/* Info grid (key–value rows inside drawers) */
.drawer-info-grid { display: flex; flex-direction: column; gap: 6px; }
.drawer-info-row {
  display: flex;
  gap: 12px;
  font-size: .85rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--c-border);
}
.drawer-info-row span:first-child { color: var(--c-muted); min-width: 100px; flex-shrink: 0; }
.drawer-info-row span:last-child  { color: var(--c-text); flex: 1; word-break: break-word; }
.drawer-info-row.danger span:first-child { color: #ef4444; }
.drawer-info-row.warning span:first-child { color: #f59e0b; }

/* Observation timeline */
.obs-timeline { display: flex; flex-direction: column; gap: 0; }
.obs-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
}
.obs-item:last-child { border-bottom: none; }
.obs-item-alert { border-left: 3px solid #ef4444; padding-left: 10px; }
.obs-meta { font-size: .78rem; color: var(--c-muted); margin-bottom: 4px; }
.obs-text { font-size: .88rem; color: var(--c-text); line-height: 1.5; }
.obs-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* Stat cards */
.v2-stat-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}
.stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.1;
  font-family: var(--font-heading);
}
.stat-label {
  font-size: .75rem;
  color: var(--c-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* v2 card */
.v2-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 14px 16px;
}
.v2-card-link {
  transition: border-color .2s ease, transform .15s ease;
}
.v2-card-link:hover {
  border-color: var(--c-blue);
  transform: translateY(-1px);
}
.v2-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* Table */
.wren-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.wren-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: .75rem;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--c-border);
}
.wren-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.04); }
.wren-table tr:hover td { background: rgba(91,143,255,.05); }

/* Form elements for modals */
.wren-input, .wren-select, .wren-textarea {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  color: var(--c-text);
  font-size: .875rem;
  padding: 8px 12px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .2s ease;
}
.wren-input:focus, .wren-select:focus, .wren-textarea:focus {
  outline: none;
  border-color: var(--c-blue);
  box-shadow: 0 0 0 2px rgba(91,143,255,.15);
}
.wren-input::placeholder, .wren-textarea::placeholder { color: var(--c-muted); }
.wren-textarea { resize: vertical; min-height: 80px; }
.wren-select option { background: #1e293b; }

/* Alert banners */
.wren-alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 12px;
}
.wren-alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }
.wren-alert-success { background: rgba(34,197,94,.10); border: 1px solid rgba(34,197,94,.25); color: #86efac; }
.wren-alert-danger  { background: rgba(239,68,68,.10);  border: 1px solid rgba(239,68,68,.25);  color: #fca5a5; }

/* Extra badge colour */
.badge-yellow { background: rgba(245,158,11,.15); color: #fcd34d; }

/* Tab skeleton extra widths */
.tab-sk-row.w65  { width: 65%; }
.tab-sk-row.w75  { width: 75%; }
.tab-sk-row.w100 { width: 100%; }

/* ── MPA sidebar — link-based nav with collapsible groups ───────────────────── */

/* Direct nav links (flat items) */
.v2-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--c-muted);
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}
.v2-nav-link:hover { background: rgba(255,255,255,.07); color: var(--c-text); }
.v2-nav-link.v2-active {
  background: rgba(74,154,191,.15);
  color: var(--c-blue);
  font-weight: 600;
}
.v2-nav-link:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }

/* Group toggle button */
.v2-group-btn {
  width: 100%;
  text-align: left;
  border-radius: 8px;
}
.v2-group-btn .v2-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.v2-mpa-chevron {
  font-size: .9rem;
  line-height: 1;
  opacity: 0.5;
  transition: transform .2s;
  margin-left: auto;
  flex-shrink: 0;
}
.v2-group-btn[aria-expanded="true"] .v2-mpa-chevron {
  transform: rotate(90deg);
  opacity: 0.9;
}
.v2-group-active > .v2-group-btn {
  color: var(--c-blue);
}

/* Children list */
.v2-mpa-children {
  list-style: none;
  margin: 0;
  padding: 2px 0 4px 0;
  overflow: hidden;
}
/* Hidden by default when sidebar is collapsed; visible when expanded */
body.v2-shell #wren-sidebar:not(.v2-expanded):not(.v2-mobile-open) .v2-mpa-children {
  display: none;
}

.v2-child-link {
  display: block;
  padding: 7px 12px 7px 44px;
  font-size: .82rem;
  color: var(--c-muted);
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--transition), color var(--transition);
}
.v2-child-link:hover { background: rgba(255,255,255,.06); color: var(--c-text); }
.v2-child-link.v2-active {
  background: rgba(74,154,191,.12);
  color: var(--c-blue);
  font-weight: 600;
}
.v2-child-link:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }

/* Mobile: show children when sidebar is open */
@media (max-width: 767px) {
  body.v2-shell #wren-sidebar.v2-mobile-open .v2-mpa-children {
    display: block;
  }
}

/* ── EY home page — suppress shell chrome margin (Bug A fix) ────────────────── */
html.eylog-home #wren-main {
  margin-top: 0 !important;
}

