  :root {
    --bg: #0b1326;
    --surface-1: #101a33;
    --surface-2: #16223f;
    --border: rgba(255,255,255,0.07);
    --text: #e2e8f0;
    --text-dim: #88929b;
    --accent: #0ea5e9;
    --accent-2: #0284c7;
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --red: #ef4444;
    --warn: var(--yellow);
    --sidebar-w: 220px;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg); color: var(--text); min-height: 100vh;
  }
  h1, h2, h3, .display { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.01em; }
  .material-symbols-rounded {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    user-select: none; font-size: 1.25rem; line-height: 1;
    display: inline-block; vertical-align: middle;
  }
  a { color: inherit; text-decoration: none; }

  /* ── 登入頁 ── */
  #login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
  .login-card {
    width: 100%; max-width: 380px; padding: 2rem;
    background: var(--surface-1); border-radius: 16px; border: 1px solid var(--border);
  }
  .login-shield {
    width: 44px; height: 44px; border-radius: 12px; margin-bottom: 1.25rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex; align-items: center; justify-content: center; color: #fff;
  }
  label { display: block; font-size: 0.75rem; color: var(--text-dim);
          margin-bottom: 0.4rem; font-weight: 600; }
  input {
    width: 100%; padding: 0.7rem 0.85rem; margin-bottom: 1rem;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text); font-family: 'Manrope', sans-serif; font-size: 0.9rem;
  }
  input:focus { outline: none; border-color: var(--accent); }
  button.primary {
    width: 100%; padding: 0.75rem; border: none; border-radius: 10px; cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 0.9rem;
  }
  button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
  .error { color: var(--red); font-size: 0.8rem; margin-bottom: 0.75rem; min-height: 1.1rem; }

  /* ── 主外殼 ── */
  #shell { display: none; }
  #shell.on { display: block; }
  aside {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 50;
    background: rgba(11,19,38,0.88);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 1rem 0.75rem;
  }
  .brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.5rem 1.25rem; }
  .brand-mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex; align-items: center; justify-content: center; color: #fff;
  }
  .brand-mark .material-symbols-rounded { font-size: 1.1rem; }
  .brand-text { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.9rem; }
  nav a, nav button.nav-btn {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.6rem 0.7rem; border-radius: 10px; margin-bottom: 0.15rem;
    font-size: 0.85rem; font-weight: 600; color: var(--text-dim); cursor: pointer;
  }
  nav a:hover, nav button.nav-btn:hover { background: var(--surface-1); color: var(--text); }
  nav a.active { background: var(--surface-2); color: var(--accent); }
  nav a .material-symbols-rounded, nav button.nav-btn .material-symbols-rounded { font-size: 1.15rem; }
  nav button.nav-btn {
    width: 100%; background: none; border: none; text-align: left;
    font-family: 'Manrope', sans-serif;
  }
  a:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
  }
  .nav-spacer { flex: 1; }
  main { margin-left: var(--sidebar-w); padding: 1.75rem 2rem 3rem; }
  .page { display: none; }
  .page.on { display: block; }
  .page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.25rem; }

  /* ── 通知橫幅（黃底警示，例如「正在使用初始密碼」）── */
  .notice {
    display: flex; align-items: center; gap: 0.6rem;
    background: rgba(234,179,8,0.12); border: 1px solid rgba(234,179,8,0.35);
    color: var(--yellow); border-radius: 12px; padding: 0.7rem 0.9rem;
    font-size: 0.82rem; font-weight: 600; margin-bottom: 1.25rem;
  }
  .notice a { text-decoration: underline; cursor: pointer; }
  .notice .material-symbols-rounded:first-child { flex-shrink: 0; }
  .notice-close {
    margin-left: auto; flex-shrink: 0; background: none; border: none; cursor: pointer;
    color: inherit; opacity: 0.7; padding: 0; display: flex; align-items: center;
  }
  .notice-close:hover { opacity: 1; }

  /* ── 共用元件 ── */
  .card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: 14px; padding: 1.1rem 1.25rem;
  }
  .card-title { font-size: 0.8rem; color: var(--text-dim); font-weight: 700; margin-bottom: 0.9rem; }
  .grid { display: grid; gap: 1rem; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .stat-label { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.35rem; font-weight: 600; }
  .stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700; }
  .stat-delta { font-size: 0.72rem; margin-top: 0.3rem; }
  .up { color: var(--green); } .down { color: var(--red); }
  table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
  th { text-align: left; color: var(--text-dim); font-weight: 700; font-size: 0.75rem;
       padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
  td { padding: 0.55rem 0.6rem; border-bottom: 1px solid rgba(255,255,255,0.04); }
  .muted { color: var(--text-dim); }
  .btn-sm {
    padding: 0.4rem 0.75rem; border-radius: 8px; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    font-family: 'Manrope', sans-serif; font-weight: 600; font-size: 0.78rem;
  }
  .btn-sm:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
  .btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
  .btn-sm.active { border-color: var(--accent); color: var(--accent); }
  /* 狀態燈（例如系統健康頁的 165 快照燈號）。background-color 由呼叫端
     以 inline style 指定（ok/stale/critical/missing 對應不同顏色）。 */
  .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

  /* ── 流量頁：7×24 熱圖 ── */
  .heat { display: grid; grid-template-columns: 2.2rem repeat(24, 1fr); gap: 2px; font-size: 0.6rem; }
  .heat .cell { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); }
  .heat .rowlabel, .heat .collabel { color: var(--text-dim); display: flex;
                                     align-items: center; justify-content: center; }
  .bar-inline { height: 6px; border-radius: 3px; background: var(--accent); }

  /* ── Key Pool 頁 ──
     命名刻意避開會撞到既有共用類別的名字（.dot／.btn-sm／.notice 在
     其他七頁或外殼本身已經在用，字級、圓角、粗細都不一樣——直接同名
     重新定義會因為 CSS cascade「後面蓋前面」，把這裡的樣式滲到系統
     健康頁的狀態燈、密碼變更橫幅、其他頁的篩選按鈕上）。這裡只新增
     `.btn-sm.danger` 這個修飾類別（純附加，其餘七頁沒人用過這個組合，
     不會覆蓋任何既有規則）。 */
  .slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.85rem; }
  .slot { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem; }
  .slot.down { opacity: 0.55; border-color: rgba(239,68,68,0.35); }
  .slot-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; gap: 0.5rem; }
  .slot-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.88rem; word-break: break-word; }
  .slot-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
  .slot-dot.ok { background: var(--green); }
  .slot-dot.cool { background: var(--yellow); }
  .slot-dot.full { background: var(--red); }
  .meter { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 0.2rem 0 0.55rem; }
  .meter > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
  .meter.full > i { background: var(--red); }
  .meter-row { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--text-dim); }
  .tag { display: inline-block; font-size: 0.62rem; font-weight: 700; padding: 0.12rem 0.4rem;
         border-radius: 5px; background: var(--surface-2); color: var(--text-dim); }
  .tag.warn { background: rgba(234,179,8,0.15); color: var(--yellow); }
  .btn-sm.danger { border-color: rgba(239,68,68,0.4); color: var(--red); }
  /* 額度前提提示（黃底說明）—— 不叫 .notice：那個類別已經是外殼的
     「初始密碼」橫幅在用（display:flex、不同字級／圓角），同名重定義
     會讓那個橫幅的樣式跟著這裡跑掉。 */
  .llm-notice { background: rgba(234,179,8,0.1); border: 1px solid rgba(234,179,8,0.3);
                border-radius: 10px; padding: 0.7rem 0.9rem; font-size: 0.78rem;
                color: #fde68a; margin-bottom: 1rem; }
  /* Pool 是空的且正式環境（真故障，不是中性狀態）——紅色，比額度提示
     更嚴重，跟系統健康頁「0（池子是空的）」用同一種語意（紅字），但
     這裡要放一整段說明，不只一個數字。 */
  .llm-fault { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.35);
               border-radius: 10px; padding: 0.9rem 1rem; font-size: 0.85rem; color: #fca5a5; }
  .llm-fault strong { color: var(--red); }
  /* 啟用未驗證模型後，後端回傳的 warning——必須顯眼，用跟 .llm-fault
     同等級的視覺重量，不能只是安靜的 .muted 小字或曇花一現的 alert()。 */
  .llm-model-warn { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.4);
                    border-radius: 10px; padding: 0.7rem 0.9rem; font-size: 0.8rem;
                    color: #fca5a5; margin: 0.5rem 0 0.75rem; display: flex; gap: 0.5rem; align-items: flex-start; }
  .llm-model-warn .material-symbols-rounded { font-size: 1.1rem; }

  @media (max-width: 860px) {
    aside { left: -100%; }
    main { margin-left: 0; padding: 1.25rem 1rem 5rem; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    nav.mobile {
      position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
      display: flex; overflow-x: auto; gap: 0.25rem; padding: 0.4rem;
      background: rgba(11,19,38,0.94); backdrop-filter: blur(16px);
      border-top: 1px solid var(--border);
    }
    nav.mobile a { flex-direction: column; gap: 0.15rem; font-size: 0.62rem; padding: 0.4rem 0.6rem; }
  }
  @media (min-width: 861px) { nav.mobile { display: none; } }
