:root {
  --paper: #f3f0e8;
  --paper-2: #ebe7dc;
  --surface: #faf8f2;
  --surface-strong: #fffdf8;
  --ink: #17201f;
  --ink-2: #35413f;
  --muted: #6e7975;
  --faint: #9aa29d;
  --green: #123d3b;
  --green-2: #23615d;
  --green-3: #82a7a0;
  --cinnabar: #a44d3d;
  --gold: #b88a42;
  --line: rgba(23, 32, 31, .12);
  --line-strong: rgba(23, 32, 31, .22);
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 8%, rgba(130, 167, 160, .12), transparent 26rem),
    linear-gradient(90deg, rgba(18, 61, 59, .024) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 48px 100%, auto;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 3px; }
.skip { position: fixed; left: 18px; top: -60px; z-index: 20; padding: 10px 14px; background: var(--surface-strong); border: 1px solid var(--line); }
.skip:focus { top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.admin-app { min-height: 100dvh; }
.admin-rail {
  min-height: 76px;
  padding: 0 max(28px, calc((100vw - 1380px) / 2));
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 28px;
  color: rgba(255, 255, 255, .72);
  background: var(--green);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.admin-brand { display: inline-flex; align-items: center; gap: 12px; justify-self: start; }
.admin-brand > span:first-child {
  width: 38px; height: 38px; display: grid; place-items: center;
  color: var(--green); background: #e7e1d4; font-family: var(--serif); font-size: 23px;
}
.admin-brand > span:last-child { display: grid; line-height: 1.25; }
.admin-brand b { color: white; font-family: var(--serif); font-size: 17px; font-weight: 500; letter-spacing: .12em; }
.admin-brand small { margin-top: 2px; font-size: 9px; letter-spacing: .2em; }
.admin-nav { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.admin-nav > * { min-height: 36px; padding: 8px 12px; display: inline-flex; align-items: center; }
.admin-nav a { transition: color .18s ease, background .18s ease; }
.admin-nav a:hover { color: white; background: rgba(255,255,255,.07); }
.nav-current { color: white; box-shadow: inset 0 -2px 0 #d2b174; }
.admin-account { display: flex; justify-content: flex-end; align-items: center; gap: 14px; font-size: 11px; }
#admin-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .72; }
#admin-refresh {
  min-height: 36px; padding: 8px 12px; color: white;
  border: 1px solid rgba(255,255,255,.2); transition: background .18s ease, border-color .18s ease;
}
#admin-refresh:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.4); }
#admin-refresh:active { transform: translateY(1px); }
#admin-refresh i { display: inline-block; margin-right: 4px; font-style: normal; }
#admin-refresh.is-loading i { animation: spin .8s linear infinite; }

.admin-main { width: min(1320px, calc(100% - 64px)); margin: 0 auto; padding: 70px 0 44px; }
.overview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 48px; margin-bottom: 42px; }
.eyebrow, .panel-head p {
  margin: 0 0 8px; color: var(--green-2); font-family: var(--mono); font-size: 9px; letter-spacing: .18em;
}
.overview-head h1 { margin: 0; font-family: var(--serif); font-size: clamp(42px, 6vw, 74px); font-weight: 400; line-height: 1.08; letter-spacing: -.045em; }
.overview-copy { max-width: 42em; margin: 18px 0 0; color: var(--muted); font-size: 14px; text-wrap: pretty; }
.overview-controls { display: grid; justify-items: end; gap: 13px; padding-bottom: 4px; }
.freshness { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #4f8e66; box-shadow: 0 0 0 4px rgba(79,142,102,.1); }
.period { display: inline-flex; gap: 0; border: 1px solid var(--line-strong); background: rgba(255,255,255,.35); }
.period button { min-width: 62px; min-height: 38px; padding: 8px 14px; color: var(--muted); font-size: 11px; transition: color .18s ease, background .18s ease; }
.period button + button { border-left: 1px solid var(--line); }
.period button:hover { color: var(--ink); }
.period button[aria-pressed="true"] { color: #fff; background: var(--green); }

.metrics {
  display: grid; grid-template-columns: 1.5fr repeat(4, 1fr);
  margin-bottom: 22px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
.metric { min-width: 0; padding: 26px 22px 24px; position: relative; }
.metric:first-child { padding-left: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric-label { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.metric strong { display: block; margin-top: 8px; font-family: var(--serif); font-size: clamp(28px, 3vw, 42px); font-weight: 400; line-height: 1.05; font-variant-numeric: tabular-nums; }
.metric:first-child strong { font-size: clamp(40px, 5vw, 64px); letter-spacing: -.04em; }
.metric small { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-delta { color: var(--green-2); font-family: var(--mono); font-size: 9px; letter-spacing: 0; }
.metric-delta.is-down { color: var(--cinnabar); }
.metric-delta.is-flat { color: var(--faint); }

.dashboard-grid { display: grid; gap: 22px; }
.dashboard-grid-primary { grid-template-columns: minmax(0, 1.45fr) minmax(340px, .75fr); }
.dashboard-grid-secondary { grid-template-columns: .72fr .9fr 1.38fr; align-items: start; }
.panel { min-width: 0; background: rgba(255,253,248,.72); border: 1px solid var(--line); }
.panel-head { min-height: 76px; padding: 20px 22px 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 400; line-height: 1.25; }
.panel-note { color: var(--faint); font-family: var(--mono); font-size: 9px; white-space: nowrap; }

.chart { min-height: 318px; padding: 18px 14px 4px 6px; overflow: hidden; }
.chart svg { width: 100%; height: 294px; display: block; overflow: visible; }
.chart .grid { stroke: rgba(23,32,31,.08); stroke-width: 1; }
.chart .axis-label { fill: var(--faint); font: 9px var(--mono); }
.chart .line-visitors, .chart .line-engaged { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.chart .line-visitors { stroke: var(--green); stroke-width: 2.2; }
.chart .line-engaged { stroke: var(--gold); stroke-width: 1.6; }
.chart .area-visitors { fill: rgba(35,97,93,.09); }
.chart .dot { fill: var(--surface-strong); stroke: var(--green); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart-empty, .empty-copy { min-height: 180px; display: grid; place-items: center; color: var(--faint); font-family: var(--serif); }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 9px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 14px; height: 2px; display: inline-block; }
.legend-visitors { background: var(--green); }
.legend-engaged { background: var(--gold); }

.funnel { padding: 21px 22px 24px; display: grid; gap: 18px; }
.funnel-row { display: grid; gap: 8px; }
.funnel-meta { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: baseline; }
.funnel-label { color: var(--ink-2); font-size: 11px; }
.funnel-value { font-family: var(--mono); font-size: 10px; font-variant-numeric: tabular-nums; }
.funnel-track { height: 7px; overflow: hidden; background: var(--paper-2); }
.funnel-fill { height: 100%; min-width: 2px; background: var(--green-2); transform-origin: left; animation: reveal .55s cubic-bezier(.22,.8,.2,1) both; }
.funnel-row:nth-child(3) .funnel-fill, .funnel-row:nth-child(4) .funnel-fill { background: var(--gold); }
.funnel-row:last-child .funnel-fill { background: var(--cinnabar); }
.funnel-step { color: var(--faint); font-size: 9px; }

.insight-strip {
  margin: 22px 0; padding: 27px 28px;
  display: grid; grid-template-columns: 260px 1fr; gap: 34px;
  color: #eef4ef; background: var(--green);
}
.insight-strip header p { margin: 0 0 6px; color: #d4b577; font-family: var(--mono); font-size: 9px; letter-spacing: .15em; }
.insight-strip h2 { margin: 0; max-width: 12em; font-family: var(--serif); font-size: 21px; font-weight: 400; line-height: 1.45; }
.insights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.insight { padding-left: 16px; border-left: 1px solid rgba(255,255,255,.2); }
.insight b { display: block; color: #d4b577; font-family: var(--mono); font-size: 9px; font-weight: 400; letter-spacing: .12em; }
.insight p { margin: 7px 0 0; color: rgba(255,255,255,.76); font-size: 11px; line-height: 1.75; }

.bars { padding: 20px 22px 24px; display: grid; gap: 15px; }
.bar-row { display: grid; grid-template-columns: 62px minmax(40px,1fr) 54px; gap: 10px; align-items: center; color: var(--muted); font-size: 10px; }
.bar-track { height: 5px; background: var(--paper-2); }
.bar-fill { height: 100%; background: var(--green-2); animation: reveal .5s ease-out both; }
.bar-num { text-align: right; font-family: var(--mono); font-size: 9px; }
.bar-num small { color: var(--faint); }
.source-list { padding: 10px 22px 17px; }
.source-row { padding: 11px 0; display: grid; grid-template-columns: 24px minmax(0,1fr) auto; gap: 9px; align-items: center; border-bottom: 1px solid var(--line); }
.source-row:last-child { border-bottom: 0; }
.source-rank { color: var(--faint); font-family: var(--mono); font-size: 9px; }
.source-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: 10px; }
.source-value { font-family: var(--mono); font-size: 9px; }
.table-wrap { overflow-x: auto; }
.path-list { width: 100%; border-collapse: collapse; table-layout: fixed; }
.path-list th, .path-list td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); font-size: 10px; }
.path-list th { color: var(--faint); font-size: 9px; font-weight: 400; letter-spacing: .08em; }
.path-list th:first-child, .path-list td:first-child { width: 64%; padding-left: 22px; }
.path-list th:not(:first-child), .path-list td:not(:first-child) { text-align: right; }
.path-list td:first-child { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path-list td:not(:first-child) { font-family: var(--mono); font-size: 9px; font-variant-numeric: tabular-nums; }
.path-list tr:last-child td { border-bottom: 0; }

.panel-users { margin-top: 22px; }
.users-head { align-items: center; }
.user-search input {
  width: min(260px, 34vw); min-height: 38px; padding: 8px 12px;
  color: var(--ink); background: var(--surface-strong); border: 1px solid var(--line-strong);
  border-radius: 0; font: 11px var(--sans); outline: 0;
}
.user-search input::placeholder { color: var(--faint); }
.user-search input:focus-visible { border-color: var(--green-2); box-shadow: 0 0 0 2px rgba(35,97,93,.14); }
.user-list { width: 100%; min-width: 860px; border-collapse: collapse; table-layout: fixed; }
.user-list th, .user-list td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); font-size: 10px; }
.user-list th { color: var(--faint); font-size: 9px; font-weight: 400; letter-spacing: .08em; }
.user-list th:first-child, .user-list td:first-child { width: 28%; padding-left: 22px; }
.user-list th:nth-child(2), .user-list td:nth-child(2),
.user-list th:last-child, .user-list td:last-child { width: 17%; }
.user-list th:nth-child(n+4), .user-list td:nth-child(n+4) { text-align: right; }
.user-list tr:last-child td { border-bottom: 0; }
.user-list td:not(:first-child) { color: var(--muted); font-family: var(--mono); font-size: 9px; font-variant-numeric: tabular-nums; }
.user-email { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; color: var(--green-2); border-bottom: 1px solid transparent; }
.user-email:hover { border-bottom-color: currentColor; }
.account-state { color: var(--cinnabar); }
.account-state.is-verified { color: var(--green-2); }
.users-empty { padding-block: 38px !important; text-align: center !important; color: var(--faint) !important; font-family: var(--serif) !important; font-size: 12px !important; }
.users-note { margin: 0; padding: 12px 22px; color: var(--faint); border-top: 1px solid var(--line); font-size: 9px; }

.admin-foot { margin-top: 30px; padding-top: 18px; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); color: var(--faint); font-size: 9px; }
.admin-foot p { margin: 0; }
.admin-state { min-height: 62vh; display: grid; place-items: center; align-content: center; text-align: center; }
.admin-state p { margin: 18px 0 0; font-family: var(--serif); font-size: 20px; }
.admin-state small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.admin-state a { color: var(--green-2); border-bottom: 1px solid currentColor; }
.state-orbit { width: 34px; height: 34px; border: 1px solid var(--line-strong); border-top-color: var(--green); border-radius: 50%; animation: spin .9s linear infinite; }
.admin-state.is-error .state-orbit { display: none; }
.admin-state.is-error p { color: var(--cinnabar); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes reveal { from { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

@media (max-width: 1060px) {
  .admin-rail { grid-template-columns: 1fr auto; padding-inline: 24px; }
  .admin-nav { display: none; }
  .metrics { grid-template-columns: 1.3fr repeat(2, 1fr); }
  .metric:nth-child(4) { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .metric:nth-child(4), .metric:nth-child(5) { border-top: 1px solid var(--line); }
  .dashboard-grid-primary { grid-template-columns: 1fr; }
  .dashboard-grid-secondary { grid-template-columns: 1fr 1fr; }
  .panel-paths { grid-column: 1 / -1; }
  .insight-strip { grid-template-columns: 210px 1fr; }
}

@media (max-width: 720px) {
  body { background-size: auto, 32px 100%, auto; }
  .admin-rail { min-height: 64px; grid-template-columns: 1fr auto; gap: 12px; padding-inline: 16px; }
  .admin-brand > span:first-child { width: 34px; height: 34px; }
  .admin-brand small, #admin-email { display: none; }
  #admin-refresh { min-height: 40px; padding-inline: 10px; font-size: 10px; }
  .admin-main { width: calc(100% - 32px); padding-top: 45px; }
  .overview-head { align-items: flex-start; flex-direction: column; gap: 25px; margin-bottom: 31px; }
  .overview-head h1 { font-size: 45px; }
  .overview-copy { font-size: 12px; }
  .overview-controls { width: 100%; justify-items: stretch; }
  .freshness { justify-self: start; }
  .period { display: grid; grid-template-columns: repeat(3, 1fr); }
  .period button { min-width: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric, .metric:first-child { padding: 20px 14px; }
  .metric:first-child { grid-column: 1 / -1; }
  .metric:nth-child(2), .metric:nth-child(4) { border-left: 0; }
  .metric:nth-child(n+2) { border-top: 1px solid var(--line); }
  .metric:first-child strong { font-size: 50px; }
  .metric strong { font-size: 30px; }
  .dashboard-grid, .dashboard-grid-secondary { grid-template-columns: 1fr; }
  .panel-paths { grid-column: auto; }
  .panel-head { min-height: 70px; padding: 18px 16px 14px; }
  .chart { min-height: 260px; padding-inline: 2px; }
  .chart svg { height: 245px; }
  .funnel, .bars { padding-inline: 16px; }
  .insight-strip { grid-template-columns: 1fr; gap: 24px; padding: 24px 20px; }
  .insight-strip h2 { max-width: 18em; }
  .insights { grid-template-columns: 1fr; gap: 16px; }
  .source-list { padding-inline: 16px; }
  .path-list { min-width: 430px; }
  .users-head { align-items: flex-start; flex-direction: column; }
  .user-search, .user-search input { width: 100%; }
  .admin-foot { align-items: flex-start; flex-direction: column; }
}
