/* TikTokScope — shadcn/ui-style design system (vanilla, no build step) */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --radius: 0.625rem;
  --chart-1: oklch(0.646 0.222 41.116);
  --chart-2: oklch(0.6 0.118 184.704);
  --chart-3: oklch(0.398 0.07 227.392);
  --chart-4: oklch(0.828 0.189 84.429);
  --chart-5: oklch(0.769 0.188 70.08);
}
.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.205 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --chart-1: oklch(0.488 0.243 264.376);
  --chart-2: oklch(0.696 0.17 162.48);
  --chart-3: oklch(0.769 0.188 70.08);
  --chart-4: oklch(0.627 0.265 303.9);
  --chart-5: oklch(0.645 0.246 16.439);
}

*, ::before, ::after { box-sizing: border-box; border: 0 solid var(--border); }
* { border-color: var(--border); }
html, body { margin: 0; padding: 0; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.875rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in oklab, var(--primary) 20%, transparent); }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }

/* ------------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--card); padding: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-foreground); font-weight: 800; font-size: 13px;
}
.brand .t { font-weight: 600; font-size: 0.9rem; line-height: 1.1; }
.brand .s { color: var(--muted-foreground); font-size: 0.7rem; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav .group { color: var(--muted-foreground); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground); font-weight: 500; font-size: 0.85rem; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--accent); color: var(--accent-foreground); text-decoration: none; }
.nav a.active { background: var(--accent); color: var(--accent-foreground); }
.nav svg { width: 16px; height: 16px; flex: 0 0 auto; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 8px 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }

main { padding: 20px 26px 64px; max-width: 1240px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.topbar .titles { min-width: 0; }
.eyebrow { color: var(--muted-foreground); font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.page-title { font-size: 1.35rem; margin-top: 2px; }
.searchbar { margin-left: auto; position: relative; width: min(420px, 42vw); }
.searchbar svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-foreground); }
.searchbar input { width: 100%; height: 2.25rem; padding: 0 12px 0 34px; }

/* --------------------------------------------------------------- components */
.card, .panel {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  padding: 20px; margin-bottom: 18px;
}
.card > h3, .panel h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.card .card-desc, .hint { color: var(--muted-foreground); font-size: 0.8rem; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 200px; min-width: 0; }
.sep { height: 1px; background: var(--border); margin: 16px 0; }

.btn, button, .chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 2.25rem; padding: 0 16px; border-radius: calc(var(--radius) - 2px);
  font: inherit; font-size: 0.85rem; font-weight: 500; cursor: pointer;
  background: var(--secondary); color: var(--secondary-foreground); border: 1px solid transparent;
  transition: background .12s, color .12s, border-color .12s, opacity .12s; white-space: nowrap;
}
.btn:hover, button:hover { background: color-mix(in oklab, var(--secondary) 80%, transparent); text-decoration: none; }
.btn.primary, button.primary { background: var(--primary); color: var(--primary-foreground); }
.btn.primary:hover, button.primary:hover { background: color-mix(in oklab, var(--primary) 90%, transparent); }
.btn.outline, button.outline { background: var(--background); border-color: var(--border); color: var(--foreground); }
.btn.outline:hover, button.outline:hover { background: var(--accent); }
.btn.ghost, button.ghost { background: transparent; color: var(--foreground); }
.btn.ghost:hover, button.ghost:hover { background: var(--accent); }
.btn.destructive, button.destructive { background: var(--destructive); color: #fff; }
button.sm, .btn.sm { height: 2rem; padding: 0 12px; font-size: 0.78rem; }
button.icon { width: 2.25rem; padding: 0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
button, .btn, .chip, .nav a, .tag-pill { cursor: pointer; }

input[type="text"], input[type="search"], .input {
  height: 2.25rem; width: 100%; padding: 0 12px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--input); background: transparent; color: var(--foreground);
  font: inherit; font-size: 0.85rem; outline: none; transition: border-color .12s, box-shadow .12s;
}
input::placeholder { color: var(--muted-foreground); }
select { height: 2.25rem; padding: 0 10px; border-radius: calc(var(--radius) - 2px); border: 1px solid var(--input); background: var(--background); color: var(--foreground); font: inherit; font-size: 0.82rem; }
input:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 2px 9px; font-size: 0.72rem; font-weight: 600; border: 1px solid var(--border);
  background: var(--secondary); color: var(--secondary-foreground); white-space: nowrap;
}
.badge.outline { background: transparent; color: var(--muted-foreground); }
.badge.ok { background: color-mix(in oklab, #22c55e 15%, transparent); color: #16a34a; border-color: color-mix(in oklab, #22c55e 30%, transparent); }
.badge.pink { background: color-mix(in oklab, var(--destructive) 15%, transparent); color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 30%, transparent); }
.badge.cyan { background: color-mix(in oklab, #06b6d4 15%, transparent); color: #0891b2; border-color: color-mix(in oklab, #06b6d4 30%, transparent); }
.dark .badge.ok { color: #4ade80; }
.dark .badge.cyan { color: #22d3ee; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--card); }
.stat .k { color: var(--muted-foreground); font-size: 0.72rem; font-weight: 500; }
.stat .v { font-size: 1.4rem; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat .sub { color: var(--muted-foreground); font-size: 0.7rem; }

.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: 620px; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--card); color: var(--muted-foreground); font-size: 0.72rem; font-weight: 600; position: sticky; top: 0; z-index: 2; }
tbody tr:hover { background: var(--accent); }
tr:last-child td { border-bottom: none; }
td.wrap { white-space: normal; max-width: 460px; min-width: 220px; }
.mini { color: var(--muted-foreground); font-size: 0.75rem; }
.muted { color: var(--muted-foreground); }
.tavatar { width: 26px; height: 26px; border-radius: 999px; vertical-align: middle; margin-right: 8px; object-fit: cover; background: var(--muted); }
.user-cell { display: flex; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 999px; object-fit: cover; border: 1px solid var(--border); background: var(--muted); }
.avatar.lg { width: 84px; height: 84px; }
.profile-head { display: flex; gap: 16px; align-items: center; }
.pname { font-size: 1.15rem; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pager { display: flex; gap: 12px; align-items: center; margin-top: 14px; color: var(--muted-foreground); font-size: 0.8rem; flex-wrap: wrap; }
.pager .spacer { flex: 1; }
.video-grid { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 20px; }
.video-cover { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: var(--muted); display: block; }
pre.snippet { background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; overflow: auto; max-height: 300px; white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 0.78rem; line-height: 1.55; }

.bar-row { display: grid; grid-template-columns: 30px 1fr 90px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.bar-row:last-child { border-bottom: none; }
.bar-rank { color: var(--muted-foreground); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.bar-track { background: var(--muted); border-radius: 999px; height: 7px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.bar-val { text-align: right; color: var(--muted-foreground); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.scroll { max-height: 620px; overflow-y: auto; padding-right: 4px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag-pill, .chips span { display: inline-flex; align-items: center; gap: 5px; background: var(--secondary); border-radius: 999px; padding: 5px 11px; font-size: 0.78rem; font-weight: 500; color: var(--secondary-foreground); }
.tag-pill:hover, .chips span:hover { background: var(--accent); text-decoration: none; }

.skel { background: linear-gradient(90deg, var(--muted) 25%, color-mix(in oklab, var(--muted) 60%, var(--background)) 37%, var(--muted) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: calc(var(--radius) - 4px); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-line { height: 12px; margin: 10px 0; }
.skel-stat { height: 74px; border-radius: var(--radius); }
.skel-avatar { width: 64px; height: 64px; border-radius: 999px; }

.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted-foreground); }
.kv .v { font-weight: 500; text-align: right; word-break: break-all; }
.empty { color: var(--muted-foreground); text-align: center; padding: 34px 16px; }
.empty .big { font-size: 1.6rem; margin-bottom: 6px; opacity: .6; }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 60;
  background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: var(--radius); box-shadow: 0 10px 30px -12px rgb(0 0 0 / .4);
  opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; font-size: 0.82rem; max-width: 380px;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-left: 3px solid var(--destructive); }
.spinner { width: 14px; height: 14px; border: 2px solid color-mix(in oklab, var(--foreground) 20%, transparent); border-top-color: var(--foreground); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.chart { width: 100%; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.metric { border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; }
.metric .k { color: var(--muted-foreground); font-size: 0.7rem; }
.metric .v { font-weight: 600; font-size: 1.05rem; margin-top: 2px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .group { display: none; }
  .sidebar-foot { display: none; }
  main { padding: 16px; }
  .grid-2, .grid-3, .video-grid { grid-template-columns: 1fr; }
  .searchbar { width: 100%; margin-left: 0; }
  .topbar { flex-wrap: wrap; }
}
