/* =============================================================================
 * base.css — 复位、排版、应用外壳骨架
 * ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--bf-font-sans);
  font-size: var(--ah-fs-13);
  line-height: 1.55;
  color: var(--ah-text-1);
  background: var(--ah-bg-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6, p, figure, ul, ol {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--cf-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

code,
kbd,
.mono {
  font-family: var(--bf-font-mono);
  font-size: 0.92em;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--ah-hairline-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bf-text-subtle);
  background-clip: content-box;
}

/* -----------------------------------------------------------------------------
 * 应用外壳：顶栏 + 侧边导航 + 内容区
 * -------------------------------------------------------------------------- */

/* #app 只承载布局类，不要在这里设置 display：
 * ID 选择器权重高于 .app-shell，会覆盖掉网格布局。 */
#app {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar"
    "sidenav content";
  min-height: 100vh;
}

.app-shell.is-bare {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "topbar"
    "content";
}

/* ---- 启动占位（main.js 挂载后会被整体替换） ---- */
.boot-splash {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 60vh;
  color: var(--ah-text-3);
  font-size: var(--ah-fs-13);
}

/* ---- 顶栏 ---- */
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--ah-separator);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--ah-radius-xs);
  background: linear-gradient(140deg, var(--ah-accent) 0%, #8f6ef0 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(109, 73, 216, 0.28);
}

.brand-name {
  font-size: var(--ah-fs-14);
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-sub {
  font-size: var(--ah-fs-11);
  color: var(--ah-text-3);
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1 1 auto;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 项目级联选择器 */
.cascade {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--ah-hairline);
  border-radius: 999px;
  background: var(--ah-surface-1);
  box-shadow: var(--ah-shadow-2);
}

.cascade-label {
  font-size: var(--ah-fs-11);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ah-text-3);
}

.cascade select {
  border: none;
  background: transparent;
  font-size: var(--ah-fs-12);
  font-weight: 600;
  color: var(--ah-text-1);
  padding: 4px 2px;
  max-width: 240px;
  cursor: pointer;
}

.cascade select:focus {
  outline: none;
}

.cascade-sep {
  color: var(--ah-text-4);
  font-size: var(--ah-fs-11);
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--ah-hairline);
  background: var(--ah-surface-1);
}

.who-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ah-accent-soft);
  color: var(--ah-accent-ink);
  font-size: 11px;
  font-weight: 800;
}

.who-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.who-name {
  font-size: var(--ah-fs-11);
  font-weight: 700;
}

.who-role {
  font-size: 10px;
  color: var(--ah-text-3);
}

/* ---- 侧边导航 ---- */
.sidenav {
  grid-area: sidenav;
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 14px 12px 24px;
  background: var(--ah-surface-1);
  border-right: 1px solid var(--ah-separator);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-group-title {
  padding: 0 10px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ah-text-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 2px;
  border: none;
  border-radius: var(--ah-radius-xs);
  background: transparent;
  color: var(--ah-text-2);
  font-size: var(--ah-fs-12);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--ah-surface-2);
  color: var(--ah-text-1);
  text-decoration: none;
}

.nav-item.active {
  background: var(--ah-accent-soft);
  color: var(--ah-accent-ink);
}

.nav-item .nav-icon {
  flex: none;
  width: 16px;
  height: 16px;
  opacity: 0.85;
}

.nav-item .nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ah-surface-3);
  color: var(--ah-text-2);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.nav-item.active .nav-count {
  background: rgba(109, 73, 216, 0.16);
  color: var(--ah-accent-ink);
}

.sidenav-foot {
  margin-top: auto;
  padding: 10px;
  border-radius: var(--ah-radius-sm);
  background: var(--ah-surface-2);
  font-size: 10px;
  line-height: 1.5;
  color: var(--ah-text-3);
}

/* ---- 内容区 ---- */
.content {
  grid-area: content;
  min-width: 0;
  padding: 20px 24px 56px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ah-text-4);
}

.page-title {
  margin-top: 2px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--ah-text-1);
}

.page-lead {
  margin-top: 6px;
  max-width: 78ch;
  font-size: var(--ah-fs-12);
  line-height: 1.65;
  color: var(--ah-text-2);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: var(--ah-fs-11);
  color: var(--ah-text-3);
}

.breadcrumb a {
  color: var(--ah-text-2);
  font-weight: 600;
}

.breadcrumb .sep {
  color: var(--ah-text-4);
}

/* ---- 通用排版工具 ---- */
.stack {
  display: grid;
  gap: 16px;
}

.stack-sm {
  display: grid;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-tight {
  display: flex;
  align-items: center;
  gap: 6px;
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.muted {
  color: var(--ah-text-3);
}

.subtle {
  color: var(--ah-text-2);
}

.tiny {
  font-size: 11px;
}

.nowrap {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "sidenav"
      "content";
  }

  .sidenav {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--ah-separator);
    gap: 8px;
  }

  .sidenav .nav-group-title,
  .sidenav-foot {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
    width: auto;
  }

  .content {
    padding: 16px 14px 48px;
  }
}
