/* 布局骨架 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  color: var(--text); font-size: 14px; line-height: 1.55;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--panel2); padding: 1px 5px; border-radius: 4px; color: var(--sub); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .2px; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }

.app { display: grid; grid-template-columns: 214px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px 17px; border-bottom: 1px solid var(--border-soft); }
.brand-mark {
  width: 35px; height: 35px; border-radius: 11px; display: grid; place-items: center;
  font-size: 18px; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 5px 16px var(--accent-soft);
}
.brand b { display: block; font-size: 15px; letter-spacing: .6px; }
.brand small { color: var(--sub); font-size: 11px; letter-spacing: .5px; }
#nav { padding: 12px 10px; flex: 1; overflow: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px;
  color: var(--sub); cursor: pointer; margin-bottom: 3px; transition: background .16s, color .16s, transform .16s;
  font-size: 13px; user-select: none;
}
.nav-item:hover { background: var(--panel2); color: var(--text); transform: translateX(2px); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; font-size: 15px; flex: none; }
.nav-tag { margin-left: auto; font-size: 10px; color: var(--faint); }
.side-foot { padding: 13px; border-top: 1px solid var(--border-soft); }
.boundary { font-size: 11px; color: var(--sub); background: var(--panel2); border: 1px solid var(--border-soft); border-radius: 9px; padding: 9px 11px; line-height: 1.7; }
.boundary small { display: block; color: var(--faint); font-size: 10px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20;
}
.tb-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.tb-left h1 { font-size: 17px; white-space: nowrap; }
.crumb { color: var(--sub); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-right { display: flex; align-items: center; gap: 9px; flex: none; }
.poll-pill {
  display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--sub);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 20px; padding: 5px 11px; white-space: nowrap;
}
.poll-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--in); box-shadow: 0 0 0 3px var(--in-soft); flex: none; }
.poll-pill.warn .dot { background: var(--lim); box-shadow: 0 0 0 3px var(--lim-soft); }
.poll-pill.stale .dot { background: var(--out); box-shadow: 0 0 0 3px var(--out-soft); }
.health-badge { font-size: 11.5px; color: var(--in); white-space: nowrap; }
.health-badge.bad { color: var(--out); }
.health-badge.warn { color: var(--lim); }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--sub); cursor: pointer; font-size: 14px; line-height: 1;
  display: grid; place-items: center; transition: .16s; flex: none;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.view { padding: 22px 24px 30px; flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; }
.foot { padding: 12px 24px; color: var(--faint); font-size: 11px; border-top: 1px solid var(--border-soft); }

@media (max-width: 900px) {
  .crumb { display: none; }
  .poll-pill { display: none; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: 100%; height: auto;
    border-right: 0; border-top: 1px solid var(--border); flex-direction: row; align-items: center;
    padding-bottom: env(safe-area-inset-bottom); /* PWA / iPhone 底部安全区 */
  }
  .brand, .side-foot { display: none; }
  #nav { display: flex; padding: 6px; gap: 2px; overflow-x: auto; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 10px; margin: 0; white-space: nowrap; }
  .nav-item:hover { transform: none; }
  .nav-ico { font-size: 16px; }
  .nav-tag { display: none; }
  .view { padding: 16px 14px 90px; }
  .topbar { padding: 0 14px; }
  .foot { display: none; }
}
