/* ==========================================================================
   基础重置与排版
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { min-height: 100vh; }

a { color: var(--c-primary-600); text-decoration: none; }
a:hover { color: var(--c-primary-700); }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.4; color: var(--text-primary); }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

p { margin: 0 0 var(--space-3); }

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

/* ==========================================================================
   布局：登录页
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-app);
}
.login-page__brand {
  background: linear-gradient(135deg, var(--c-primary-700) 0%, var(--c-primary-900) 100%);
  color: var(--text-inverse);
  display: flex; flex-direction: column; justify-content: center;
  padding: 64px;
  position: relative;
  overflow: hidden;
}
.login-page__brand::before,
.login-page__brand::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.login-page__brand::before { width: 320px; height: 320px; top: -80px; right: -80px; }
.login-page__brand::after  { width: 200px; height: 200px; bottom: -60px; left: -60px; }

.login-page__logo {
  display: flex; align-items: center; gap: 12px;
  font-size: 22px; font-weight: 600;
  position: relative; z-index: 1;
}
.login-page__logo-icon {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.login-page__pitch {
  margin-top: 48px;
  font-size: 36px; font-weight: 700; line-height: 1.3;
  max-width: 480px;
  position: relative; z-index: 1;
}
.login-page__sub {
  margin-top: 16px;
  font-size: 15px;
  color: rgba(255,255,255,0.75);
  max-width: 440px;
  position: relative; z-index: 1;
}
.login-page__features {
  margin-top: 48px;
  display: flex; flex-direction: column; gap: 14px;
  position: relative; z-index: 1;
}
.login-page__feature {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: rgba(255,255,255,0.85);
}
.login-page__feature-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-primary-300);
}
.login-page__footer {
  position: absolute; bottom: 32px; left: 64px;
  font-size: 12px; color: rgba(255,255,255,0.45);
  z-index: 1;
}

.login-page__form-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-card__title {
  font-size: 28px; font-weight: 700; margin-bottom: 8px;
}
.login-card__subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

@media (max-width: 960px) {
  .login-page { grid-template-columns: 1fr; }
  .login-page__brand { display: none; }
}

/* ==========================================================================
   布局：主 SPA
   ========================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* 侧栏 */
.sidebar {
  grid-area: sidebar;
  background: var(--c-gray-900);
  color: var(--c-gray-300);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar__header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  height: var(--topbar-height);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.sidebar__logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--c-primary-400), var(--c-primary-600));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white; font-weight: 700;
}
.sidebar__title {
  font-size: 15px; font-weight: 600; color: white;
  letter-spacing: 0.3px;
}
.sidebar__subtitle {
  font-size: 11px; color: var(--c-gray-500);
  margin-top: 1px;
}

.sidebar__nav {
  flex: 1; overflow-y: auto;
  padding: 12px 0;
}
.sidebar__group {
  padding: 12px 0;
}
.sidebar__group-title {
  padding: 4px 18px;
  font-size: 11px;
  color: var(--c-gray-500);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.sidebar__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  margin: 1px 8px;
  border-radius: var(--radius-md);
  color: var(--c-gray-300);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast);
}
.sidebar__item:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}
.sidebar__item.is-active {
  background: var(--c-primary-600);
  color: white;
  box-shadow: 0 1px 3px rgba(2, 132, 199, 0.4);
}
.sidebar__item.is-active .sidebar__icon { color: white; }
.sidebar__icon {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-gray-400);
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar__item:hover .sidebar__icon { color: var(--c-gray-200); }
.sidebar__badge {
  margin-left: auto;
  background: var(--c-danger);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar__footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11px;
  color: var(--c-gray-500);
}

/* 顶栏 */
.topbar {
  grid-area: topbar;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0;
  z-index: 10;
}
.topbar__crumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.topbar__crumb .sep { color: var(--c-gray-300); }
.topbar__crumb .current { color: var(--text-primary); font-weight: 600; }

.topbar__spacer { flex: 1; }

.topbar__search {
  position: relative;
  width: 280px;
}
.topbar__search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0 12px 0 36px;
  background: var(--bg-app);
  font-size: 13px;
  color: var(--text-primary);
  transition: all var(--t-fast);
}
.topbar__search input:focus {
  outline: none;
  background: white;
  border-color: var(--c-primary-500);
  box-shadow: 0 0 0 3px var(--c-primary-50);
}
.topbar__search-icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--c-gray-400); font-size: 14px;
}

.topbar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--t-fast);
}
.topbar__user:hover { background: var(--bg-hover); }
.topbar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary-400), var(--c-primary-600));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.topbar__username {
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
}
.topbar__userrole {
  font-size: 11px;
  color: var(--text-tertiary);
}
.topbar__menu {
  position: relative;
}
.topbar__dropdown {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 4px;
  z-index: 50;
}
.topbar__dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.topbar__dropdown-item:hover { background: var(--bg-hover); }
.topbar__dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

/* 主区 */
.main {
  grid-area: main;
  overflow-y: auto;
  background: var(--bg-app);
  padding: 24px;
}

/* ==========================================================================
   页面通用容器
   ========================================================================== */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-header__title { font-size: 22px; font-weight: 600; margin: 0; }
.page-header__sub { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.page-header__actions { display: flex; gap: 8px; align-items: center; }