/* cc-analytics dashboard — clean editorial admin aesthetic (olive accent, Fraunces + Inter Tight). */
:root {
  --bg: #f5f5f1;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --ink: #20251f;
  --ink-soft: #4a4f47;
  --muted: #868b80;
  --border: #e6e5de;
  --border-strong: #d6d5cc;
  --accent: #59683c;
  --accent-hover: #485530;
  --accent-soft: #eef0e6;
  --danger: #a13a2f;
  --good: #4f7a3f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(32, 37, 31, .05), 0 1px 3px rgba(32, 37, 31, .04);
  --shadow-md: 0 4px 16px rgba(32, 37, 31, .08), 0 1px 4px rgba(32, 37, 31, .05);
  --shadow-lg: 0 24px 60px rgba(32, 37, 31, .22);
  --ui: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button { font-family: inherit; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .14s, border-color .14s, transform .04s, box-shadow .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(32,37,31,.05); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }

/* ── top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  height: 60px; padding: 0 24px;
  background: rgba(245,245,241,.82); backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.wordmark { display: flex; align-items: baseline; gap: 9px; }
.wordmark .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }
.wordmark h1 { font-family: var(--serif); font-weight: 500; font-size: 19px; margin: 0; letter-spacing: -.01em; }
.wordmark .sub { color: var(--muted); font-size: 12px; }
.topbar .spacer { flex: 1; }

/* ── layout ──────────────────────────────────────────────────────────────── */
.container { max-width: 1120px; margin: 0 auto; padding: 26px 24px 80px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 600; color: var(--muted); }

/* ── stat cards ──────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin: 18px 0 26px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat .value { font-family: var(--serif); font-size: 30px; font-weight: 500; margin-top: 4px; letter-spacing: -.02em; }
.stat .value small { font-size: 16px; color: var(--ink-soft); }

/* ── filters ─────────────────────────────────────────────────────────────── */
.filters { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-soft);
  height: 28px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.search {
  height: 34px; padding: 0 12px; min-width: 200px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 13px; color: var(--ink); outline: none; transition: border-color .12s, box-shadow .12s;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filters .spacer { flex: 1; }

/* ── sessions list ───────────────────────────────────────────────────────── */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.row {
  display: grid; grid-template-columns: 44px 1.4fr 1fr 90px 88px 70px 96px; align-items: center;
  gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.head { cursor: default; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.row.head:hover { background: var(--surface-2); }
.row.head > div { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.devicewrap { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.path { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path .arrow { color: var(--muted); margin: 0 6px; }
.subtle { color: var(--muted); font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--ink-soft); font-weight: 500;
}
.play {
  display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 12.5px;
  opacity: .55; transition: opacity .12s;
}
.row:hover .play { opacity: 1; }

/* ── skeleton / states ───────────────────────────────────────────────────── */
.skel { background: linear-gradient(90deg, #ecebe5 25%, #f3f2ed 37%, #ecebe5 63%); background-size: 400% 100%; animation: sh 1.3s ease infinite; border-radius: 6px; height: 12px; }
@keyframes sh { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.empty, .error { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty .big, .error .big { font-family: var(--serif); font-size: 22px; color: var(--ink); margin-bottom: 8px; }
.error .big { color: var(--danger); }
.center-pad { padding: 14px 18px; }

/* ── login ───────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); padding: 30px 28px; }
.login-card .wordmark { justify-content: center; margin-bottom: 6px; }
.login-card p { color: var(--muted); text-align: center; margin: 0 0 20px; font-size: 13px; }
.field { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 15px; outline: none; transition: border-color .12s, box-shadow .12s; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { width: 100%; justify-content: center; height: 42px; margin-top: 12px; }
.login-err { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; min-height: 16px; }

/* ── replay modal ────────────────────────────────────────────────────────── */
.backdrop { position: fixed; inset: 0; background: rgba(24,27,22,.5); backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: center; padding: 28px; animation: fade .14s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(1180px, 96vw); max-height: 92vh; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: pop .16s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head .meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--ink-soft); font-size: 13px; }
.modal-head .meta b { color: var(--ink); font-weight: 600; }
.modal-head .spacer { flex: 1; }
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.crumb { font-size: 12px; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.crumb .i { color: var(--muted); margin-right: 5px; }
.player-wrap { flex: 1; min-height: 0; overflow: auto; background: #eceae3; display: grid; place-items: center; padding: 18px; }
.player-loading { display: grid; place-items: center; height: 420px; width: 100%; color: var(--muted); gap: 14px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* rrweb-player chrome tweaks to match the admin look */
.rr-player { box-shadow: var(--shadow-md) !important; border-radius: 10px !important; overflow: hidden; }
.rr-controller { background: var(--surface) !important; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 38px 1.3fr 70px 70px; }
  .row .col-hide { display: none; }
}

/* ── heatmaps view ─────────────────────────────────────────────────────────── */
.viewseg button { min-width: 78px; justify-content: center; }
.muted2 { color: var(--muted); font-size: 12px; }
.pagepill {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft);
  height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.pagepill:hover { border-color: var(--muted); }
.pagepill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pagepill .muted2 { margin-left: 4px; }

.hm-grid { display: grid; grid-template-columns: 420px 1fr; gap: 22px; align-items: start; }
.hm-left { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.hm-canvas { width: 100%; max-width: 380px; height: auto; border-radius: 8px; border: 1px solid var(--border); display: block; margin: 10px auto 0; background: #fbfbf9; }
.hm-cap { text-align: center; margin-top: 10px; }
.hm-right { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }

.el-list { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.el-row { display: grid; grid-template-columns: 1fr 90px 70px; align-items: center; gap: 10px; }
.el-sel { font-size: 11.5px; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Menlo, Consolas, monospace; }
.el-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.el-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.el-cnt { text-align: right; font-size: 13px; color: var(--ink); }
.rage { color: var(--danger); margin-left: 5px; font-size: 11px; }

.scrolldepth { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.sd-row { display: grid; grid-template-columns: 40px 1fr 44px; align-items: center; gap: 10px; }
.sd-label { color: var(--muted); }
.sd-bar { height: 14px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.sd-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #8a9a5b); border-radius: 5px; transition: width .3s; }
.sd-pct { text-align: right; font-size: 12px; color: var(--ink-soft); }

@media (max-width: 860px) { .hm-grid { grid-template-columns: 1fr; } }

/* ── visitor tags (location / returning / revenue) ─────────────────────────── */
.ret { color: var(--accent); font-weight: 600; }
.vtag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--ink-soft); }
.vtag.ret { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.vtag.rev { background: #fdf3e6; border-color: #e7c98f; color: #9a6a1a; font-weight: 600; }
.vtag.cust { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ── products view ─────────────────────────────────────────────────────────── */
.row.phead { grid-template-columns: 56px 1fr 80px 80px; }
.prow { display: grid; grid-template-columns: 56px 1fr 80px 80px; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.prow:last-child { border-bottom: 0; }
.pthumb { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pthumb .noimg { font-size: 18px; opacity: .5; }
.pinfo { min-width: 0; }
.ptitle { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pprice { color: var(--accent); font-weight: 600; font-size: 12.5px; }
.pbar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.pbar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.pviews { text-align: right; font-size: 14px; }
@media (max-width: 760px) {
  .row.phead, .prow { grid-template-columns: 48px 1fr 64px; }
  .prow .col-hide, .row.phead .col-hide { display: none; }
}
