/* Admin → Analytics (#/admin/analytics). Uses base.css tokens only, so every theme applies. */
.an-page {
  --an-good: #1f9d55; --an-warn: var(--orange); --an-bad: #e03131;
  --an-bar: var(--accent); --an-track: color-mix(in srgb, var(--accent) 12%, transparent);
}
.an-page h3 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.an-page h4 { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
.an-h { font-size: 17px; margin: 22px 2px 10px; }
.an-sub, .an-foot { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: -4px 0 10px; }
.an-foot { margin: 10px 0 0; }
.an-privacy { text-align: center; margin: 4px 0 24px; }
.an-none { color: var(--muted); font-size: 14px; margin: 6px 0; }
.an-note { font-size: 13px; color: var(--text-2); margin: 0 2px 12px; }

/* range tabs */
.an-seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 999px; background: var(--surface-2); }
.an-seg button { flex: 1; height: 34px; border: 0; border-radius: 999px; background: none; color: var(--text-2); font: inherit; font-size: 14px; cursor: pointer; }
.an-seg button.is-active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }

/* online now */
.an-live-head { display: flex; align-items: baseline; gap: 8px; }
.an-live-head b { font-size: 28px; font-weight: 600; line-height: 1; }
.an-live-head span:last-child { color: var(--text-2); font-size: 14px; }
.an-pulse { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--an-good); align-self: center; flex-shrink: 0; }
.an-pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--an-good); opacity: 0; animation: an-pulse 2s ease-out infinite; }
.an-pulse.is-idle { background: var(--muted); }
.an-pulse.is-idle::after { display: none; }
@keyframes an-pulse { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .an-pulse::after { animation: none; } }
.an-doing { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.an-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-chip b { color: var(--text); font-weight: 600; }

/* KPI tiles */
.an-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .an-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.an-kpi { margin: 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.an-kpi-label { font-size: 12.5px; color: var(--text-2); }
.an-kpi-value { font-size: 24px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-kpi-sub { font-size: 12px; color: var(--muted); line-height: 1.35; }
.an-delta { font-weight: 600; margin-right: 2px; }
.an-delta.up { color: var(--an-good); }
.an-delta.down { color: var(--an-bad); }

/* trend chart */
.an-trend-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.an-trend-head h3 { margin: 0; }
.an-metrics { display: flex; flex-wrap: wrap; gap: 4px; }
.an-metrics button { height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: none; color: var(--text-2); font: inherit; font-size: 12.5px; cursor: pointer; }
.an-metrics button.is-active { border-color: transparent; background: var(--accent-soft); color: var(--accent-light); font-weight: 600; }
.an-chart { position: relative; padding-left: 40px; }
.an-plot { position: relative; height: 180px; }
.an-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); }
.an-grid span { position: absolute; right: calc(100% + 6px); top: -7px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.an-col { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; outline: none; }
.an-bar { display: block; width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; background: var(--an-bar); transition: opacity .15s; }
.an-col.is-muted .an-bar { background: var(--muted); opacity: .35; }
.an-cols:hover .an-col:not(.is-on) .an-bar, .an-cols:has(.is-on) .an-col:not(.is-on) .an-bar { opacity: .45; }
.an-col:focus-visible .an-bar { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.an-xaxis { display: flex; gap: 2px; margin-top: 6px; }
.an-xaxis span { flex: 1; min-width: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: visible; text-align: left; }
.an-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); z-index: 2; display: flex; flex-direction: column; align-items: center;
  padding: 6px 10px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 12px; white-space: nowrap; pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.an-tip b { font-size: 14px; }
.an-trend { padding-top: 14px; }
.an-trend .an-chart { margin-top: 30px; }

/* top manga */
.an-top-list { list-style: none; margin: 0; padding: 0; }
.an-top-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.an-top-list li:last-child { border-bottom: 0; }
.an-rank { width: 20px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.an-cover { width: 34px; height: 48px; border-radius: 5px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.an-top-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.an-top-title { color: var(--text); font-size: 15px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-top-sub { font-size: 12px; color: var(--muted); }
.an-top-n { display: flex; flex-direction: column; align-items: flex-end; font-size: 17px; font-weight: 600; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.an-top-n small { font-size: 11px; font-weight: 400; color: var(--muted); }
.an-track { height: 6px; border-radius: 999px; background: var(--an-track); overflow: hidden; }
.an-track span { display: block; height: 100%; border-radius: 999px; background: var(--an-bar); }

/* uptime */
.an-status { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.an-status > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.an-status b { font-size: 14.5px; font-weight: 600; }
.an-status small { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.an-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.an-state { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.an-status.is-ok .an-dot { background: var(--an-good); }
.an-status.is-ok .an-state { color: var(--an-good); background: color-mix(in srgb, var(--an-good) 12%, transparent); }
.an-status.is-warn .an-dot { background: var(--an-warn); }
.an-status.is-warn .an-state { color: var(--an-warn); background: color-mix(in srgb, var(--an-warn) 14%, transparent); }
.an-status.is-bad .an-dot { background: var(--an-bad); }
.an-status.is-bad .an-state { color: var(--an-bad); background: color-mix(in srgb, var(--an-bad) 12%, transparent); }
.an-strip-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); margin: 16px 0 6px; }
.an-strip { display: flex; gap: 2px; height: 34px; }
.an-day { flex: 1; min-width: 0; border-radius: 2px; background: var(--surface-2); }
.an-day.is-ok { background: var(--an-good); }
.an-day.is-warn { background: var(--an-warn); }
.an-day.is-bad { background: var(--an-bad); }
.an-day:hover { opacity: .7; }
.an-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.an-legend span { display: inline-flex; align-items: center; gap: 5px; }
.an-legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--surface-2); }
.an-legend i.is-ok { background: var(--an-good); }
.an-legend i.is-warn { background: var(--an-warn); }
.an-legend i.is-bad { background: var(--an-bad); }
.an-incidents { display: flex; flex-direction: column; }
.an-inc { display: flex; flex-direction: column; gap: 1px; padding: 8px 0 8px 12px; border-left: 3px solid var(--an-warn); margin-bottom: 6px; }
.an-inc.is-open { border-left-color: var(--an-bad); }
.an-inc b { font-size: 14px; }
.an-inc span { font-size: 13px; color: var(--text-2); }
.an-inc small { font-size: 12px; color: var(--muted); }

/* audience */
.an-shares { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .an-shares { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.an-share { margin: 0; }
.an-share-row { margin-bottom: 9px; }
.an-share-row:last-child { margin-bottom: 0; }
.an-share-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; margin-bottom: 4px; }
.an-share-k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-share-v { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-share-v small { font-weight: 400; color: var(--muted); }

/* traffic */
.an-cells { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .an-cells { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.an-cells div { display: flex; flex-direction: column; }
.an-cells b { font-size: 18px; font-weight: 600; }
.an-cells span { font-size: 12.5px; color: var(--muted); }

/* admin home: links above the analytics */
.adm-home-links { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .adm-home-links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.adm-home-links .mbr-link { margin: 0; }
.an-page .adm-foot { margin-bottom: 24px; }
