/* AllMCP dashboard shell + shared dashboard building blocks.
   Loaded by every /app/* page after tokens.css + base.css.
   The shell frame (sidebar, topbar, content slot) is injected by shell.js. */

.app { display: flex; min-height: 100vh; background: var(--surface); color: var(--text); }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
  transition: width 0.15s ease-out; /* 2d: 240↔64px, 150ms ease-out */
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px; }
.sidebar-brand { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.sidebar-toggle {
  width: 24px; height: 24px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; border-radius: 6px;
  color: var(--text-dim); font-size: 12px; cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.sidebar-toggle:hover { background: var(--subtle); color: var(--text); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius);
  font-size: 13px; color: var(--text-muted); cursor: pointer;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}
.nav-item svg { flex: none; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--subtle); color: var(--text); font-weight: 500; }
/* Active icon per 2a: first tile of the grid glyph lights up; stroked glyphs
   go full white (2d active rail tile). */
.nav-item.active svg rect[fill="#8A8F98"]:first-of-type { fill: var(--text); }
.nav-item.active svg [stroke="#8A8F98"] { stroke: var(--text); }
.nav-item.active svg circle[fill="#8A8F98"] { fill: var(--text); }
.nav-label { white-space: nowrap; transition: opacity 0.06s ease-out; } /* 2d: labels fade by 60ms */
/* Rail flyout tooltip (2d) — shown only while collapsed. */
.nav-tip {
  display: none; position: absolute; left: 48px; top: 50%; transform: translateY(-50%);
  background: var(--subtle); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 6px;
  padding: 4px 9px; font-size: 12px; font-weight: 400; color: var(--text);
  white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); z-index: 100;
  pointer-events: none;
}
.sidebar-spacer { flex: 1; }
.sidebar-foot { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-top: 1px solid var(--border); }
.nav-docs .docs-arrow { font-size: 11px; }
.sidebar-status { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius); font-size: 13px; color: var(--text-muted); }
.sidebar-status .dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--success); animation: allmcp-pulse 2.4s infinite; }
@keyframes allmcp-pulse {
  0% { box-shadow: 0 0 0 0 rgba(76, 195, 138, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(76, 195, 138, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 195, 138, 0); }
}
/* Owner override (2026-07-08): the status pulse is a live-signal element and
   keeps breathing even under prefers-reduced-motion (base.css kills the rest). */
@media (prefers-reduced-motion: reduce) {
  .sidebar-status .dot {
    animation: allmcp-pulse 2.4s infinite !important;
    animation-duration: 2.4s !important;
    animation-iteration-count: infinite !important;
  }
}
.avatar { width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--subtle); border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }

/* ---------- Collapsed rail (2d: 64px, icon tiles, hover tooltips) ---------- */
@media (min-width: 861px) {
  .app.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  .app.sidebar-collapsed .sidebar-head { flex-direction: column; align-items: center; gap: 10px; padding: 16px 0 6px; }
  .app.sidebar-collapsed .sidebar-brand { gap: 0; }
  .app.sidebar-collapsed .sidebar-brand svg { width: 22px; height: 22px; }
  .app.sidebar-collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; pointer-events: none; }
  .app.sidebar-collapsed .sidebar-nav { padding: 6px 13px; }
  .app.sidebar-collapsed .nav-item { width: 38px; height: 38px; padding: 0; gap: 0; justify-content: center; border-radius: 9px; }
  .app.sidebar-collapsed .nav-item svg { width: 16px; height: 16px; }
  .app.sidebar-collapsed .nav-item:hover .nav-tip,
  .app.sidebar-collapsed .nav-item:focus-visible .nav-tip { display: block; }
  .app.sidebar-collapsed .sidebar-foot { align-items: center; padding: 8px 13px 12px; }
  .app.sidebar-collapsed .nav-docs .docs-arrow { font-size: 12px; }
  .app.sidebar-collapsed .sidebar-status { width: 38px; height: 38px; padding: 0; gap: 0; justify-content: center; }
}

/* ---------- Main + topbar ---------- */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 20;
}
.topbar-title { font-size: 14px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.hamburger { display: none; width: 34px; height: 34px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--text-muted); cursor: pointer; }
.app-content { flex: 1; overflow: auto; }

/* ---------- Page scaffold ---------- */
.page { max-width: var(--content-max); margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; max-width: 620px; }
.section-title { font-size: 13px; color: var(--text-muted); }

/* ---------- Stat strip ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--panel); overflow: hidden; }
.stat { padding: 20px 24px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: none; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-family: var(--font-mono); font-size: 26px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 12px; color: var(--text-dim); margin-top: 12px; }

/* ---------- Progress / quota ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--subtle); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--text-muted); border-radius: 3px; transition: width 0.4s var(--ease); }
.progress.warn > span { background: var(--warning); }
.progress.over > span { background: var(--danger); }
/* Topbar quota pill (2a) — gray <80% · amber 80–99% · red 100% (2c). */
.quota-pill {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-pill);
  background: transparent; cursor: pointer;
  transition: border-color 0.14s var(--ease);
}
.quota-pill:hover { border-color: rgba(255, 255, 255, 0.2); }
.quota-pill .bar { width: 44px; height: 3px; border-radius: 2px; background: var(--subtle); overflow: hidden; }
.quota-pill .bar > span { display: block; height: 100%; background: var(--text-muted); }
.quota-pill .num { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text); }
.quota-pill.loading .num { color: var(--text-dim); }
.quota-pill.blocked { border-color: var(--border); cursor: default; }
.quota-pill.blocked .bar { display: none; }
.quota-pill.blocked .num { color: var(--text-muted); }
.quota-pill.warn { border-color: rgba(242, 201, 76, 0.35); }
.quota-pill.warn .bar > span { background: var(--warning); }
.quota-pill.warn .num { color: var(--warning); }
.quota-pill.over { border-color: rgba(235, 87, 87, 0.4); }
.quota-pill.over .bar > span { background: var(--danger); }
.quota-pill.over .num { color: var(--danger); }
.kbd { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: var(--radius-sm); padding: 3px 7px; }
button.kbd { background: none; cursor: pointer; transition: color 0.12s var(--ease), border-color 0.12s var(--ease); }
button.kbd:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.2); }

/* ---------- Command palette (8a/8b/8c) ---------- */
.pal-overlay { position: fixed; inset: 0; z-index: 1100; background: rgba(0, 0, 0, 0.5); animation: fade-in 0.15s var(--ease); }
.pal {
  position: absolute; top: 110px; left: 50%; transform: translateX(-50%);
  width: 560px; max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); overflow: hidden;
  display: flex; flex-direction: column;
}
.pal-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.pal-head svg { flex: none; }
.pal-input {
  flex: 1; min-width: 0; padding: 0; border: none; background: none; outline: none;
  font-family: var(--font-sans); font-size: 14.5px; color: var(--text);
  caret-color: var(--accent);
}
.pal-input::placeholder { color: var(--text-dim); }
.pal-esc { flex: none; margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 5px; padding: 2px 6px; }
.pal-list { display: flex; flex-direction: column; padding: 8px; overflow-y: auto; max-height: min(478px, calc(100vh - 240px)); }
.pal-sec { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); letter-spacing: 0.06em; padding: 12px 12px 4px; }
.pal-sec:first-child { padding-top: 8px; }
.pal-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  border-radius: 8px; font-size: 13.5px; color: var(--text-muted); cursor: pointer;
}
.pal-item svg { flex: none; color: var(--text-dim); }
.pal-item.sel { background: var(--subtle); box-shadow: inset 2px 0 0 var(--accent); color: var(--text); }
.pal-item.sel svg { color: var(--text-muted); }
.pal-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-m { color: var(--text); font-weight: 600; }
.pal-hint { flex: none; margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); }
.pal-enter { visibility: hidden; }
.pal-item.sel .pal-enter { visibility: visible; }
.pal-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 18px; }
.pal-empty-title { font-size: 13.5px; color: var(--text-muted); }
.pal-empty-docs { font-size: 13px; color: var(--text-muted); }
.pal-empty-docs a { color: var(--text); cursor: pointer; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, 0.25); }
.pal-empty-docs a:hover { border-bottom-color: var(--text); }
.pal-foot { display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-dim); }
.pal-key { font-family: var(--font-mono); }

/* ---------- Tables / lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); font-size: 12px; color: var(--text-muted); cursor: pointer; background: transparent; }
.chip.active { background: var(--subtle); color: var(--text); border-color: var(--border-hover); }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 24px; }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--subtle); display: flex; align-items: center; justify-content: center; color: var(--text-muted); margin-bottom: 4px; }
.empty-title { font-size: 15px; font-weight: 600; }
.empty-text { font-size: 13px; color: var(--text-muted); max-width: 380px; }

/* ---------- Drawer (right slide-in) ---------- */
.drawer-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(0, 0, 0, 0.5); display: flex; justify-content: flex-end; animation: fade-in 0.15s var(--ease); }
.drawer { width: 100%; max-width: 440px; height: 100%; background: var(--panel); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-drawer); display: flex; flex-direction: column; animation: drawer-in 0.18s var(--ease); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border); flex: none; }
.drawer-title { font-size: 14px; font-weight: 600; }
.drawer-body { flex: 1; overflow: auto; padding: 24px; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex: none; }
.icon-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-muted); background: transparent; border: none; cursor: pointer; }
.icon-btn:hover { background: var(--subtle); color: var(--text); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* ---------- Danger zone ---------- */
.danger-zone { border: 1px solid rgba(235, 87, 87, 0.3); border-radius: var(--radius-lg); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%); transition: transform 0.2s var(--ease);
    box-shadow: var(--shadow-pop);
  }
  .sidebar-toggle { display: none; } /* off-canvas drawer replaces the rail on mobile */
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.5); }
  .hamburger { display: flex; }
  .topbar { padding: 0 16px; }
  .page { padding: 18px 16px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: none; }
  .stat:nth-child(1), .stat:nth-child(2) { border-bottom: 1px solid var(--border); }
}
@media (max-width: 520px) {
  .stat-strip { grid-template-columns: 1fr; }
  .stat { border-right: none; border-bottom: 1px solid var(--border); }
  .stat:last-child { border-bottom: none; }
}
