/* ════════════════════════════════════════════════
   layout.css — 主布局 / 侧边栏 / 顶栏 / 响应式
   ════════════════════════════════════════════════ */

.shell { display: flex; width: 100%; min-height: 100vh; }

/* ─── Sidebar(深色) ─── */
.sidebar {
  width: var(--sb-w);
  background: linear-gradient(180deg, #152620 0%, #101c17 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
}

.brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  display: flex; align-items: center; gap: 10px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent3), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.2px; color: #f0f6f2; }
.brand-sub  { font-size: 11px; color: rgba(224, 238, 231, .45); margin-top: 1px; }

.nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-sec {
  font-size: 10.5px; font-weight: 600; color: rgba(224, 238, 231, .38);
  letter-spacing: .8px; text-transform: uppercase;
  padding: 14px 12px 6px;
}
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  color: rgba(224, 238, 231, .68); font-size: 13px;
  transition: background .15s var(--ease), color .15s var(--ease);
  cursor: pointer;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: rgba(95, 162, 134, .2); color: #8fdcb8; font-weight: 600; }
.nav a.active::before {
  content: '';
  position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent3);
}
.nav a .ico { width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; opacity: .8; flex-shrink: 0; }
.nav a .ico svg { width: 16px; height: 16px; }
.nav a.active .ico { opacity: 1; }

.side-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: rgba(224, 238, 231, .6);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(224, 238, 231, .3); flex-shrink: 0; }
.dot.on { background: #4cc98e; box-shadow: 0 0 0 3px rgba(76, 201, 142, .2); animation: pulse 2.4s ease-in-out infinite; }
.side-foot .btn.ghost { color: rgba(224, 238, 231, .6); }
.side-foot .btn.ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* ─── Main ─── */
.main { flex: 1; margin-left: var(--sb-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 54px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 16px; font-weight: 650; letter-spacing: -.2px; font-variant-numeric: tabular-nums; }
.topbar-r { display: flex; align-items: center; gap: 8px; }

.menu-btn { display: none; background: none; border: none; color: var(--fg); font-size: 20px; cursor: pointer; padding: 6px 8px; }

.content { padding: 28px; flex: 1; overflow-y: auto; }

/* ─── Section 容器 ─── */
.section { display: none; animation: fade .25s ease; }
.section.active { display: block; }
.section.loading::before {
  content: '加载中…'; display: block; padding: 36px; text-align: center; color: var(--fg3);
}

/* ─── 移动抽屉遮罩 ─── */
.mob-mask {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(20, 20, 30, .35);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .2s;
}
.mob-mask.show { display: block; opacity: 1; }

/* ─── 响应式 ─── */

/* 大屏 (≥1440): 内容更舒展 */
@media (min-width: 1440px) {
  .content { padding: 32px 36px; }
  .stats { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  .page-head h2 { font-size: 26px; }
}

/* 小桌面 (1024-1280): 收侧栏 */
@media (max-width: 1280px) {
  :root { --sb-w: 220px; }
  .brand { padding: 16px 18px; }
  .nav a { padding: 7px 10px; font-size: 12.5px; }
}

/* 平板竖屏 (≤1024): 侧栏收起为图标条 */
@media (max-width: 1024px) {
  .nav a.active::before { display: none; }
  :root { --sb-w: 64px; }
  .brand { padding: 16px 12px; justify-content: center; flex-direction: column; gap: 6px; }
  .brand > div:not(.brand-mark) { display: none; }
  .nav { padding: 10px 6px; }
  .nav-sec { padding: 14px 0 6px; text-align: center; font-size: 9px; letter-spacing: .3px; }
  .nav a {
    justify-content: center; padding: 10px 0;
    flex-direction: column; gap: 3px;
    margin: 2px 6px; font-size: 10.5px;
  }
  .nav a .ico { font-size: 18px; }
  .side-foot { justify-content: center; padding: 10px 6px; }
  .side-foot > span:not(.dot), .side-foot > .btn { display: none; }
  .side-foot .dot { margin: 0; }
  .menu-btn { display: inline-block; }
  .content { padding: 22px 18px; }
}

/* 手机 (≤768): 侧栏变抽屉 */
@media (max-width: 768px) {
  :root { --sb-w: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    transition: transform .25s ease;
    z-index: 60;
    align-items: stretch;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open .brand > div:not(.brand-mark) { display: block; }
  .sidebar.open .brand { padding: 18px; justify-content: flex-start; flex-direction: row; }
  .sidebar.open .nav-sec { text-align: left; padding: 14px 12px 6px; }
  .sidebar.open .nav a {
    flex-direction: row; justify-content: flex-start;
    padding: 8px 12px; font-size: 13px; gap: 10px; margin: 2px 10px;
  }
  .sidebar.open .nav a .ico { font-size: 14px; }
  .sidebar.open .side-foot { justify-content: space-between; padding: 12px 14px; font-size: 12px; }
  .sidebar.open .side-foot > span:not(.dot), .sidebar.open .side-foot > .btn { display: initial; }

  .main { margin-left: 0; }
  .content { padding: 16px 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .val { font-size: 20px; }
  .stat .ico { font-size: 18px; top: 12px; right: 12px; }
  .charts { grid-template-columns: 1fr; gap: 12px; }
  .chart-h { height: 200px; }
  .panel-b { padding: 14px; }
  .panel-h { padding: 11px 14px; font-size: 12.5px; }
  .modal { width: 100%; max-height: 95vh; }
  .page-head h2 { font-size: 18px; }
  .page-head .desc { font-size: 12px; }
}

/* 极窄屏 (≤480) */
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .val { font-size: 18px; }
  .stat .lab { font-size: 11px; }
  .content { padding: 14px 12px; }
  .topbar { padding: 0 12px; height: 48px; }
  .topbar h1 { font-size: 14px; }
  .fr { flex-direction: column; gap: 10px; align-items: stretch; }
  .fg { min-width: 0; }
  .fr .fg[style*="max-width"] { max-width: 100% !important; }
  .tbl { font-size: 12px; }
  .tbl td, .tbl th { padding: 8px 10px; }
  .nav a, .panel-h { font-size: 12px; }
  .modal { padding: 18px; }
  .login-card { padding: 32px 24px; }
}

/* 横屏模式 (高度 < 480) */
@media (max-height: 480px) and (orientation: landscape) {
  .brand { padding: 12px 14px; }
  .nav { padding: 8px; }
  .nav-sec { padding: 8px 12px 4px; }
}