* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--c-bg); color: var(--c-text); min-height: 100vh; padding-bottom: 56px; }

.page-wrap { padding-top: calc(56px + 40px + 24px); padding-bottom: calc(48px + 56px); max-width: 900px; margin: 0 auto; padding-left: 24px; padding-right: 24px; opacity: 0; animation: fadeIn 1s ease forwards; animation-delay: 0.2s; }

.header { margin-bottom: 32px; }
.header h1 { font-size: 1.5rem; font-weight:400; letter-spacing: 0.08em; margin-bottom: 4px; }
.header .ts { font-size: 0.75rem; color: var(--c-text-secondary); }

.section { margin-bottom: 32px; }
.section-title { font-size: 0.7rem; font-weight: 400; letter-spacing: 0.2em; color: var(--c-text-secondary); text-transform: uppercase; margin-bottom: 12px; }
.section-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-title-row .section-title { margin-bottom: 0; }

.info-btn { width: 16px; height: 16px; border-radius: 50%; border: 1px solid #777; background: transparent; color: #888; font-size: 0.6rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; transition: border-color 0.2s, color 0.2s; font-family: system-ui, sans-serif; line-height: 1; }
.info-btn:hover { border-color: #888; color: var(--c-text-secondary); }
.info-btn .tooltip { display: none; position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); background: var(--c-border); border: 1px solid var(--c-border-hover); border-radius: 8px; padding: 14px 16px; font-size: 0.75rem; color: var(--c-text-secondary); line-height: 1.6; width: 280px; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,0.4); text-align: left; font-weight: 400; letter-spacing: 0; text-transform: none; pointer-events: none; }
.info-btn:hover .tooltip { display: block; }
.info-btn .tooltip strong { color: var(--c-text); font-weight: 400; }
.info-btn .tooltip .metric { margin-bottom: 6px; }
.info-btn .tooltip .metric:last-child { margin-bottom: 0; }

/* Bar chart — tool calls per app (primary metric) */
.bar-row { display: flex; align-items: center; padding: 8px 0; gap: 12px; }
.bar-label { font-size: 0.8rem; font-weight: 400; color: var(--c-text-secondary); min-width: 110px; text-align: right; flex-shrink: 0; }
.bar-wrap { flex: 1; height: 24px; background: var(--c-border); border-radius: 6px; overflow: hidden; position: relative; border: 1px solid var(--c-border); transition: border-color 0.2s; }
.bar-row:hover .bar-wrap { border-color: var(--c-border-hover); }
.bar { height: 100%; border-radius: 5px; transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94); position: relative; background: linear-gradient(90deg, var(--c-border) 0%, #818cf8 100%); }
.bar-inner { display: flex; align-items: center; height: 100%; padding: 0 10px; font-size: 0.65rem; font-weight: 400; color: rgba(255,255,255,0.85); letter-spacing: 0.02em; white-space: nowrap; }
.bar-value { font-size: 0.75rem; font-weight:400; color: var(--c-text); min-width: 70px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Cost treemap — simplified as horizontal bars per app (mobile-friendly) */
.cost-row { display: flex; align-items: center; padding: 6px 0; gap: 10px; }
.cost-label { font-size: 0.75rem; font-weight: 400; color: var(--c-text-secondary); min-width: 110px; text-align: right; flex-shrink: 0; }
.cost-bar-wrap { flex: 1; height: 18px; background: var(--c-border); border-radius: 4px; overflow: hidden; position: relative; }
.cost-bar { height: 100%; border-radius: 4px; transition: width 0.5s ease; background: linear-gradient(90deg, var(--c-border) 0%, var(--c-success) 100%); }
.cost-value { font-size: 0.75rem; font-weight:400; color: var(--c-text); min-width: 70px; text-align: right; flex-shrink: 0; }

/* Weekly sparkline grid — one row per app */
.spark-row { display: flex; align-items: center; padding: 6px 0; gap: 12px; border-bottom: 1px solid var(--c-border); }
.spark-row:last-child { border-bottom: none; }
.spark-name { font-size: 0.8rem; font-weight: 400; color: var(--c-text); min-width: 110px; flex-shrink: 0; }
.spark-canvas { flex: 1; height: 28px; background: var(--c-bg-card); border: 1px solid var(--c-border); border-radius: 4px; display: block; }
.spark-meta { font-size: 0.7rem; font-weight: 400; color: var(--c-text-secondary); min-width: 90px; text-align: right; flex-shrink: 0; white-space: nowrap; }

/* Recency grid — first/last touch per app */
.recency-row { display: flex; align-items: center; padding: 6px 0; gap: 12px; border-bottom: 1px solid var(--c-border); }
.recency-row:last-child { border-bottom: none; }
.recency-name { font-size: 0.8rem; font-weight: 400; color: var(--c-text); min-width: 110px; flex-shrink: 0; }
.recency-first { font-size: 0.7rem; font-weight: 400; color: var(--c-text-muted); min-width: 80px; text-align: center; flex-shrink: 0; }
.recency-last { font-size: 0.7rem; font-weight: 400; color: var(--c-text-secondary); min-width: 80px; text-align: center; flex-shrink: 0; }
.recency-30d { font-size: 0.65rem; font-weight: 400; color: #888; min-width: 90px; text-align: right; flex-shrink: 0; }
.recency-stale { color: var(--c-warning); } /* amber for stale */

/* Last-25-sessions ticker */
.activity-row { display: flex; align-items: center; padding: 6px 0; gap: 12px; border-bottom: 1px solid var(--c-border); }
.activity-row:last-child { border-bottom: none; }
.activity-title { font-size: 0.75rem; font-weight: 400; color: var(--c-text-secondary); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-app { font-size: 0.65rem; font-weight: 400; letter-spacing: 0.1em; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; flex-shrink: 0; }
.activity-app-watching { border: 1px solid rgba(74,222,128,0.25); background: rgba(74,222,128,0.08); color: var(--c-success); }
.activity-app-firelabs { border: 1px solid rgba(139,92,246,0.25); background: rgba(139,92,246,0.08); color: #8b5cf6; }
.activity-app-status { border: 1px solid rgba(96,165,250,0.25); background: rgba(96,165,250,0.08); color: #60a5fa; }
.activity-app-other { border: 1px solid rgba(150,150,150,0.25); background: rgba(150,150,150,0.08); color: var(--c-text-secondary); }
.activity-tools { font-size: 0.7rem; font-weight: 400; color: var(--c-text-muted); min-width: 40px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.activity-date { font-size: 0.7rem; font-weight: 400; color: var(--c-text-dim); min-width: 110px; text-align: right; flex-shrink: 0; white-space: nowrap; }

/* Uncategorized drilldown */
.uncat-row { display: flex; align-items: center; padding: 6px 0; gap: 12px; border-bottom: 1px solid var(--c-border); font-size: 0.75rem; }
.uncat-row:last-child { border-bottom: none; }
.uncat-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #888; }
.uncat-count { font-weight: 400; color: var(--c-text-muted); min-width: 40px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.uncat-usd { font-weight: 400; color: #888; min-width: 60px; text-align: right; flex-shrink: 0; }

/* Totals overview cards */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.overview-card { background: var(--c-bg-card); border: 1px solid var(--c-border); border-radius: 16px; padding: 20px; transition: border-color 0.2s; }
.overview-card:hover { border-color: var(--c-border-hover); }
.overview-card .label { font-size: 0.75rem; font-weight: 400; color: var(--c-text-secondary); letter-spacing: 0.04em; margin-bottom: 8px; }
.overview-card .value { font-size: 1.5rem; font-weight:400; color: var(--c-text); letter-spacing: 0.02em; }
.overview-card .sub { font-size: 0.7rem; font-weight:400; color: var(--c-text-secondary); margin-top: 4px; }

/* Loading + animations */
.loading { opacity: 0.4; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.7; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile */
@media (max-width: 600px) {
  .page-wrap { padding-left: 16px; padding-right: 16px; }
  .bar-label, .cost-label, .spark-name, .recency-name { min-width: 80px; font-size: 0.7rem; }
  .bar-value, .cost-value, .spark-meta { min-width: 60px; font-size: 0.7rem; }
  .recency-first, .recency-last { min-width: 70px; font-size: 0.65rem; }
  .recency-30d { min-width: 80px; font-size: 0.6rem; }
  .activity-title { font-size: 0.7rem; }
  .activity-date { min-width: 90px; font-size: 0.65rem; }
  .activity-app { font-size: 0.6rem; padding: 1px 6px; }
  .uncat-title { font-size: 0.7rem; }
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .me-period-tab { padding: 8px 12px; font-size: 0.78rem; }
  .me-outcome-row, .me-time-row { min-width: 460px; }
  .me-block-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
}

/* ── Model Errors & Recovery section ── */
.me-section { margin-bottom: 32px; padding: 20px; background: var(--c-bg-elevated); border: 1px solid var(--c-border); border-radius: 16px; }
.me-section h2 { font-size: 0.95rem; font-weight: 400; letter-spacing: 0.06em; margin-bottom: 4px; color: var(--c-text); }
.me-section .subtitle { font-size: 0.7rem; color: var(--c-text-secondary); margin-bottom: 14px; line-height: 1.5; }

.me-period-tabs { display: flex; gap: 0; margin-bottom: 18px; border-bottom: 1px solid var(--c-border); flex-wrap: wrap; }
.me-period-tab { font-size: 0.8rem; font-weight: 400; letter-spacing: 0.04em; color: var(--c-text-secondary); background: none; border: none; cursor: pointer; padding: 8px 16px; border-bottom: 2px solid transparent; transition: color 0.2s, border-color 0.2s; }
.me-period-tab:hover { color: #ccc; }
.me-period-tab.active { color: var(--c-text); border-bottom-color: var(--c-error); }

.me-totals-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 18px; }
.me-totals-row .me-tot-cell { background: var(--c-bg-card); border: 1px solid var(--c-border); border-radius: 10px; padding: 10px 12px; }
.me-totals-row .me-tot-cell .lbl { font-size: 0.6rem; font-weight: 400; letter-spacing: 0.1em; color: var(--c-text-secondary); text-transform: uppercase; margin-bottom: 3px; }
.me-totals-row .me-tot-cell .val { font-size: 1.05rem; font-weight: 400; color: var(--c-text); font-variant-numeric: tabular-nums; }
.me-totals-row .me-tot-cell .val.switch { color: var(--c-warning); }
.me-totals-row .me-tot-cell .val.stayed { color: var(--c-success); }
.me-totals-row .me-tot-cell .val.unresolved { color: var(--c-error); }

.me-block { margin-bottom: 22px; }
.me-block:last-child { margin-bottom: 0; }
.me-block-title { font-size: 0.62rem; font-weight: 400; letter-spacing: 0.2em; color: #888; text-transform: uppercase; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

/* Error types */
.me-type-row { display: flex; align-items: center; padding: 6px 0; gap: 12px; border-bottom: 1px solid var(--c-border); }
.me-type-row:last-child { border-bottom: none; }
.me-type-cat { font-size: 0.78rem; font-weight: 400; color: var(--c-text); min-width: 230px; flex-shrink: 0; }
.me-type-bar-wrap { flex: 1; height: 14px; background: var(--c-border); border-radius: 4px; overflow: hidden; }
.me-type-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #3a1a1a 0%, var(--c-error) 100%); transition: width 0.5s ease; }
.me-type-count { font-size: 0.78rem; font-weight: 400; color: var(--c-text-secondary); min-width: 40px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Per-model breakdown */
.me-model-row { display: flex; align-items: center; padding: 10px 0; gap: 14px; border-bottom: 1px solid var(--c-border); }
.me-model-row:last-child { border-bottom: none; }
.me-model-name { font-size: 0.82rem; font-weight: 400; color: var(--c-text); min-width: 240px; flex-shrink: 0; font-family: monospace; }
.me-model-errs { font-size: 0.8rem; font-weight: 400; color: var(--c-error); min-width: 60px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.me-model-types { font-size: 0.65rem; font-weight: 400; color: var(--c-text-muted); min-width: 100px; flex-shrink: 0; }
.me-model-gap { font-size: 0.75rem; font-weight: 400; color: var(--c-text-secondary); min-width: 80px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.me-model-window { font-size: 0.62rem; font-weight: 400; color: var(--c-text-dim); min-width: 110px; text-align: right; flex-shrink: 0; }

/* Recovery outcomes */
.me-outcome-row { display: flex; align-items: center; padding: 7px 0; gap: 10px; border-bottom: 1px solid var(--c-border); font-size: 0.74rem; }
.me-outcome-row:last-child { border-bottom: none; }
.me-outcome-badge { font-size: 0.6rem; font-weight: 400; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; flex-shrink: 0; min-width: 80px; text-align: center; }
.me-badge-stayed { border: 1px solid rgba(74,222,128,0.25); background: rgba(74,222,128,0.08); color: var(--c-success); }
.me-badge-switched { border: 1px solid rgba(251,191,36,0.25); background: rgba(251,191,36,0.08); color: var(--c-warning); }
.me-badge-unresolved { border: 1px solid rgba(248,113,113,0.25); background: rgba(248,113,113,0.08); color: var(--c-error); }
.me-outcome-start { font-family: monospace; color: var(--c-text); min-width: 200px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-outcome-arrow { color: var(--c-text-dim); font-size: 0.8rem; flex-shrink: 0; }
.me-outcome-end { font-family: monospace; color: var(--c-warning); min-width: 200px; flex-shrink: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-outcome-end.stayed { color: var(--c-success); }
.me-outcome-attempts { color: var(--c-text-secondary); min-width: 50px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.me-outcome-wall { color: var(--c-text-secondary); min-width: 80px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.me-outcome-session { color: var(--c-text-faint); min-width: 180px; text-align: right; flex-shrink: 0; font-family: monospace; font-size: 0.62rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Time per model */
.me-time-row { display: flex; align-items: center; padding: 6px 0; gap: 12px; border-bottom: 1px solid var(--c-border); }
.me-time-row:last-child { border-bottom: none; }
.me-time-name { font-family: monospace; font-size: 0.78rem; font-weight: 400; color: var(--c-text); min-width: 240px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-time-bar-wrap { flex: 1; height: 18px; background: var(--c-border); border-radius: 4px; overflow: hidden; }
.me-time-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #2a2a3a 0%, #818cf8 100%); transition: width 0.5s ease; }
.me-time-share { font-size: 0.65rem; font-weight: 400; color: var(--c-text-secondary); min-width: 50px; flex-shrink: 0; font-variant-numeric: tabular-nums; text-align: right; }
.me-time-min { font-size: 0.78rem; font-weight: 400; color: var(--c-text); min-width: 80px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Error sparkline */
.me-spark-svg { width: 100%; height: 60px; background: var(--c-bg-card); border: 1px solid var(--c-border); border-radius: 6px; display: block; }

/* Watcher pill */
.me-watcher-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: rgba(139,92,246,0.08); border: 1px solid rgba(139,92,246,0.2); color: #a78bfa; font-size: 0.66rem; font-weight: 400; letter-spacing: 0.04em; margin-left: 4px; }
.me-watcher-pill a { color: #a78bfa; text-decoration: underline; }

/* Grok footnote */
.me-grok-footnote { font-size: 0.65rem; color: var(--c-text-muted); margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--c-border); line-height: 1.55; }
.me-grok-footnote strong { color: #888; font-weight: 400; }

/* Empty state */
.me-empty { color: var(--c-text-dim); font-size: 0.78rem; padding: 12px 0; font-style: italic; }

/* Failed state */
.me-failed { color: var(--c-error); font-size: 0.78rem; padding: 12px 0; }
