/* =========================================================
   LinkNest — design tokens
   Dark is the default; [data-theme="light"] switches.
   ========================================================= */
:root,
:root[data-theme="dark"] {
  --bg: #08090b;
  --bg-glow: rgba(190, 242, 60, .07);
  --surface: #111317;
  --surface-2: #171a1f;
  --surface-3: #1f2329;
  --inset: #0c0d10;
  --line: #22262d;
  --line-2: #2e333b;
  --text: #f1f3f5;
  --text-2: #b7bcc5;
  --muted: #7c838f;
  --faint: #5a616c;

  --accent: #c6f432;          /* fills (buttons, bars) */
  --accent-hover: #d4ff4a;
  --accent-ink: #0b1200;      /* text on accent fills */
  --accent-text: #c6f432;     /* accent used as text / icons */
  --accent-soft: rgba(198, 244, 50, .10);
  --accent-line: rgba(198, 244, 50, .32);
  --bar: #b6e42c;

  --danger: #ff6b5e;
  --danger-soft: rgba(255, 107, 94, .10);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .10);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .08);
  --warn-line: rgba(251, 191, 36, .35);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 32px -18px rgba(0, 0, 0, .8);
  --shadow-lg: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 30px 70px -30px rgba(0, 0, 0, .9);
  --tile-ring: rgba(255, 255, 255, .06);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-glow: rgba(132, 204, 22, .10);
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef2;
  --inset: #f8f9fb;
  --line: #e4e7ec;
  --line-2: #d3d8df;
  --text: #0d1015;
  --text-2: #3d4450;
  --muted: #6b7380;
  --faint: #9aa1ac;

  --accent: #c6f432;
  --accent-hover: #b8ea1d;
  --accent-ink: #0b1200;
  --accent-text: #4a7a06;
  --accent-soft: rgba(132, 204, 22, .12);
  --accent-line: rgba(101, 163, 13, .40);
  --bar: #65a30d;

  --danger: #d92d20;
  --danger-soft: rgba(217, 45, 32, .07);
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, .08);
  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, .09);
  --warn-line: rgba(217, 119, 6, .35);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -14px rgba(16, 24, 40, .14);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, .04), 0 30px 60px -28px rgba(16, 24, 40, .22);
  --tile-ring: rgba(0, 0, 0, .05);
  color-scheme: light;
}

/* =========================================================
   Base
   ========================================================= */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(700px 420px at 100% 0%, var(--bg-glow), transparent 65%),
    radial-gradient(520px 360px at 0% 100%, var(--bg-glow), transparent 70%);
}
a { color: inherit; }
h1, h2, h3 { font-family: "Space Grotesk", "Inter", sans-serif; }
code { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; }
.inline { display: inline; margin: 0; }
.muted { color: var(--muted); }
.ic { flex: none; display: block; }
.only-light { display: none; }
:root[data-theme="light"] .only-light { display: inline-flex; }
:root[data-theme="light"] .only-dark { display: none; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* =========================================================
   Brand
   ========================================================= */
.brand {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font: 700 19px/1 "Space Grotesk", sans-serif; letter-spacing: -.03em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 0 0 1px rgba(0,0,0,.08) inset, 0 6px 18px -8px var(--accent);
}
.brand-mark .ic { stroke-width: 2.4; }

/* =========================================================
   App shell (admin)
   ========================================================= */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: 22px 16px 18px; border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(14px);
}
.sidebar .brand { padding: 4px 8px 6px; }
.nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--surface-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.is-active .ic { color: var(--accent-text); }
.side-foot { margin-top: auto; display: grid; gap: 12px; }

.theme-switch {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; height: 38px;
  border-radius: 11px; border: 1px solid var(--line); background: var(--inset); cursor: pointer; font: inherit;
}
.theme-switch::before {
  content: ""; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: 8px; background: var(--surface-3); box-shadow: var(--shadow-sm); transition: transform .22s ease;
}
:root[data-theme="light"] .theme-switch::before { transform: translateX(100%); background: var(--surface); }
.ts-opt { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
:root:not([data-theme="light"]) .ts-dark, :root[data-theme="light"] .ts-light { color: var(--text); }

.user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent), #6fd33a); color: var(--accent-ink); font: 700 14px "Space Grotesk", sans-serif;
}
.user-meta { display: grid; line-height: 1.25; min-width: 0; flex: 1; }
.user-meta strong { font-size: 13.5px; font-weight: 600; }
.user-meta span { font-size: 12px; color: var(--muted); }

.content { padding: 30px clamp(18px, 3.2vw, 44px) 56px; min-width: 0; }
.content-inner { max-width: 1240px; margin: 0 auto; }

/* =========================================================
   Plain layout (PIN / login / creator for PIN users)
   ========================================================= */
.topbar {
  position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 4vw, 40px);
}
.plain { position: relative; z-index: 1; padding: 8px clamp(16px, 4vw, 40px) 64px; }

/* =========================================================
   Buttons & inputs
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 11px; border: 1px solid transparent;
  font: 600 14px "Inter", sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .input:focus-visible, .nav-item:focus-visible, .col:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.btn-sm { height: 34px; padding: 0 12px; border-radius: 9px; font-size: 13px; gap: 6px; }
.btn-lg { height: 50px; padding: 0 22px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px -12px var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-dashed { background: transparent; border: 1px dashed var(--line-2); color: var(--text-2); height: 42px; }
.btn-dashed:hover { color: var(--accent-text); border-color: var(--accent-line); background: var(--accent-soft); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; flex: none;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn-lg { width: 40px; height: 40px; border-radius: 11px; border-color: var(--line); background: var(--surface); }
.icon-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.is-copied, .btn.is-copied { color: var(--ok) !important; background: var(--ok-soft) !important; }

.field { display: grid; gap: 7px; }
.field-label { display: flex; align-items: baseline; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.field-label em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 11px;
  background: var(--inset); border: 1px solid var(--line); color: var(--text);
  font: 14.5px "Inter", sans-serif; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--line-2); }
.input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.input-wrap { position: relative; }
.input-wrap > .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-wrap .input { padding-left: 42px; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--bar); }
.stack { display: grid; gap: 18px; }

/* URL rows */
.url-list { display: grid; gap: 8px; }
.url-row { display: flex; align-items: center; gap: 8px; }
.url-num {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font: 500 12px "JetBrains Mono", monospace; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
}
.url-remove {
  flex: none; width: 40px; height: 46px; border-radius: 11px; display: grid; place-items: center;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
}
.url-remove:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* =========================================================
   Alerts, pills, toast
   ========================================================= */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); margin-bottom: 16px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap;
}
.pill .ic { color: var(--accent-text); }
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   Page header
   ========================================================= */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-text); }
.page-title { margin: 0; font-size: clamp(26px, 3vw, 32px); font-weight: 700; letter-spacing: -.035em; line-height: 1.1; }
.page-sub { margin: 6px 0 0; color: var(--muted); }

/* =========================================================
   Panels & KPIs
   ========================================================= */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.panel-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.panel-sub { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.panel-note { margin: 16px 0 0; font-size: 12.5px; color: var(--muted); padding-top: 14px; border-top: 1px dashed var(--line); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.kpi-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.kpi-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.kpi-value { font: 700 clamp(28px, 3vw, 34px)/1 "Space Grotesk", sans-serif; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.kpi-foot { margin-top: 10px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.delta.up { color: var(--ok); background: var(--ok-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--muted); background: var(--surface-2); }
.kpi.is-hero { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 16%, var(--surface)) 0%, var(--surface) 62%); border-color: var(--accent-line); }
.kpi.is-hero .kpi-ico { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.chart-panel { display: flex; flex-direction: column; }
.chart-panel .chart { flex: 1; height: auto; min-height: 236px; }

/* =========================================================
   Chart (clicks per day)
   ========================================================= */
.chart-sum { display: flex; align-items: baseline; gap: 8px; }
.chart-sum strong { font: 700 22px "Space Grotesk", sans-serif; letter-spacing: -.03em; }
.chart { position: relative; height: 236px; padding: 10px 0 26px 34px; }
.chart-grid { position: absolute; top: 10px; right: 0; bottom: 26px; left: 34px; }
.grid-line { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed var(--line); }
.grid-line.is-base { border-top-style: solid; border-color: var(--line-2); }
.grid-line span { position: absolute; right: calc(100% + 8px); top: -8px; font: 11px "JetBrains Mono", monospace; color: var(--faint); white-space: nowrap; }
.chart-cols { position: relative; height: 100%; display: flex; gap: 2px; }
.col { position: relative; flex: 1; display: flex; align-items: flex-end; justify-content: center; border-radius: 6px; outline: none; }
.col:hover, .col:focus { background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
.bar { position: relative; width: min(26px, 62%); background: var(--bar); border-radius: 4px 4px 0 0; }
.col:not(.is-today) .bar { background: color-mix(in srgb, var(--bar) 68%, var(--surface)); }
.col:hover .bar, .col:focus .bar { background: var(--bar); }
.xlab { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.col.is-today .xlab { color: var(--text); font-weight: 600; }
.tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translate(-50%, 4px); z-index: 5;
  display: grid; gap: 1px; padding: 8px 11px; border-radius: 10px; white-space: nowrap; pointer-events: none;
  background: var(--text); color: var(--bg); font-size: 12.5px; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .12s, transform .12s;
}
.tip strong { font-size: 14px; }
.tip em { font-style: normal; opacity: .7; font-size: 11.5px; }
.col:hover .tip, .col:focus .tip { opacity: 1; transform: translate(-50%, 0); }
.col:first-child .tip, .col:nth-child(2) .tip { left: 0; transform: translate(-10%, 4px); }
.col:first-child:hover .tip, .col:nth-child(2):hover .tip { transform: translate(-10%, 0); }
.col:last-child .tip, .col:nth-last-child(2) .tip { left: auto; right: 0; transform: translate(10%, 4px); }
.col:last-child:hover .tip, .col:nth-last-child(2):hover .tip { transform: translate(10%, 0); }

/* =========================================================
   Sources
   ========================================================= */
.src-tile { flex: none; display: block; border-radius: 10px; box-shadow: 0 0 0 1px var(--tile-ring), 0 4px 10px -6px rgba(0,0,0,.4); }
.src-neutral { display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.src-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.src-row { display: flex; align-items: center; gap: 13px; padding: 9px 10px; margin: 0 -10px; border-radius: 12px; transition: background .15s; }
.src-row:hover { background: var(--surface-2); }
.src-main { flex: 1; min-width: 0; display: grid; gap: 7px; }
.src-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.src-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-num { display: inline-flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.src-num strong { font-size: 14px; font-weight: 600; }
.src-num span { font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }
.src-track { display: block; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.src-fill { display: block; height: 100%; border-radius: 99px; background: var(--bar); }
.src-row:not(.is-top) .src-fill { opacity: .7; }
.empty-mini { text-align: center; padding: 22px 8px 8px; color: var(--muted); font-size: 13.5px; }
.empty-mini p { margin: 12px auto 0; max-width: 260px; }
.src-stack { display: inline-flex; }
.src-stack .src-tile { margin: 0 -4px; box-shadow: 0 0 0 3px var(--surface); }

/* =========================================================
   Setup banner
   ========================================================= */
.setup {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 16px; align-items: start;
  padding: 18px 20px; margin-bottom: 18px; border-radius: 16px;
  background: var(--warn-soft); border: 1px solid var(--warn-line);
}
.setup-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.setup h3 { margin: 0 0 4px; font-size: 15px; }
.setup p { margin: 0; color: var(--text-2); font-size: 13.5px; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.setup details { margin-top: 12px; }
.setup summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; }
.code-box { position: relative; margin-top: 10px; padding: 12px 52px 12px 14px; border-radius: 11px; background: var(--inset); border: 1px solid var(--line); }
.code-box code { display: block; font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.code-box .icon-btn { position: absolute; top: 8px; right: 8px; }

/* =========================================================
   Links table
   ========================================================= */
.links-panel { padding: 0; overflow: hidden; }
.links-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.links-head .panel-title { display: flex; align-items: center; gap: 8px; }
.count-chip { font: 600 12px "Inter", sans-serif; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.search { display: flex; gap: 8px; align-items: center; }
.search .input { height: 40px; width: min(320px, 60vw); }
.table-scroll { overflow-x: auto; }
table.links { width: 100%; border-collapse: collapse; min-width: 860px; }
.links th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.links td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.links tbody tr:last-child td { border-bottom: 0; }
.links tbody tr { transition: background .12s; }
.links tbody tr:hover { background: var(--surface-2); }
.links th:first-child, .links td:first-child { padding-left: 22px; }
.links th:last-child, .links td:last-child { padding-right: 18px; }
.links th.num, .links th.act { text-align: right; }
.sn { width: 56px; font: 500 12.5px "JetBrains Mono", monospace; color: var(--muted); }
.t-name { display: grid; gap: 5px; min-width: 0; max-width: 300px; }
.t-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-title.is-empty { color: var(--muted); font-weight: 500; font-style: italic; }
.t-short { display: flex; align-items: center; gap: 6px; font: 12px "JetBrains Mono", monospace; color: var(--text-2); min-width: 0; }
.t-short > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-src { display: inline-flex; align-items: center; flex: none; padding: 1px 7px; border-radius: 6px; font: 500 11px "Inter", sans-serif; color: var(--text-2); background: var(--surface-3); }
.t-url { max-width: 280px; }
.t-url a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); text-decoration: none; font-size: 13.5px; }
.t-url a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.rot { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; font-size: 11.5px; font-weight: 600; color: var(--accent-text); }
.num { text-align: right; }
.clicks { font: 600 15px "Space Grotesk", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.t-date { color: var(--text-2); white-space: nowrap; font-size: 13px; }
.t-date span { display: block; font-size: 11.5px; color: var(--muted); }
.act { white-space: nowrap; text-align: right; }
.act-group { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); }
.empty { padding: 56px 20px; text-align: center; }
.empty-ico { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.empty h3 { margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 18px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager-btns { display: flex; gap: 6px; }

/* =========================================================
   Creator page
   ========================================================= */
.creator { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); gap: clamp(28px, 5vw, 64px); align-items: center; padding-top: clamp(8px, 4vh, 40px); }
.mode-app .creator { padding-top: 0; }
.pitch h1 { margin: 16px 0 14px; font-size: clamp(34px, 4.6vw, 54px); line-height: 1.02; letter-spacing: -.045em; font-weight: 700; }
.pitch h1 em { font-style: normal; color: var(--accent-text); }
.pitch > p { margin: 0 0 28px; font-size: 16px; color: var(--text-2); max-width: 440px; }
.badge-new { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 5px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); box-shadow: var(--shadow-sm); }
.badge-new b { display: inline-grid; place-items: center; height: 21px; padding: 0 8px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.features li { display: flex; gap: 14px; align-items: flex-start; }
.feat-ico { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--accent-text); box-shadow: var(--shadow-sm); }
.features strong { display: block; font-size: 14.5px; margin-bottom: 1px; }
.features span { font-size: 13.5px; color: var(--muted); }

.form-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); padding: clamp(22px, 3vw, 30px); }
.form-card::before {
  content: ""; position: absolute; inset: -1px; border-radius: 23px; padding: 1px; pointer-events: none;
  background: linear-gradient(160deg, var(--accent-line), transparent 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.form-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.form-card-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.preview { padding: 12px 14px; border-radius: 12px; background: var(--inset); border: 1px dashed var(--line-2); }
.preview-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.preview code { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.preview code b { color: var(--accent-text); font-weight: 500; }
.preview code i { font-style: normal; color: var(--text-2); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 12px; }

.result-card { margin-bottom: 22px; padding: 16px; border-radius: 16px; border: 1px solid var(--accent-line); background: linear-gradient(160deg, var(--accent-soft), transparent 80%); animation: pop .35s ease; }
.result-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ok-dot { width: 26px; height: 26px; border-radius: 99px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.result-top strong { font-size: 14px; }
.result-meta { font-size: 12.5px; color: var(--muted); margin-left: auto; }
.result-url { display: block; padding: 12px 14px; border-radius: 11px; background: var(--inset); border: 1px solid var(--line); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; color: var(--text); }
.result-actions { display: flex; gap: 8px; margin-top: 10px; }
.result-actions .btn { flex: 1; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } to { opacity: 1; transform: none; } }

/* =========================================================
   Auth (PIN / login)
   ========================================================= */
.auth { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 410px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); padding: 34px 30px 30px; text-align: center; }
.auth-ico { width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.auth-card h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.03em; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); }
.auth-card form { text-align: left; }
.auth-card .alert { text-align: left; }
.pin-input { text-align: center; height: 60px; font: 500 24px "JetBrains Mono", monospace; letter-spacing: .5em; padding-left: calc(14px + .5em); }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }

/* =========================================================
   Edit page
   ========================================================= */
.edit-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.side-col { display: grid; gap: 16px; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini { padding: 16px 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.mini span { font-size: 12.5px; color: var(--muted); }
.mini strong { display: block; margin-top: 4px; font: 700 26px "Space Grotesk", sans-serif; letter-spacing: -.03em; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .edit-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .creator { grid-template-columns: minmax(0, 1fr); }
  .pitch { text-align: center; }
  .pitch > p { margin-left: auto; margin-right: auto; margin-bottom: 0; }
  .features { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px;
    padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar .brand { padding: 0; margin-right: auto; }
  .sidebar .brand > span:last-child { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav-item { height: 36px; padding: 0 10px; font-size: 13px; gap: 7px; }
  .nav-item.is-active { box-shadow: inset 0 -2px 0 var(--accent); }
  .side-foot { margin: 0; display: flex; align-items: center; gap: 6px; }
  .theme-switch { width: 36px; height: 36px; grid-template-columns: 1fr; padding: 0; place-items: center; }
  .theme-switch::before { display: none; }
  .ts-opt span { display: none; }
  .ts-opt { grid-area: 1 / 1; color: var(--text) !important; }
  :root:not([data-theme="light"]) .ts-dark, :root[data-theme="light"] .ts-light { display: none; }
  .user { padding: 0; border: 0; background: none; gap: 4px; }
  .user .avatar, .user-meta { display: none; }
  .content { padding: 22px 16px 48px; }
}
@media (max-width: 560px) {
  .nav-item span { display: none; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; border-radius: 15px; }
  .kpi-ico { display: none; }
  .kpi-top { margin-bottom: 8px; }
  .kpi-foot { font-size: 11.5px; }
  .panel { padding: 16px; border-radius: 16px; }
  .links-panel { padding: 0; }
  .links-head { padding: 14px 16px; }
  .search { width: 100%; }
  .search .input-wrap { flex: 1; }
  .search .input { width: 100%; }
  .two { grid-template-columns: 1fr; }
  .chart, .chart-panel .chart { min-height: 200px; }
  .result-actions { flex-direction: column; }
  .setup { grid-template-columns: 1fr; }
  .setup-ico { display: none; }
  /* table becomes cards */
  table.links { min-width: 0; }
  .links thead { display: none; }
  .links, .links tbody, .links tr, .links td { display: block; width: 100%; }
  .links tr { position: relative; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
  .links tbody tr:last-child { border-bottom: 0; }
  .links td { border: 0 !important; padding: 3px 0 !important; text-align: left; max-width: none; }
  .links td.sn { position: absolute; top: 14px; right: 16px; width: auto; }
  .t-name, .t-url { max-width: calc(100% - 44px); }
  .links td.num { display: flex; gap: 10px; align-items: baseline; }
  .links td.num::before { content: "Clicks"; font-size: 12px; color: var(--muted); }
  .links td.act { text-align: left; padding-top: 10px !important; }
  .pager { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* =========================================================
   Settings page
   ========================================================= */
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-grid .panel-head { margin-bottom: 16px; }
.set-title { display: flex; align-items: center; gap: 12px; }
.set-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-line); }
.settings-grid .panel-sub strong { color: var(--text); font-weight: 600; }
.settings-grid .btn { justify-self: start; }
@media (max-width: 1180px) { .settings-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 760px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }

/* =========================================================
   Live counters
   ========================================================= */
.head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.live-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  font-size: 12.5px; font-weight: 600; letter-spacing: .02em; transition: background .2s, color .2s, border-color .2s;
}
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 99px; background: currentColor; }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 99px; border: 2px solid currentColor; opacity: 0; animation: livePulse 2s ease-out infinite; }
.live-pill.ping .live-dot::after { animation: livePulse .9s ease-out 2; }
.live-pill.is-paused { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.live-pill.is-off { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.live-pill.is-paused .live-dot::after, .live-pill.is-off .live-dot::after { animation: none; }
@keyframes livePulse { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.8); opacity: 0; } }

.kpi.bump { animation: kpiBump 1.1s ease; }
@keyframes kpiBump {
  0%   { box-shadow: 0 0 0 0 var(--accent-line), var(--shadow); border-color: var(--accent-line); }
  25%  { box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); border-color: var(--accent-line); }
  100% { box-shadow: var(--shadow); }
}
.links tr.bump .clicks { animation: cellBump 1.1s ease; }
@keyframes cellBump { 0%, 30% { color: var(--accent-text); } 100% { color: inherit; } }

/* Top navigation (public pages) */
.topbar { display: flex; align-items: center; gap: 16px; }
.top-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; flex: 1; }
.top-nav-link {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.top-nav-link:hover { background: var(--surface-2); color: var(--text); }
.top-nav-link.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Pricing page */
.pricing-wrap { max-width: 980px; margin: 0 auto; padding: 32px 20px 60px; }
.pricing-head { text-align: center; margin-bottom: 40px; }
.pricing-head h1 { font-size: clamp(28px, 4vw, 36px); font-weight: 700; letter-spacing: -.03em; margin: 0 0 10px; }
.pricing-head p { color: var(--muted); font-size: 16px; margin: 0; }
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 800px) {
  .pricing-grid { grid-template-columns: 1fr; max-width: 400px; margin: 0 auto; }
}
.price-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color .2s, transform .2s;
}
.price-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.price-card.is-featured {
  border-color: var(--accent);
  box-shadow: 0 12px 40px -16px var(--accent);
}
.price-card .plan-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 99px;
  letter-spacing: .02em;
}
.price-card h2 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.price-card .plan-tag { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.price-card .plan-price {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -.03em;
  margin-bottom: 4px;
}
.price-card .plan-price span { font-size: 14px; font-weight: 500; color: var(--muted); }
.price-card ul {
  list-style: none;
  padding: 0;
  margin: 20px 0 24px;
  flex: 1;
}
.price-card ul li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-2);
  border-bottom: 1px dashed var(--line);
}
.price-card ul li:last-child { border-bottom: none; }
.price-card ul li svg { flex-shrink: 0; margin-top: 2px; color: var(--accent); }
.price-card .btn { width: 100%; justify-content: center; }

/* =========================================================
   Mobile polish (100% responsive)
   ========================================================= */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }
img, svg, video { max-width: 100%; height: auto; }
.input, textarea.input, select.input { max-width: 100%; width: 100%; }
table { max-width: 100%; }

/* Topbar mobile */
@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px;
  }
  .topbar .brand { order: 1; }
  .topbar .top-nav {
    order: 3;
    width: 100%;
    margin: 0;
    justify-content: center;
    gap: 2px;
    padding-top: 4px;
    border-top: 1px solid var(--line);
  }
  .top-nav-link { padding: 8px 16px; font-size: 13.5px; }
  .topbar > div { order: 2; margin-left: auto; }
  .topbar .btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
  .plain { padding: 8px 14px 48px; }
}

@media (max-width: 400px) {
  .topbar .btn-sm span,
  .topbar .btn-sm { font-size: 12px; }
  .top-nav-link { padding: 7px 12px; }
}

/* Auth / login / register / PIN */
@media (max-width: 560px) {
  .auth { padding: 12px 0 32px; }
  .auth-card {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 24px 18px;
    border-radius: 16px;
  }
  .auth-card h1 { font-size: 22px; }
  .auth-card > p { font-size: 14px; }
  .pin-input { font-size: 22px !important; letter-spacing: .35em; }
  .btn-lg { height: 48px; font-size: 15px; }
  .btn-block { width: 100%; }
  .stack { gap: 14px; }
  .field-label { font-size: 13px; }
}

/* Creator form */
@media (max-width: 960px) {
  .creator { gap: 20px; }
  .form-card { padding: 20px 16px; border-radius: 16px; }
  .form-card-head {
    flex-wrap: wrap;
    gap: 10px;
  }
  .form-card-head h2 { font-size: 17px; }
  .pitch h1 { font-size: clamp(24px, 6vw, 32px); }
  .pitch > p { font-size: 14.5px; }
}

@media (max-width: 560px) {
  .badge-new { font-size: 11.5px; height: 28px; }
  .form-card-head .head-actions,
  .form-card-head > div {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .form-card-head .btn { flex: 1; justify-content: center; }
  .alert {
    flex-wrap: wrap;
    font-size: 13.5px;
    padding: 12px 14px;
  }
  .alert code,
  .copyable {
    display: block;
    word-break: break-all;
    white-space: pre-wrap;
    font-size: 12px;
    margin: 6px 0;
  }
  .alert .btn-sm { margin-top: 6px; }
}

/* Page heads */
@media (max-width: 640px) {
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-title { font-size: 24px; }
  .page-sub { font-size: 13.5px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; justify-content: center; }
}

/* KPI / stats */
@media (max-width: 560px) {
  .kpis,
  .stat-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }
  .stat, .kpi { padding: 14px; }
  .stat-val, .kpi strong { font-size: 22px; }
}

@media (max-width: 360px) {
  .kpis,
  .stat-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Tables general mobile card layout */
@media (max-width: 700px) {
  .table-wrap,
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
  }
  table.table {
    min-width: 0;
    width: 100%;
  }
  /* Users admin table → stacked cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td {
    display: block;
    width: 100%;
  }
  .table tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td {
    border: 0 !important;
    padding: 4px 0 !important;
    text-align: left !important;
    max-width: none;
  }
  .table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .row-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 10px !important;
  }
  .row-actions .btn,
  .row-actions .btn-sm {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }
  .row-actions .icon-btn { flex: none; }
}

/* Dashboard links table already handled; ensure owner col ok */
@media (max-width: 560px) {
  .links td.t-date span { display: none; }
  .act-group { flex-wrap: wrap; gap: 6px; }
  .page-head .live-pill { display: none; }
}

/* Settings */
@media (max-width: 560px) {
  .settings-grid { gap: 12px; }
  .settings-grid .panel { padding: 16px; }
  .set-title { gap: 10px; }
  .set-ico { width: 34px; height: 34px; }
}

/* Pricing mobile */
@media (max-width: 800px) {
  .pricing-wrap { padding: 24px 14px 48px; }
  .pricing-head { margin-bottom: 28px; }
  .pricing-head h1 { font-size: 26px; }
  .pricing-head p { font-size: 14.5px; }
  .price-card { padding: 22px 18px; border-radius: 16px; }
  .price-card .plan-price { font-size: 28px; }
}

/* Sidebar mobile: prevent overflow of many nav items */
@media (max-width: 860px) {
  .sidebar {
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav {
    flex: 1 1 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    max-width: 100%;
  }
  .nav-item { flex: none; white-space: nowrap; }
}

@media (max-width: 560px) {
  .sidebar { padding: 8px 10px; gap: 6px; }
  .nav-item { padding: 0 8px; height: 34px; }
  .content { padding: 16px 12px 40px; }
  .content-inner { max-width: 100%; }
}

/* Users edit form grid */
@media (max-width: 640px) {
  .stack [style*="grid-template-columns"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
}

/* Toast */
.toast {
  max-width: calc(100vw - 32px);
  left: 50%;
  transform: translateX(-50%);
  right: auto;
}

/* Prevent iOS zoom on focus */
@media (max-width: 560px) {
  input.input,
  textarea.input,
  select.input {
    font-size: 16px !important;
  }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .sidebar {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .content, .plain {
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }
}
