/*!
 * Visitorly 1.0 – shared stylesheet (landing, auth, installer, dashboard)
 * Warm & inviting palette: orange / amber / rose. No external fonts.
 */

/* ---------- Design tokens ---------- */
:root {
  --bg: #fffbf7;
  --surface: #ffffff;
  --surface-2: #fff3ea;
  --surface-3: #fdeee3;
  --text: #1c1917;
  --muted: #78716c;
  --border: #f0e4dc;
  --border-strong: #e5d5c9;
  --primary: #f97316;
  --primary-strong: #ea580c;
  --primary-soft: #ffedd5;
  --primary-contrast: #ffffff;
  --accent: #f43f5e;
  --amber: #f59e0b;
  --green: #10b981;
  --danger: #e11d48;
  --chart-1: #f97316;
  --chart-2: #fb923c;
  --shadow-sm: 0 1px 2px rgba(120, 72, 30, 0.06);
  --shadow: 0 4px 16px rgba(120, 72, 30, 0.10);
  --shadow-lg: 0 12px 32px rgba(120, 72, 30, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #191412;
  --surface: #221c18;
  --surface-2: #2c241e;
  --surface-3: #362c25;
  --text: #fdf5f0;
  --muted: #a8a29e;
  --border: #3a312b;
  --border-strong: #4a3f37;
  --primary: #fb923c;
  --primary-strong: #f97316;
  --primary-soft: #3b2a1c;
  --primary-contrast: #231303;
  --accent: #fb7185;
  --amber: #fbbf24;
  --green: #34d399;
  --danger: #fb7185;
  --chart-1: #fb923c;
  --chart-2: #fdba74;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
  transition: background 0.25s ease, color 0.25s ease;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--primary-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 800; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small, small { font-size: 0.85rem; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--border); }

::selection { background: var(--primary-soft); color: var(--primary-strong); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none !important;
  border: 1px solid transparent; border-radius: 999px; padding: 0.62rem 1.25rem;
  background: var(--surface-2); color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  min-height: 44px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--amber));
  background-color: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(249, 115, 22, 0.45); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.32rem 0.8rem; min-height: 34px; font-size: 0.86rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow-sm);
}
.card-hover:hover { box-shadow: var(--shadow); transform: translateY(-2px); transition: all 0.2s ease; }
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin: 0 0 1rem; font-size: 0.92rem; }
.alert-error { background: rgba(225, 29, 72, 0.09); color: var(--danger); border: 1px solid rgba(225, 29, 72, 0.25); }
.alert-success { background: rgba(16, 185, 129, 0.1); color: var(--green); border: 1px solid rgba(16, 185, 129, 0.3); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.container-wide { max-width: 1320px; margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 0.35rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  font: inherit; color: var(--text); width: 100%;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem; min-height: 44px; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: 0.85rem; }
.check { display: flex; gap: 0.65rem; align-items: flex-start; margin: 0.9rem 0; cursor: pointer; }
.check input { margin-top: 0.25rem; width: 18px; height: 18px; accent-color: var(--primary); }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none !important; letter-spacing: -0.02em; }
.logo span { color: var(--primary-strong); }

/* ---------- Site header (landing) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; gap: 1rem; height: 64px; }
.site-header nav { display: flex; gap: 1.25rem; margin-left: auto; align-items: center; }
.site-header nav a { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.site-header nav a:hover { color: var(--text); text-decoration: none; }
.lang-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; overflow: hidden; }
.lang-switch a { padding: 0.3rem 0.55rem; font-size: 0.8rem; font-weight: 700; color: var(--muted); text-decoration: none !important; }
.lang-switch a.active { background: var(--primary); color: var(--primary-contrast); }
.theme-toggle { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); }
.theme-toggle:hover { color: var(--primary-strong); border-color: var(--primary); }
.theme-toggle svg { display: block; }
.theme-toggle .ic-moon { display: none; }
[data-theme="dark"] .theme-toggle .ic-moon { display: block; }
[data-theme="dark"] .theme-toggle .ic-sun { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 4.5rem 0 3.5rem; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(600px 300px at 12% 0%, rgba(249, 115, 22, 0.13), transparent 65%),
    radial-gradient(500px 260px at 90% 10%, rgba(244, 63, 94, 0.09), transparent 60%);
}
.hero-grid { display: grid; gap: 3rem; align-items: center; position: relative; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.15fr 0.85fr; } }
.badge {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: var(--primary-soft); color: var(--primary-strong);
  border: 1px solid rgba(249, 115, 22, 0.3); border-radius: 999px;
  padding: 0.3rem 0.9rem; font-size: 0.82rem; font-weight: 700; margin-bottom: 1.1rem;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1);} 50% { opacity: 0.55; transform: scale(0.8);} }
.hero h1 em { font-style: normal; color: var(--primary-strong); }
.hero p.lead { font-size: 1.12rem; color: var(--muted); max-width: 34rem; }
.hero-cta { display: flex; gap: 0.8rem; flex-wrap: wrap; margin: 1.6rem 0 0; }

/* hero live preview card */
.live-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.live-card-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 0.85rem; font-weight: 700; }
.live-dots { display: inline-flex; gap: 6px; }
.live-dots i { width: 10px; height: 10px; border-radius: 50%; }
.live-dots i:nth-child(1) { background: #f87171; } .live-dots i:nth-child(2) { background: #fbbf24; } .live-dots i:nth-child(3) { background: #34d399; }
.live-card-body { padding: 1.1rem; }
.live-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; margin-bottom: 0.9rem; }
.live-stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.6rem 0.7rem; }
.live-stat b { display: block; font-size: 1.3rem; color: var(--primary-strong); font-variant-numeric: tabular-nums; }
.live-stat span { font-size: 0.72rem; color: var(--muted); }
.live-feed { display: flex; flex-direction: column; gap: 0.45rem; max-height: 168px; overflow: hidden; }
.live-feed-row { display: flex; gap: 0.5rem; align-items: center; font-size: 0.82rem; background: var(--surface-2); border-radius: 8px; padding: 0.42rem 0.65rem; animation: slidein 0.4s ease; }
.live-feed-row .flag { font-size: 1rem; }
.live-feed-row .path { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-feed-row .when { margin-left: auto; color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px);} to { opacity: 1; transform: none;} }

/* ---------- Sections ---------- */
.section { padding: 3.2rem 0; }
.section-head { max-width: 40rem; margin-bottom: 2rem; }
.section-head p { color: var(--muted); font-size: 1.05rem; }
.kicker { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; font-weight: 800; color: var(--primary-strong); margin-bottom: 0.5rem; }

.features-grid { display: grid; gap: 1.1rem; }
@media (min-width: 640px) { .features-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .features-grid { grid-template-columns: repeat(3, 1fr); } }
.feature-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--primary-soft); margin-bottom: 0.8rem; color: var(--primary-strong); }
.feature-icon.rose { background: rgba(244, 63, 94, 0.12); }
.feature-icon.amber { background: rgba(245, 158, 11, 0.14); }
.feature-icon.green { background: rgba(16, 185, 129, 0.12); }

/* webspace requirements section */
.req-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.2rem 0; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; background: var(--surface); border: 1px solid var(--border); padding: 0.45rem 0.9rem; border-radius: 999px; font-size: 0.9rem; font-weight: 600; }
.chip.ok { border-color: rgba(16, 185, 129, 0.45); color: var(--green); }
.chip.no { color: var(--danger); border-color: rgba(225, 29, 72, 0.35); }
.chip svg { width: 16px; height: 16px; }

/* how it works */
.steps { display: grid; gap: 1.2rem; }
@media (min-width: 840px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step-num { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--primary-contrast); background: linear-gradient(135deg, var(--primary), var(--amber)); margin-bottom: 0.75rem; font-size: 1.05rem; }
.code-block {
  background: #2a1f1a; color: #fdeadd; border-radius: var(--radius-sm); padding: 1rem 1.1rem;
  font-family: var(--mono); font-size: 0.82rem; overflow-x: auto; position: relative;
  border: 1px solid #3d2e25; line-height: 1.6;
}
/* v1.0.2 fix: the global inline `code` style (light background) must NOT
 * apply inside the dark code block – it made the snippet text invisible
 * (light text on light background) in light mode. */
.code-block code { background: transparent; color: inherit; padding: 0; font-size: inherit; border-radius: 0; }
.code-block .comment { color: #b08968; }
.code-block-wrap { position: relative; }
/* v1.0.3: the copy button sits ON the always-dark code block. The old
 * transparent outline style vanished in dark mode (dark border + dark text
 * shadow on the dark block). Solid light chip = clearly visible in BOTH
 * themes. */
.copy-btn {
  position: absolute; top: 0.55rem; right: 0.55rem; z-index: 2;
  background: #fdeadd; color: #2a1f1a;
  border: 1px solid rgba(253, 234, 221, 0.65);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.copy-btn:hover {
  background: #ffffff; color: #1c1917; border-color: #ffffff;
  transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.copy-btn:disabled { opacity: 0.55; }
/* keep the snippet text clear of the button */
.code-block-wrap .code-block { padding-right: 7rem; }
@media (max-width: 520px) {
  .code-block-wrap .code-block { padding-right: 1.1rem; padding-bottom: 3.2rem; }
  .copy-btn { position: static; margin: 0.55rem 0 0; }
}

/* FAQ */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 0.7rem; overflow: hidden; }
.faq-item summary { cursor: pointer; padding: 0.95rem 1.15rem; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 0.6rem; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; margin-left: auto; color: var(--primary-strong); font-size: 1.2rem; font-weight: 800; }
.faq-item[open] summary::after { content: "–"; }
.faq-item .faq-body { padding: 0 1.15rem 1rem; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface-2); padding: 2.2rem 0; margin-top: 3rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.site-footer p { margin: 0; }

/* ---------- Auth / installer pages ---------- */
.auth-wrap, .install-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; gap: 1.4rem; background:
  radial-gradient(700px 400px at 20% 0%, rgba(249, 115, 22, 0.08), transparent 60%),
  radial-gradient(600px 350px at 85% 90%, rgba(244, 63, 94, 0.07), transparent 55%); }
.auth-card, .install-wrap > .card { width: 100%; max-width: 460px; }
.auth-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; background: var(--surface-2); border-radius: 999px; padding: 0.3rem; }
.auth-tabs a { flex: 1; text-align: center; padding: 0.5rem; border-radius: 999px; font-weight: 700; font-size: 0.92rem; color: var(--muted); text-decoration: none !important; }
.auth-tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.install-wrap > .card { max-width: 560px; }
.form-title { margin: 1.4rem 0 0.7rem; font-size: 1.02rem; }
.form-title:first-child { margin-top: 0; }
.req-table { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin: 1rem 0; }
.req-table.compact { font-size: 0.9rem; }
.req-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--border); }
.req-row:last-child { border-bottom: 0; }
.req-icon { font-weight: 800; width: 1.2rem; }
.req-row.ok .req-icon { color: var(--green); }
.req-row.fail { background: rgba(225, 29, 72, 0.06); }
.req-row.fail .req-icon { color: var(--danger); }
.req-label { font-weight: 600; }
.req-detail { margin-left: auto; color: var(--muted); font-size: 0.82rem; font-family: var(--mono); }
.hint { font-size: 0.85rem; color: var(--muted); }
.done-icon { font-size: 3rem; text-align: center; }
.done-list { margin: 1rem 0 1.4rem; padding-left: 1.2rem; }
.done-list li { margin-bottom: 0.5rem; }
.card-done { text-align: center; }
.card-notice { text-align: center; }
.snippet-label { text-align: left; }
.done-actions { margin-top: 1.4rem; }
.install-footer { text-align: center; font-size: 0.85rem; }

/* ---------- Dashboard ---------- */
.dash-shell { min-height: 100vh; display: flex; flex-direction: column; }
.dash-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.dash-header-inner { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 1rem; flex-wrap: nowrap; min-width: 0; }
.dash-header .logo { font-size: 1.05rem; }
.dash-header .logo .word { display: none; }
@media (min-width: 480px) { .dash-header .logo .word { display: inline; } }
.site-select-wrap { min-width: 0; flex: 1; max-width: 340px; margin-left: 0.5rem; }
.site-select { width: 100%; min-width: 0; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.45rem; }
.header-actions select { width: auto; min-height: 38px; padding: 0.35rem 0.6rem; font-size: 0.85rem; }

.dash-nav { display: flex; gap: 0.25rem; padding: 0.45rem 1rem 0.55rem; overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.dash-nav a {
  white-space: nowrap; padding: 0.42rem 0.85rem; border-radius: 999px; font-weight: 700; font-size: 0.88rem;
  color: var(--muted); text-decoration: none !important; border: 1px solid transparent; min-height: 36px; display: inline-flex; align-items: center;
}
.dash-nav a:hover { color: var(--text); background: var(--surface-2); }
.dash-nav a.active { background: var(--primary); color: var(--primary-contrast); box-shadow: 0 3px 10px rgba(249, 115, 22, 0.35); }

.dash-main { flex: 1; padding: 1.4rem 1rem 3rem; width: 100%; max-width: 1320px; margin: 0 auto; }
.view-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.view-head h1 { font-size: 1.5rem; margin: 0 0 0.2rem; }
.view-head .muted { margin: 0; }
.view-head .right { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.live-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 800; border-radius: 999px; padding: 0.3rem 0.8rem; }
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
.live-badge.on { background: rgba(16, 185, 129, 0.12); color: var(--green); }
.live-badge.wait { background: var(--primary-soft); color: var(--primary-strong); }
.live-badge.off { background: rgba(225, 29, 72, 0.1); color: var(--danger); }
.live-badge.off .dot { background: var(--danger); animation: none; }

/* range tabs */
.range-tabs { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 0.25rem; border: 1px solid var(--border); }
.range-tabs button { border: 0; background: transparent; font: inherit; font-weight: 700; font-size: 0.86rem; padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer; color: var(--muted); min-height: 36px; }
.range-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border-strong); }

/* stat cards */
.stat-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1.2rem; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .stat-grid { grid-template-columns: repeat(8, 1fr); } }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow-sm); }
.stat-card .label { font-size: 0.78rem; font-weight: 700; color: var(--muted); margin-bottom: 0.25rem; }
.stat-card .value { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-card .sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }
.stat-card.orange .value { color: var(--primary-strong); }
.stat-card.green .value { color: var(--green); }
.stat-card.rose .value { color: var(--accent); }
.stat-card.amber .value { color: var(--amber); }

/* charts */
.chart-card { margin-bottom: 1.2rem; }
.chart-card canvas { width: 100%; height: 240px; display: block; }
.chart-legend { display: flex; gap: 1.1rem; font-size: 0.82rem; color: var(--muted); margin-top: 0.4rem; flex-wrap: wrap; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 0.35rem; }

/* top lists (legacy rows – still used by realtime/events/settings) */
.top-rows { display: flex; flex-direction: column; gap: 0.3rem; }
.top-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.42rem 0.6rem; border-radius: 8px; font-size: 0.86rem; }
.top-row:nth-child(odd) { background: var(--surface-2); }
.top-row .rank { color: var(--muted); font-size: 0.75rem; font-weight: 700; width: 1.1rem; }
.top-row .k { font-family: var(--mono); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.top-row .flag { font-size: 1rem; }
.top-row .c { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.top-row .v { color: var(--muted); font-size: 0.75rem; margin-left: 0.35rem; }
.top-row .bar { height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--chart-1), var(--chart-2)); min-width: 26px; flex: 0 1 90px; }

/* overview top lists (v1.0.2 – clean aligned table look) */
.tops-grid { display: grid; gap: 1.1rem; align-items: start; }
@media (min-width: 780px) { .tops-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1150px) { .tops-grid { grid-template-columns: repeat(3, 1fr); } }
.tl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 0.95rem 0.95rem; box-shadow: var(--shadow-sm); min-width: 0; }
.tl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.tl-head h3 { margin: 0; font-size: 0.95rem; }
.tl-legend { font-size: 0.7rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.tl-rows { display: flex; flex-direction: column; gap: 3px; }
.tl-row {
  position: relative; display: grid;
  grid-template-columns: 1.05rem minmax(0, 1fr) 4.4rem 3.6rem;
  gap: 0.55rem; align-items: center;
  padding: 0.42rem 0.65rem; border-radius: 8px; font-size: 0.86rem;
}
.tl-row::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0;
  width: calc(var(--w, 0) * 1%);
  background: var(--primary-soft);
  border-radius: 8px;
  z-index: 0; pointer-events: none;
}
.tl-row > * { position: relative; z-index: 1; min-width: 0; }
.tl-row .rank { color: var(--muted); font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-row .k { font-family: var(--mono); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row .k .flag { font-size: 1rem; margin-right: 0.3rem; }
.tl-row .c { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.tl-row .v { text-align: right; color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.tl-empty { color: var(--muted); font-size: 0.84rem; margin: 0; padding: 0.3rem 0.65rem 0.45rem; }
@media (max-width: 420px) {
  .tl-row { grid-template-columns: minmax(0, 1fr) 3.8rem 3.2rem; }
  .tl-row .rank { display: none; }
}

/* realtime feed */
.rt-grid { display: grid; gap: 1.1rem; }
@media (min-width: 900px) { .rt-grid { grid-template-columns: 1.4fr 1fr; } }
.feed { display: flex; flex-direction: column; gap: 0.45rem; max-height: 430px; overflow-y: auto; padding-right: 0.3rem; scrollbar-width: thin; }
.feed::-webkit-scrollbar { width: 8px; }
.feed::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.feed-row { display: flex; gap: 0.55rem; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 0.55rem 0.75rem; font-size: 0.84rem; animation: slidein 0.35s ease; }
.feed-row.event { border: 1px solid rgba(245, 158, 11, 0.4); background: rgba(245, 158, 11, 0.08); }
.feed-row .flag { font-size: 1.05rem; }
.feed-row .main { min-width: 0; flex: 1; }
.feed-row .path { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .ename { font-weight: 800; color: var(--amber); }
.feed-row .meta { font-size: 0.72rem; color: var(--muted); }
.feed-row .when { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.feed-empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* goals / funnels */
.item-grid { display: grid; gap: 1.1rem; }
@media (min-width: 780px) { .item-grid { grid-template-columns: repeat(2, 1fr); } }
.goal-card { position: relative; }
.goal-card.inactive { opacity: 0.6; }
.goal-head { display: flex; align-items: flex-start; gap: 0.6rem; flex-wrap: wrap; }
.goal-head h3 { margin: 0; flex: 1; min-width: 0; }
.goal-stats { display: flex; gap: 1.4rem; margin: 0.8rem 0; flex-wrap: wrap; }
.goal-stats .big { font-size: 1.5rem; font-weight: 800; color: var(--primary-strong); font-variant-numeric: tabular-nums; }
.goal-stats .lbl { font-size: 0.75rem; color: var(--muted); }
.progress { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; margin: 0.4rem 0 0.2rem; }
.progress i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--chart-1), var(--chart-2)); transition: width 0.4s ease; }
.goal-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; flex-wrap: wrap; }
.type-pill { font-size: 0.72rem; font-weight: 800; padding: 0.18rem 0.6rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-strong); }
.type-pill.event { background: rgba(245, 158, 11, 0.14); color: var(--amber); }
.type-pill.duration { background: rgba(16, 185, 129, 0.12); color: var(--green); }

.funnel-step { margin-bottom: 0.65rem; }
.funnel-step .step-head { display: flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; margin-bottom: 0.25rem; }
.funnel-step .step-label { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-step .step-count { font-variant-numeric: tabular-nums; font-weight: 800; }
.funnel-step .step-share { color: var(--muted); font-size: 0.78rem; }
.funnel-step .dropoff { font-size: 0.75rem; color: var(--danger); margin-top: 0.15rem; }
.completion-badge { font-size: 1.6rem; font-weight: 800; color: var(--primary-strong); font-variant-numeric: tabular-nums; }
.completion-label { font-size: 0.75rem; color: var(--muted); }

/* dialogs */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0;
  background: var(--surface); color: var(--text); max-width: 480px; width: calc(100% - 2rem);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(28, 25, 23, 0.55); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.dialog-head h3 { margin: 0; }
.dialog-body { padding: 1.25rem; }
.dialog-foot { display: flex; gap: 0.6rem; justify-content: flex-end; padding: 0 1.25rem 1.25rem; flex-wrap: wrap; }
.x-btn { border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; padding: 0.2rem 0.4rem; }
.x-btn:hover { color: var(--text); }

/* step picker (funnel create) */
.step-picker { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.5rem 0; }
.step-chip { border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 999px; padding: 0.3rem 0.75rem; font-size: 0.82rem; font-weight: 700; cursor: pointer; color: var(--text); }
.step-chip:hover { border-color: var(--primary); color: var(--primary-strong); }
.step-chip.picked { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.step-order { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.6rem 0; }
.order-row { display: flex; align-items: center; gap: 0.5rem; background: var(--surface-2); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.85rem; font-weight: 600; }
.order-row .num { color: var(--primary-strong); font-weight: 800; }
.order-row .btns { margin-left: auto; display: flex; gap: 0.25rem; }
.order-row button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 0.8rem; color: var(--text); }
.order-row button:hover { border-color: var(--primary); color: var(--primary-strong); }

/* ads slot */
.ad-slot { border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); padding: 0.8rem; margin: 1.2rem 0; position: relative; text-align: center; }
.ad-slot .ad-label { position: absolute; top: -0.55rem; left: 50%; transform: translateX(-50%); background: var(--bg); color: var(--muted); font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; padding: 0 0.5rem; }
.ad-slot .ad-content { min-height: 60px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.85rem; }
.ad-slot .ad-content ins, .ad-slot .ad-content > * { margin: 0 auto; }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th { text-align: left; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
table.data td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: 0; }
.pill { display: inline-flex; padding: 0.14rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 800; }
.pill.admin { background: var(--primary-soft); color: var(--primary-strong); }
.pill.user { background: var(--surface-3); color: var(--muted); }
.pill.banned { background: rgba(225, 29, 72, 0.1); color: var(--danger); }

/* toast */
.toast-wrap { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 0.5rem; width: min(92vw, 380px); }
.toast { background: var(--text); color: var(--bg); border-radius: 999px; padding: 0.7rem 1.2rem; font-weight: 700; font-size: 0.9rem; text-align: center; box-shadow: var(--shadow-lg); animation: slideup 0.3s ease; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes slideup { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: none;} }

/* empty states */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .icon { font-size: 2.6rem; margin-bottom: 0.5rem; line-height: 1; }
.empty .icon .ic, .empty .icon svg { color: var(--primary-strong); }
.empty h3 { color: var(--text); }

/* ---------- inline SVG icons (app.js icon() helper) ---------- */
.ic { display: inline-block; vertical-align: -0.18em; flex: 0 0 auto; }

/* owner tag on site cards (admins see all sites incl. owner) */
.owner-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 0.15rem 0.6rem;
  font-size: 0.72rem; font-weight: 700; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.owner-tag .ic { color: var(--primary-strong); }

/* tracking view */
.track-steps { display: grid; gap: 0.9rem; margin: 1.2rem 0; }
@media (min-width: 760px) { .track-steps { grid-template-columns: repeat(3, 1fr); } }
.track-step { display: flex; gap: 0.7rem; align-items: flex-start; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.9rem; font-size: 0.88rem; }
.track-step .n { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: var(--primary-contrast); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.8rem; }

/* utilities */
.flex { display: flex; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; } .gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; }
.grid-2 { display: grid; gap: 1.1rem; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
/* grid items must be allowed to shrink below their content's min-width,
 * otherwise long code snippets blow up the page width on mobile
 * (the code blocks scroll internally instead) */
.grid-2 > *, .item-grid > *, .rt-grid > *, .features-grid > *, .tops-grid > * { min-width: 0; }
.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; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--surface-3); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg);} }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 0.6rem; color: var(--muted); padding: 3rem 0; }

/* mobile tweaks */
@media (max-width: 520px) {
  .site-header nav a:not(.lang-switch a) { display: none; }
  .hero { padding: 2.8rem 0 2.2rem; }
  .live-stats { grid-template-columns: 1fr 1fr 1fr; }
  .dash-main { padding: 1rem 0.75rem 2.5rem; }
  .stat-card .value { font-size: 1.25rem; }
}

/* print (admin exports) */
@media print {
  .dash-header, .dash-nav, .ad-slot, .toast-wrap { display: none !important; }
}

/* ---------- Contact form (landing, v1.0.5) ---------- */
.contact-card { max-width: 40rem; margin: 0 auto; padding: 1.5rem; }
.contact-card textarea { font-family: inherit; font-size: 0.95rem; }
.contact-card .btn-block { margin-top: 0.4rem; }

/* honeypot: invisible for humans, still "visible" for naive bots */
.hp-field {
  position: absolute; left: -6000px; top: -6000px;
  width: 1px; height: 1px; opacity: 0; overflow: hidden;
}
