/* ============================================================
   StepScore · layout.css
   应用外壳 / 侧边栏 / 顶栏 / 页面网格
   ============================================================ */

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ------------------------------------------------------------------
   侧边栏
------------------------------------------------------------------ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(250, 251, 247, 0.94)),
    var(--surface);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 6px 12px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-deep) 100%);
  display: grid;
  place-items: center;
  color: #f7efe1;
  box-shadow: 0 8px 18px -8px rgba(10, 79, 65, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  flex: none;
}
.brand-text { min-width: 0; }
.brand-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 750;
  font-size: 16.5px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand-name em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-deep);
  letter-spacing: 0.14em;
  padding: 1px 6px;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  border-radius: var(--r-full);
  transform: translateY(-1px);
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.03em;
  margin-top: 1px;
}

.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  padding: 0 10px 7px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.13em;
  color: var(--ink-4);
  text-transform: uppercase;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.nav-item .ic { color: var(--ink-4); transition: color 0.16s var(--ease); }
.nav-item:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav-item:hover .ic { color: var(--ink-2); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--brand-soft-2);
}
.nav-item.active .ic { color: var(--brand); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
}
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 10.5px;
  font-weight: 700;
}
.nav-item.active .nav-badge { background: #fff; color: var(--brand); }

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

.side-card {
  margin: 4px 2px 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(194, 118, 44, 0.09), transparent 60%),
    var(--surface-2);
}
.side-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-2);
}
.side-card p { margin-top: 5px; font-size: 11.5px; line-height: 1.55; color: var(--ink-3); }
.side-card .link-btn { margin-top: 8px; }

.sidebar-foot {
  padding: 10px 8px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.role-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.role-switch:hover { border-color: var(--brand-line); background: var(--brand-soft); color: var(--brand-ink); }
.role-switch .ic { color: var(--brand); }
.role-switch .switch-hint { margin-left: auto; color: var(--ink-4); font-size: 10.5px; }

/* ------------------------------------------------------------------
   主区域 / 顶栏
------------------------------------------------------------------ */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: rgba(245, 246, 242, 0.82);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid rgba(227, 231, 223, 0.9);
}
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink-3);
  font-size: 12.5px;
}
.crumb .ic { color: var(--ink-4); }
.crumb-current { color: var(--ink); font-weight: 600; }
.crumb-sep { color: var(--line-2); }

.topbar-spacer { flex: 1 1 auto; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 250px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink-4);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.searchbox:focus-within {
  border-color: var(--brand-line);
  background: #fff;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.searchbox input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 12.5px;
  color: var(--ink);
}
.searchbox input::placeholder { color: var(--ink-4); }
.searchbox .kbd { flex: none; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-3);
  transition: background 0.16s var(--ease), color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn .dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 2px var(--bg);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 9px 0 4px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  background: transparent;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease);
}
.user-chip:hover { background: var(--surface); border-color: var(--line); }
.user-chip .meta { text-align: left; line-height: 1.25; }
.user-chip .meta b { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink); }
.user-chip .meta span { font-size: 10.5px; color: var(--ink-4); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
  box-shadow: inset 0 0 0 1px var(--brand-soft-2);
}
.avatar--lg { width: 42px; height: 42px; font-size: 15px; border-radius: 13px; }
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar[data-tone="amber"] { background: var(--accent-soft); color: var(--accent-deep); box-shadow: inset 0 0 0 1px #f2ddc2; }
.avatar[data-tone="blue"] { background: var(--info-soft); color: var(--info); box-shadow: inset 0 0 0 1px var(--info-line); }
.avatar[data-tone="violet"] { background: var(--violet-soft); color: var(--violet); box-shadow: inset 0 0 0 1px #ded7f0; }
.avatar[data-tone="clay"] { background: #f7e9e7; color: #9c4a42; box-shadow: inset 0 0 0 1px #eed3cf; }

/* ------------------------------------------------------------------
   页面容器
------------------------------------------------------------------ */
.view {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 26px 28px 64px;
  min-width: 0;
}

.page-hd {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-hd-main { min-width: 0; }
.page-eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.page-eyebrow .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.page-title {
  font-size: 25px;
  line-height: 1.22;
  font-weight: 720;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}
.page-title .thin { font-weight: 450; color: var(--ink-3); }
.page-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-3);
  max-width: 760px;
  line-height: 1.65;
}
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* 网格 */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; gap: 16px; }
.grid-sidebar-wide { display: grid; grid-template-columns: minmax(0, 1fr) 420px; align-items: start; gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 16px; }

@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-sidebar, .grid-sidebar-wide, .grid-main { grid-template-columns: minmax(0, 1fr); }
}
.nav-toggle { display: none; }
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    z-index: 40;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 0 16px 40px rgba(20, 28, 24, .16);
  }
  .sidebar.is-open { transform: translateX(0); }
  .nav-toggle { display: inline-grid; }
  .topbar { padding: 0 18px; }
  .searchbox { width: 180px; }
  .view { padding: 20px 18px 48px; }
}
.task-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 16px;
  background: #fff8e8;
  border-bottom: 1px solid var(--line);
}
.task-banner[hidden] { display: none; }
.task-banner-item {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 13px;
}
.task-banner-item b,
.task-banner-item span { min-width: 0; overflow-wrap: anywhere; }
.task-banner-item span { color: var(--ink-2); }
.task-banner-item button { margin-left: auto; }

@media (max-width: 820px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .page-hd { align-items: flex-start; }
  .page-title { font-size: 22px; }
  .searchbox { display: none; }
  .user-chip .meta { display: none; }
  .topbar .crumb { display: none; }
  .table { min-width: 680px; }
}
