/* ============================================================
   layout.css — 应用外壳 / 侧边栏 / 顶栏 / 卡片网格 / 响应式
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-logo {
  font-size: 26px; line-height: 1;
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--accent-weak); border-radius: 12px;
}
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--text-3); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item .ico { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.conn {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 12px; font-size: 12.5px; color: var(--text-2);
}
.sidebar-tools { display: flex; gap: 8px; }

/* ---------- 主区域 ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.conn-mini { font-size: 12.5px; color: var(--text-3); }

.view { padding: 26px; max-width: 1080px; width: 100%; }

/* ---------- 卡片网格 ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(12, 1fr); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card.span-12 { grid-column: span 12; }
.card.span-8 { grid-column: span 8; }
.card.span-6 { grid-column: span 6; }
.card.span-4 { grid-column: span 4; }
.card.span-3 { grid-column: span 3; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; }
.card-head .sub { color: var(--text-3); font-size: 12.5px; margin-left: auto; }

/* 统计小卡 */
.stat { display: flex; flex-direction: row; align-items: center; gap: 12px; }
.stat .ico { font-size: 26px; flex: 0 0 auto; line-height: 1; }
.stat .stext { display: flex; flex-direction: row; align-items: baseline; gap: 6px; min-width: 0; flex-wrap: wrap; }
.stat .num { font-size: 26px; font-weight: 700; letter-spacing: .5px; line-height: 1.1; }
.stat .lbl { color: var(--text-3); font-size: 12.5px; }

.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 20px; }
.page-head p { color: var(--text-3); margin: 4px 0 0; }

/* ---------- 响应式 ---------- */
.only-mobile { display: none; }

/* 大屏（≥1280px）：放宽内容区宽度，侧边栏略宽 */
@media (min-width: 1280px) {
  :root { --sidebar-w: 264px; }
  .view { max-width: 1280px; }
}

/* 平板 / 小笔记本（≤1080px）：侧边栏保留，但把 3/4 列卡片收成 2 列，避免被挤窄 */
@media (max-width: 1080px) {
  .card.span-3 { grid-column: span 6; }
  .card.span-4 { grid-column: span 6; }
  .card.span-8 { grid-column: span 12; }
}

/* 手机（≤860px）：侧边栏改为抽屉，卡片整行铺满 */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; max-width: 82vw; z-index: 40;
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: inline-flex; }
  .view { padding: 18px 16px; }
  .topbar { padding: 14px 16px; }
  .card.span-8, .card.span-6, .card.span-4, .card.span-3 { grid-column: span 12; }
}

/* 小屏手机（≤560px）：进一步收紧间距与字号 */
@media (max-width: 560px) {
  .view { padding: 14px 12px; }
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar h1 { font-size: 16px; }
  .conn-mini { display: none; }
  .grid { gap: 14px; }
  .card { padding: 16px; }
  .card.span-8, .card.span-6, .card.span-4, .card.span-3 { grid-column: span 12; }
  .stat .num { font-size: 22px; }
  .stat .ico { font-size: 22px; }
  .page-head { margin-bottom: 16px; }
  .page-head h2 { font-size: 18px; }
  .page-head p { font-size: 12.5px; }
}
