/* =========================================================================
   Rikosarkisto – mobile-first stylesheet
   ========================================================================= */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #121620;
  --muted: #646c7a;
  --brand: #3555e0;
  --brand-hover: #2a46c4;
  --brand-ink: #ffffff;
  --brand-soft: #eaeefe;
  --brand-soft-ink: #2a43b8;
  --danger: #cf3434;
  --danger-soft: #fdecec;
  --warn-ink: #8a5a00;
  --warn-soft: #fff5de;
  --success-ink: #106c41;
  --success-soft: #e3f5eb;
  --reader-bg: #e9ecf0;
  --mark: #ffe58a;
  --series-1: #3555e0;
  --series-2: #e07b39;
  --grid: #eceef2;

  --r-xs: 8px;
  --r-sm: 12px;
  --r: 16px;
  --r-lg: 22px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / .05);
  --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 4px 16px rgb(16 24 40 / .06);
  --shadow-lg: 0 12px 40px rgb(16 24 40 / .16);
  --header-h: 60px;
  --bottom-h: 64px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
/* Dark theme is opt-in (footer toggle → theme cookie → <html data-theme="dark">). */
:root[data-theme="dark"] {
    --bg: #0e1117;
    --surface: #161a22;
    --surface-2: #1d222c;
    --surface-3: #262c38;
    --border: #262c37;
    --border-strong: #343b49;
    --text: #e8ebf1;
    --muted: #98a0ae;
    --brand: #6f86ff;
    --brand-hover: #8798ff;
    --brand-ink: #0b0e14;
    --brand-soft: #1e2645;
    --brand-soft-ink: #aab8ff;
    --danger: #ff6b6b;
    --danger-soft: #3a1c1f;
    --warn-ink: #f3c46b;
    --warn-soft: #33290f;
    --success-ink: #6fd9a2;
    --success-soft: #12301f;
    --reader-bg: #0a0d12;
    --mark: #7a6512;
    --series-1: #6f86ff;
    --series-2: #d95926;
    --grid: #232935;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / .5);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 4.5vw, 2.1rem); }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 .1em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

.icon { width: 1.25em; height: 1.25em; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 1000; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); }
.text-brand { color: var(--brand); }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }
.only-desktop { display: none !important; }
.hide-xs { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 600; font-size: .95rem; line-height: 1;
  cursor: pointer; text-decoration: none !important; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn .icon { width: 18px; height: 18px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-soft:hover { background: var(--surface-3); }
.btn-soft.is-saved { background: var(--brand-soft); color: var(--brand-soft-ink); border-color: transparent; }
.btn-soft.is-saved .icon { fill: currentColor; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--r-pill); color: var(--text); border: 0; background: transparent; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.link-btn {
  display: inline-flex; align-items: center; gap: .4em; padding: 0; border: 0; background: none;
  color: var(--brand); font-weight: 500; cursor: pointer;
}
.link-btn.danger { color: var(--danger); }
.link-btn .icon { width: 1.05em; height: 1.05em; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 12px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.1rem; color: var(--text); letter-spacing: -.02em; text-decoration: none !important; }
.logo-mark { width: 32px; height: 32px; }
.header-search { display: none; }
.header-nav { display: none; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.avatar {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; text-decoration: none !important;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; flex: none; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: .7rem; font-weight: 600; text-decoration: none;
}
.bottom-nav a .icon { width: 22px; height: 22px; }
.bottom-nav a.is-active { color: var(--brand); }
.bottom-nav-cta .icon {
  width: 36px !important; height: 30px !important; padding: 5px 8px; border-radius: var(--r-pill);
  background: var(--brand); color: var(--brand-ink);
}

/* ---------- Flash & notices ---------- */
.flash {
  display: flex; align-items: flex-start; gap: 10px; margin: 16px 0 0; padding: 12px 16px;
  border-radius: var(--r-sm); font-weight: 500;
}
.flash .icon { margin-top: 2px; }
.flash-success { background: var(--success-soft); color: var(--success-ink); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--muted); font-size: .92rem;
}
.notice .icon { margin-top: 2px; }
.notice-warn { background: var(--warn-soft); color: var(--warn-ink); }
.notice-warn a { color: inherit; text-decoration: underline; }

/* ---------- Pills & chips ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand-soft-ink);
  font-size: .72rem; font-weight: 650; letter-spacing: .01em; white-space: nowrap;
}
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: .875rem; font-weight: 500; text-decoration: none !important;
}
.chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.chip-active { background: var(--brand-soft); color: var(--brand-soft-ink); border-color: transparent; }
.chip-active .icon { width: 14px; height: 14px; }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--brand); color: var(--brand-ink); font-size: .72rem; font-weight: 700;
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 36px 0 28px;
  background:
    radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 60%),
    radial-gradient(800px 300px at 0% 0%, color-mix(in srgb, #00b3a4 12%, transparent), transparent 60%);
}
.hero-inner { max-width: 860px; }
.hero h1 { font-size: clamp(1.9rem, 7vw, 3.3rem); letter-spacing: -.03em; margin-bottom: 12px; }
.hero-lead { color: var(--muted); font-size: 1.05rem; max-width: 620px; }
.hero-search, .search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 6px 6px 6px 16px; box-shadow: var(--shadow);
}
.hero-search:focus-within, .search-bar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.hero-search > .icon, .search-bar > .icon { color: var(--muted); }
.hero-search input[type=search], .search-bar input[type=search] {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 44px; font-size: 1rem;
}
.hero-chips { margin-top: 16px; }
.hero-stats { display: flex; gap: 28px; margin: 24px 0 0; }
.hero-stats div { display: flex; flex-direction: column-reverse; }
.hero-stats dt { font-size: .8rem; color: var(--muted); }
.hero-stats dd { margin: 0; font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; }

/* ---------- Modules ---------- */
.home-modules { display: grid; gap: 36px; padding-top: 12px; padding-bottom: 48px; }
.module-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.module-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.25rem; }
.module-head h2 .icon { color: var(--brand); }
.link-more { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: .9rem; }
.link-more .icon { width: 16px; height: 16px; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: var(--r-pill); border: 1px solid var(--border); }
.segmented button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: var(--r-pill);
  font-size: .82rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Ranked list */
.rank-list {
  list-style: none; margin: 0; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.rank-row a {
  display: grid; grid-template-columns: 26px 44px 1fr auto; align-items: center; gap: 12px;
  padding: 10px; border-radius: var(--r-sm); color: var(--text); text-decoration: none;
}
.rank-row a:hover { background: var(--surface-2); }
.rank-num { font-weight: 800; font-size: 1.05rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.rank-row:nth-child(-n+3) .rank-num { color: var(--brand); }
.rank-body { min-width: 0; display: flex; flex-direction: column; }
.rank-title { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rank-meta { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-views { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-views .icon { width: 15px; height: 15px; }

/* Thumbnails */
.thumb {
  position: relative; overflow: hidden; aspect-ratio: 3 / 4;
  background: var(--surface-2); border-radius: var(--r-xs); border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.thumb-empty { display: grid; place-items: center; color: var(--muted); }
.thumb-empty .icon { width: 40%; height: 40%; opacity: .6; }
.thumb-sm { width: 44px; border-radius: 6px; }

/* Document cards: horizontal rows on phones, tiles on larger screens */
.card-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.card-list { display: grid; gap: 10px; }
.doc-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s, border-color .2s;
}
.doc-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.doc-card-link { display: grid; grid-template-columns: 76px 1fr; gap: 14px; padding: 12px; color: var(--text); text-decoration: none !important; }
.doc-card-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-card-body .pill { align-self: flex-start; }
.doc-card-title {
  margin: 2px 0 0; font-size: .98rem; font-weight: 650; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-card-meta, .doc-card-foot, .result-meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: .8rem; color: var(--muted);
}
.doc-card-meta span, .doc-card-foot span, .result-meta span { display: inline-flex; align-items: center; gap: 4px; }
.doc-card-meta .icon, .doc-card-foot .icon, .result-meta .icon { width: 14px; height: 14px; }
.doc-card-foot { margin-top: auto; padding-top: 2px; }

.city-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.city-tile {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-weight: 600; text-decoration: none !important;
}
.city-tile:hover { border-color: var(--brand); }
.city-tile .count { font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: var(--r-pill); }

.cta {
  display: grid; gap: 16px; padding: 24px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #00a29a));
  color: #fff;
}
.cta h2 { font-size: 1.35rem; }
.cta p { opacity: .9; margin: 0; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cta .btn-primary { background: #fff; color: #1d2a6b; }
.cta .btn-ghost { color: #fff; border-color: rgb(255 255 255 / .5); }
.cta .btn-ghost:hover { background: rgb(255 255 255 / .12); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 40px 20px; border: 1px dashed var(--border-strong); border-radius: var(--r); color: var(--muted);
}
.empty > .icon { width: 40px; height: 40px; opacity: .5; margin-bottom: 4px; }
.empty h3 { color: var(--text); margin: 0; }
.empty p { margin: 0 0 8px; }

/* ---------- Search ---------- */
.search-page { padding-top: 16px; padding-bottom: 48px; }
.search-form { display: grid; gap: 12px; margin-bottom: 16px; }
.search-bar .btn { display: none; }
.quick-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.quick-filters .qf:first-child { grid-column: 1 / -1; }
.qf {
  position: relative; display: grid; padding: 6px 0 0; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border-strong); min-width: 0;
}
.qf span { padding: 0 14px; font-size: .72rem; font-weight: 600; color: var(--muted); }
.qf select { border: 0; min-height: 34px; padding: 0 34px 6px 14px; background-color: transparent; font-weight: 600; font-size: 15px; border-radius: var(--r-sm); text-overflow: ellipsis; }
.qf select:focus { box-shadow: none; }
.qf:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.qf.is-set { border-color: var(--brand); background: var(--brand-soft); }
.qf.is-set span { color: var(--brand-soft-ink); }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.filters summary {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; font-weight: 600; list-style: none;
}
.filters summary::-webkit-details-marker { display: none; }
.filters[open] summary { border-bottom: 1px solid var(--border); }
.filter-grid { display: grid; gap: 12px; padding: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.filter-grid .field:nth-child(1), .filter-grid .field:nth-child(2) { grid-column: 1 / -1; }
.filter-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; }
.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.results-count { margin: 0; color: var(--muted); font-size: .92rem; }
.results-count strong { color: var(--text); }
.sort select { height: 38px; padding: 0 32px 0 12px; border-radius: var(--r-pill); font-size: .875rem; }
.results { display: grid; gap: 10px; }
.result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); transition: border-color .15s, box-shadow .15s; }
.result:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.result-link { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 14px; color: var(--text); text-decoration: none !important; }
.result-body { min-width: 0; }
.result-top { display: flex; align-items: center; gap: 8px; font-size: .78rem; margin-bottom: 6px; }
.result-title { margin: 0 0 6px; font-size: 1.02rem; }
.result-snippet { margin: 8px 0 0; font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.result-snippet mark { color: var(--text); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 28px; flex-wrap: wrap; }
.page-num, .page-step {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; text-decoration: none !important;
}
.page-num.is-current { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.page-step.is-disabled { opacity: .4; }
.page-gap { color: var(--muted); padding: 0 2px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: .875rem; font-weight: 600; }
.req { color: var(--danger); margin-left: 2px; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 16px; /* prevents iOS zoom */
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23778' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.hero-search input:focus, .search-bar input:focus, .header-search input:focus { box-shadow: none; }
.field-hint { margin: 0; font-size: .8rem; color: var(--muted); }
.field-error { margin: 0; font-size: .82rem; color: var(--danger); font-weight: 500; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.field-row { display: grid; gap: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.check.has-error { color: var(--danger); }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-actions .btn-primary { margin-left: auto; }
.radio-list { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.radio { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
.radio:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radio input { accent-color: var(--brand); width: 18px; height: 18px; margin: 0; }

.page-head { padding: 20px 0 12px; }
.page-head h1 { margin-bottom: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.back .icon { width: 16px; height: 16px; }
.rules-box { margin-bottom: 16px; }
.danger-zone { margin-top: 16px; border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.danger-zone h2 { color: var(--danger); margin-bottom: 4px; }
.danger-zone p { margin: 0; }
.danger-zone .btn { justify-self: start; }

/* Upload dropzone */
.dropzone { position: relative; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.dropzone-label {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 32px 16px; border: 2px dashed var(--border-strong); border-radius: var(--r); background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.dropzone.is-over .dropzone-label, .dropzone:hover .dropzone-label { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-error .dropzone-label { border-color: var(--danger); }
.dropzone-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.dropzone-icon .icon { width: 24px; height: 24px; }
.dropzone.has-file input[type=file] { display: none; }
.dropzone.has-file .dropzone-label { display: none; }
.dropzone-preview { display: flex; gap: 16px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.dropzone-preview canvas { width: 84px; height: auto; border-radius: 6px; box-shadow: var(--shadow); background: #fff; }
.preview-info { display: grid; gap: 2px; min-width: 0; }
.preview-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-info .link-btn { justify-self: start; margin-top: 6px; }
.progress { position: relative; height: 34px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--brand-soft); transition: width .2s; }
.progress span { position: relative; display: grid; place-items: center; height: 100%; font-size: .85rem; font-weight: 600; }

/* ---------- Auth ---------- */
.auth { display: grid; place-items: start center; padding-top: 24px; padding-bottom: 48px; }
.auth-card { width: 100%; max-width: 440px; padding: 28px 22px; }
.auth-card h1 { margin-top: 12px; }
.auth-logo .logo-mark { width: 44px; height: 44px; }
.auth-switch { text-align: center; margin: 16px 0 0; font-size: .92rem; color: var(--muted); }

/* ---------- Document page ---------- */
.doc-page { padding-top: 16px; padding-bottom: 48px; }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: .85rem; margin-bottom: 8px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs .icon { width: 14px; height: 14px; }
.doc-head h1 { margin-bottom: 6px; overflow-wrap: anywhere; }
.doc-sub { color: var(--muted); font-size: .92rem; margin-bottom: 14px; }
.doc-actions { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.doc-actions::-webkit-scrollbar { display: none; }
.doc-actions form { display: contents; }
.doc-actions .btn { min-height: 40px; padding: 0 14px; font-size: .88rem; }
.quota-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px;
  border-radius: var(--r-sm); background: var(--brand-soft); color: var(--brand-soft-ink); font-size: .88rem;
}
.quota-bar a { color: inherit; font-weight: 700; text-decoration: underline; }
.doc-layout { display: grid; gap: 16px; margin-top: 16px; }
.doc-details h2 { font-size: 1.1rem; }
.doc-details h3 { margin-top: 18px; font-size: .95rem; }
.doc-desc { white-space: pre-line; overflow-wrap: anywhere; }
.meta-list { display: grid; gap: 0; margin: 0; }
.meta-list > div { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meta-list > div:last-child { border-bottom: 0; }
.meta-list dt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; }
.meta-list dt .icon { width: 16px; height: 16px; }
.meta-list dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.meta-list dd a { color: var(--text); }
.doc-related h2 { font-size: 1.1rem; }

/* ---------- Reader ---------- */
.reader {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow);
  margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0; /* edge to edge on phones */
}
.reader-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.rgroup { display: flex; align-items: center; gap: 2px; }
.rgroup-zoom { display: none; }
.rbtn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--text); cursor: pointer;
}
.rbtn:hover { background: var(--surface-2); }
.rbtn[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-soft-ink); }
.rbtn:disabled { opacity: .35; cursor: default; }
.rbtn .icon { width: 20px; height: 20px; }
.page-input { display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.page-input input[type=text] {
  width: 46px; min-height: 32px; height: 32px; padding: 0 4px; text-align: center; border-radius: var(--r-xs); font-size: .9rem;
}
.rgroup-zoom select { width: auto; min-height: 34px; height: 34px; padding: 0 30px 0 10px; font-size: .85rem; border-radius: var(--r-xs); }
.reader-findbar {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.reader-findbar > .icon { color: var(--muted); width: 18px; height: 18px; }
.reader-findbar input[type=search] { flex: 1; min-width: 0; min-height: 36px; height: 36px; border-radius: var(--r-xs); padding: 0 10px; }
.find-count { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.find-count.not-found { color: var(--danger); }
.reader-body {
  position: relative; display: flex;
  height: calc(100dvh - var(--header-h) - var(--bottom-h) - 60px);
  min-height: 420px;
  background: var(--reader-bg);
}
.reader-stage { position: relative; flex: 1; min-width: 0; }
.reader-viewport { position: absolute; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; outline: 0; }
.reader-viewport .pdfViewer { padding: 12px 0; }
.reader-viewport .pdfViewer .page {
  margin: 0 auto 12px; border: 0; border-radius: 3px;
  box-shadow: 0 1px 3px rgb(0 0 0 / .12), 0 6px 18px rgb(0 0 0 / .08);
}
.reader-thumbs {
  position: absolute; z-index: 5; top: 0; bottom: 0; left: 0; width: 132px;
  overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.thumb-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 2px solid transparent;
  border-radius: var(--r-xs); background: transparent; cursor: pointer; color: var(--muted); font-size: .75rem;
}
.thumb-btn:hover { background: var(--surface-2); }
.thumb-btn.is-current { border-color: var(--brand); color: var(--brand); font-weight: 700; }
.thumb-btn canvas, .thumb-btn .thumb-ph { width: 100%; background: #fff; border-radius: 3px; box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
.reader-text {
  position: absolute; inset: 0; overflow: auto; padding: 16px 12px; outline: 0;
}
.text-page {
  max-width: 760px; margin: 0 auto 14px; padding: 20px 18px; background: var(--surface);
  border-radius: var(--r-sm); border: 1px solid var(--border);
}
.text-page h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.text-page pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: .95rem; line-height: 1.65; }
.text-page .empty-text { color: var(--muted); font-style: italic; }
.reader-loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  color: var(--muted); background: var(--reader-bg); font-size: .9rem; text-align: center; padding: 20px;
}
.reader-loading.is-error { color: var(--danger); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reader.is-expanded {
  position: fixed; inset: 0; z-index: 200; margin: 0; border-radius: 0; border: 0;
}
.reader.is-expanded .reader-body { height: auto; flex: 1; min-height: 0; }
body.reader-open { overflow: hidden; }

/* ---------- Dialog ---------- */
.dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgb(10 14 22 / .5); backdrop-filter: blur(2px); }
.dialog-body { display: grid; gap: 14px; padding: 22px; }
.dialog-body h2 { margin: 0; }
.dialog-body p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Gate (quota) ---------- */
.gate { display: grid; gap: 20px; margin-top: 24px; padding: 24px; }
.gate-preview .thumb { max-width: 160px; margin: 0 auto; filter: blur(3px); opacity: .7; }
.gate-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); margin-bottom: 8px; }
.gate-icon .icon { width: 24px; height: 24px; }
.gate-doc { padding: 12px 14px; background: var(--surface-2); border-radius: var(--r-sm); }
.gate-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }

/* ---------- Profile ---------- */
.profile { padding-top: 16px; padding-bottom: 48px; }
.profile-head { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-bottom: 16px; }
.profile-id h1 { margin: 0; font-size: 1.4rem; }
.profile-id p { margin: 0; overflow-wrap: anywhere; }
.profile-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.profile-stats div { display: flex; flex-direction: column-reverse; padding: 10px 12px; background: var(--surface-2); border-radius: var(--r-sm); }
.profile-stats dt { font-size: .75rem; color: var(--muted); }
.profile-stats dd { margin: 0; font-weight: 750; font-size: 1.2rem; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; white-space: nowrap;
  color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none;
}
.tabs a.is-active { color: var(--text); border-bottom-color: var(--brand); }
.tabs .count { font-size: .75rem; background: var(--surface-2); padding: 1px 7px; border-radius: var(--r-pill); }
.settings { display: grid; gap: 16px; max-width: 640px; }
.settings .danger-zone { margin-top: 0; }

/* ---------- Admin ---------- */
.admin { padding-bottom: 48px; }
.admin-list { display: grid; gap: 12px; }
.admin-item { display: grid; gap: 10px; }
.admin-item p { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-doc { display: flex; gap: 12px; align-items: center; color: var(--text); }
.admin-doc > span { display: grid; min-width: 0; }
.admin-details { color: var(--muted); font-size: .9rem; white-space: pre-line; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.plain-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }

/* ---------- Prose & errors ---------- */
.prose { margin-top: 20px; margin-bottom: 48px; }
.prose h2 { margin-top: 1.4em; }
.prose li { margin-bottom: .4em; }
.prose .notice { margin: 12px 0; }
.error-card { margin-top: 32px; background: var(--surface); border-style: solid; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--brand); letter-spacing: -.04em; line-height: 1; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 48px; padding: 40px 0 0; }
.footer-inner { display: grid; gap: 32px; }
.footer-brand { display: grid; gap: 12px; justify-items: start; max-width: 340px; }
.footer-brand .brand { font-size: 1.1rem; }
.footer-brand p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.footer-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; }
.footer-cols > div { display: grid; gap: 10px; align-content: start; }
.footer-cols h2 { margin: 0 0 2px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.footer-cols a { color: var(--text); font-size: .92rem; font-weight: 500; text-decoration: none; justify-self: start; }
.footer-cols a:hover { color: var(--brand); text-decoration: underline; }
.footer-cols p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.footer-bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  margin-top: 32px; padding-top: 18px; padding-bottom: 22px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: .8rem;
}
.footer-bottom span { display: inline-flex; align-items: center; gap: 6px; }
.footer-bottom .icon { width: 14px; height: 14px; }

/* =========================================================================
   Larger screens
   ========================================================================= */
@media (min-width: 480px) {
  .hide-xs { display: inline-flex !important; }
  .search-bar .btn { display: inline-flex; }
  .city-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .card-grid .doc-card-link { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; height: 100%; }
  .card-grid .doc-card { overflow: hidden; }
  .card-grid .doc-card .thumb { aspect-ratio: 16 / 10; border: 0; border-radius: 0; border-bottom: 1px solid var(--border); }
  .card-grid .doc-card-body { padding: 14px 16px 16px; }
  .card-grid .doc-card:hover { transform: translateY(-2px); }
  .reader { margin: 0; border-radius: var(--r); border: 1px solid var(--border); }
  .rgroup-zoom { display: flex; }
  .reader-text { padding: 24px; }
  .text-page { padding: 28px 32px; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid .field:nth-child(1), .filter-grid .field:nth-child(2) { grid-column: auto; }
  .quick-filters { grid-template-columns: 2fr 1fr 1fr; }
  .quick-filters .qf:first-child { grid-column: auto; }
  .gate { grid-template-columns: 180px 1fr; align-items: center; padding: 32px; }
  .cta { grid-template-columns: 1fr auto; align-items: center; padding: 32px; }
  .result-link { grid-template-columns: 84px 1fr; padding: 16px; gap: 18px; }
  .profile-head { grid-template-columns: auto 1fr auto; }
  .profile-stats { grid-column: auto; display: flex; gap: 8px; }
}

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .only-mobile { display: none !important; }
  .only-desktop { display: inline-flex !important; }
  .header-search {
    display: flex; align-items: center; gap: 8px; flex: 1; max-width: 380px; margin-left: 12px;
    height: 40px; padding: 0 14px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border);
  }
  .header-search:focus-within { border-color: var(--brand); }
  .header-search .icon { color: var(--muted); width: 18px; height: 18px; }
  .header-search input[type=search] { border: 0; outline: 0; background: transparent; min-height: 0; height: 38px; padding: 0; font-size: .92rem; }
  .hero { padding: 64px 0 48px; }
  .hero-search { padding-left: 20px; }
  .hero-search input { height: 50px; font-size: 1.05rem; }
  .hero-search .btn { padding: 0 26px; min-height: 50px; }
  .hero-stats { gap: 44px; }
  .hero-stats dd { font-size: 1.9rem; }
  .home-modules { gap: 48px; }
  .reader-body { height: calc(100vh - var(--header-h) - 80px); min-height: 520px; }
  .reader-thumbs { position: relative; box-shadow: none; width: 150px; flex: none; }
  .doc-actions { overflow: visible; flex-wrap: wrap; }
  .footer-inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
  .footer-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .auth { padding-top: 48px; }
  .auth-card { padding: 36px 32px; }
}

@media (min-width: 960px) {
  .header-nav { display: flex; gap: 4px; margin-left: 8px; }
  .header-nav a {
    padding: 8px 12px; border-radius: var(--r-pill); color: var(--muted); font-weight: 600; font-size: .92rem; text-decoration: none;
  }
  .header-nav a:hover { color: var(--text); background: var(--surface-2); }
  .header-nav a.is-active { color: var(--text); background: var(--surface-2); }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .city-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .doc-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .doc-related .card-list .doc-card-link { grid-template-columns: 64px 1fr; }
  .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .search-form { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 1140px) {
  .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .home-modules > .module:first-child .rank-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: repeat(4, auto); grid-auto-flow: column; column-gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); z-index: 300;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: var(--r-pill); background: var(--text); color: var(--bg);
  font-size: .9rem; font-weight: 600; box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 768px) { .toast { bottom: 24px; } }

.theme-toggle { color: var(--text); font-size: .92rem; }
.theme-toggle .icon { width: 16px; height: 16px; }

/* ---------- Admin dashboard ---------- */
.admin-privacy { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 16px; }
.admin-privacy .icon { width: 16px; height: 16px; margin-top: 2px; flex: none; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; }
.stat-tile { padding: 14px 16px; display: grid; gap: 2px; align-content: start; }
.stat-tile dt { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat-tile dd { margin: 0; font-size: 1.55rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { margin: 0; font-size: .78rem; color: var(--muted); }
.chart-grid, .bar-grid { display: grid; gap: 12px; margin-bottom: 12px; }
.chart-card { margin: 0; padding: 16px; min-width: 0; }
.chart-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chart-title { font-size: .92rem; font-weight: 650; margin: 0; }
.chart-value { margin-left: auto; font-size: 1.25rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.chart-sub { font-size: .78rem; color: var(--muted); }
.chart-legend { list-style: none; display: flex; gap: 14px; margin: -2px 0 10px; padding: 0; font-size: .8rem; color: var(--muted); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.s1 { background: var(--series-1); }
.s2 { background: var(--series-2); }
.cc { position: relative; height: 150px; margin-left: 34px; }
.cc-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.cc-tick { position: relative; border-top: 1px solid var(--grid); height: 0; }
.cc-tick span { position: absolute; right: calc(100% + 6px); top: -8px; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cc-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.cc-col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; padding: 0 1px; cursor: default; }
.cc-col:hover, .cc-col.is-hover { background: color-mix(in srgb, var(--text) 5%, transparent); border-radius: 4px 4px 0 0; }
.cc-stack { width: 100%; max-width: 24px; display: flex; flex-direction: column-reverse; gap: 2px; }
.cc-seg { flex-basis: 0; min-height: 2px; }
.cc-seg.is-top { border-radius: 4px 4px 0 0; }
.cc-x { display: flex; justify-content: space-between; margin: 6px 0 0 34px; font-size: .72rem; color: var(--muted); }
.chart-note { margin: 10px 0 0; font-size: .78rem; color: var(--muted); }
.chart-table { margin-top: 10px; font-size: .82rem; }
.chart-table summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.table-wrap { max-height: 240px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: var(--r-xs); }
.chart-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border); }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; }
.chart-tip {
  position: fixed; z-index: 400; pointer-events: none; padding: 8px 10px; border-radius: var(--r-xs);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: .8rem; line-height: 1.45; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart-tip strong { display: block; margin-bottom: 2px; }
.bar-card { padding: 16px; min-width: 0; }
.bar-card .chart-title { margin-bottom: 12px; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bar-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .85rem; }
.bl-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-label a { color: var(--text); }
.bl-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.bl-track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); }
.bl-bar { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }
.system-card { padding: 16px; }
.system-card .chart-title { margin-bottom: 8px; }
.kv { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chart-grid, .bar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid > :first-child { grid-column: 1 / -1; }
  .chart-grid:not(.chart-pair) > :first-child .cc { height: 200px; }
  .kv { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 32px; }
  .kv > div:nth-last-child(2) { border-bottom: 0; }
}
@media (min-width: 1140px) {
  .chart-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bar-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Honeypot field (hidden from humans, filled by bots) */
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; opacity: 0; }
.mono { font-family: var(--mono); font-size: 14px !important; }

/* User menu */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu[open] summary { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg);
  display: grid; gap: 2px;
}
.menu-head { display: grid; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r-xs);
  background: none; color: var(--text); font-size: .92rem; font-weight: 500; text-align: left; cursor: pointer; text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu .icon { width: 18px; height: 18px; color: var(--muted); }
.menu form { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.menu-danger, .menu-danger .icon { color: var(--danger) !important; }
.profile-logout { grid-column: 1 / -1; }
@media (min-width: 640px) { .profile-logout { grid-column: auto; } }

/* Donate */
.donate { padding-bottom: 48px; }
.donate-head { max-width: 680px; }
.coin-grid { display: grid; gap: 14px; }
.coin { display: grid; gap: 14px; justify-items: center; text-align: center; }
.coin-head { display: flex; align-items: center; gap: 10px; justify-self: stretch; }
.coin-head h2 { margin: 0; font-size: 1.1rem; }
.coin-badge { display: inline-grid; place-items: center; min-width: 44px; height: 28px; padding: 0 8px; border-radius: var(--r-pill); font-size: .75rem; font-weight: 800; color: #fff; }
.coin-btc { background: #f7931a; }
.coin-eth { background: #627eea; }
.coin-xmr { background: #ff6600; }
.coin-qr { width: 200px; max-width: 100%; padding: 10px; background: #fff; border-radius: var(--r-sm); border: 1px solid var(--border); }
.coin-qr svg { width: 100%; height: auto; }
.coin-addr {
  display: block; width: 100%; padding: 10px 12px; border-radius: var(--r-xs); background: var(--surface-2);
  font-size: .8rem; line-height: 1.5; word-break: break-all; text-align: left; user-select: all;
}
.coin-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.donate-note { margin-top: 16px; }
.donate-form { max-width: 720px; }
.donate-form h2 { margin-bottom: 4px; }

/* Privacy */
.privacy .lead { font-size: 1.05rem; }
.privacy-grid { display: grid; gap: 10px; margin: 20px 0 8px; }
.privacy-item { display: flex; gap: 12px; padding: 14px; border-radius: var(--r-sm); background: var(--success-soft); }
.privacy-item > span { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--surface); color: var(--success-ink); }
.privacy-item > span .icon { width: 16px; height: 16px; }
.privacy-item p { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
@media (min-width: 640px) {
  .privacy-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .coin-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

/* ---------- Accounts, donors, scheduling ---------- */
.btn.is-disabled { opacity: .55; }
.pill-muted { background: var(--surface-2); color: var(--muted); }
.pill-row { display: inline-flex; gap: 6px; flex-wrap: wrap; align-self: flex-start; }
.pill-early { display: inline-flex; align-items: center; gap: 4px; background: var(--warn-soft); color: var(--warn-ink); }
.pill-early .icon { width: 12px; height: 12px; }
.rank-title .pill-early { vertical-align: 1px; margin-right: 2px; }
.rank-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill);
  background: #fff1dc; border: 1px solid #f6d9a8; color: #8a3b12; font-size: .78rem; font-weight: 700; white-space: nowrap; line-height: 1.4;
}
:root[data-theme="dark"] .rank-pill { background: #33240e; border-color: #5a4018; color: #ffcf99; }
.rank-pill .icon { width: 13px; height: 13px; }
.notice-early { background: var(--warn-soft); color: var(--warn-ink); margin: 0 0 12px; }

.why-account { padding: 14px 16px; border-radius: var(--r-sm); background: var(--brand-soft); color: var(--brand-soft-ink); margin: 4px 0 18px; font-size: .9rem; }
.why-account strong { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.why-account strong .icon { width: 16px; height: 16px; }
.why-account p { margin: 0 0 6px; }
.why-account ul { margin: 0; padding-left: 18px; }
.why-account a { color: inherit; font-weight: 700; text-decoration: underline; }

.recovery-card { max-width: 520px; display: grid; gap: 14px; }
.recovery-card h1 { margin-bottom: 0; }
.recovery-box { display: grid; gap: 2px; padding: 16px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); }
.recovery-box strong { margin-bottom: 8px; }
.recovery-code {
  font-family: var(--mono); font-size: clamp(1rem, 4.6vw, 1.35rem); font-weight: 700; letter-spacing: .06em;
  background: none; padding: 0; word-break: break-all; user-select: all;
}
.recovery-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.profile-badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 0 !important; }
.limits { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-bottom: 16px; padding: 14px 18px; }
.limit { display: grid; }
.limit strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.limits .btn { margin-left: auto; }
.limits-unlimited { display: flex; gap: 12px; align-items: flex-start; background: var(--success-soft); border-color: transparent; }
.limits-unlimited > .icon { color: var(--success-ink); margin-top: 2px; }
.limits-unlimited p { margin: 2px 0 0; }

.perks { display: grid; gap: 20px; margin-bottom: 16px; }
.perks h2 { font-size: 1.05rem; }
.perk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.perk-list li { display: flex; gap: 8px; align-items: flex-start; }
.perk-list .icon { color: var(--success-ink); width: 18px; height: 18px; margin-top: 2px; }
.rank-ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-ladder li { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; font-size: .85rem; }
.rank-ladder li > .muted { text-align: right; white-space: nowrap; }
.claim-layout { display: grid; gap: 16px; margin-top: 24px; }
.claim-card h2, .claim-list h2 { font-size: 1.1rem; margin-bottom: 4px; }
.claim-list ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.claim-list li { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; }
.claim-main { display: grid; min-width: 0; }
.claim-main code { background: none; padding: 0; font-size: .82rem; }
.claim-status { grid-column: 2; font-size: .8rem; font-weight: 600; }
.status-pending { color: var(--warn-ink); }
.status-approved { color: var(--success-ink); }
.status-rejected { color: var(--danger); }
.claim-list .coin-badge, .claim-item .coin-badge { min-width: 40px; height: 22px; font-size: .68rem; }

.schedule { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px 16px; margin: 0; display: grid; gap: 10px; background: var(--surface-2); }
.schedule legend { display: flex; align-items: center; gap: 6px; font-weight: 650; padding: 0 6px; }
.schedule legend .icon { width: 16px; height: 16px; color: var(--brand); }
.schedule p { margin: 0; }

.inline-form { display: flex; gap: 6px; align-items: center; }
.eur-input { width: 96px !important; min-height: 36px !important; padding: 6px 10px !important; }
.kv-compact { grid-template-columns: 1fr !important; }
.kv-compact > div { padding: 6px 0; }
.kv-compact dd { font-weight: 500; min-width: 0; overflow-wrap: anywhere; text-align: right; }
.mono-link { font-family: var(--mono); font-size: .78rem; word-break: break-all; }
.claim-item p { gap: 10px; }
.user-search { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.user-search input { flex: 1; min-width: 180px; }
.user-search select { width: auto; }
.user-list { display: grid; gap: 10px; }
.user-row { display: grid; gap: 12px; padding: 14px 16px; }
.user-row.is-banned { opacity: .75; }
.user-id { display: flex; gap: 12px; align-items: flex-start; }
.user-id > div { display: grid; gap: 2px; min-width: 0; }
.user-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.plain-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.plain-table th, .plain-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.plain-table th { background: var(--surface-2); font-weight: 600; }
.scheduled-card { margin-bottom: 12px; }
@media (min-width: 640px) {
  .perks { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .user-row { grid-template-columns: 1fr auto; align-items: center; }
}
@media (min-width: 960px) {
  .claim-layout { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
}

/* ---------- Requests / public profiles ---------- */
.contrib-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill);
  background: #e3f6ec; border: 1px solid #b9e6cf; color: #0b5d3b; font-size: .78rem; font-weight: 700; white-space: nowrap; line-height: 1.4;
}
:root[data-theme="dark"] .contrib-pill { background: #10301f; border-color: #1d5136; color: #8ee6b9; }
.contrib-pill .icon { width: 13px; height: 13px; }
.requests-page, .request-page { padding-top: 16px; padding-bottom: 48px; }
.requests-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; }
.requests-head p { max-width: 680px; margin: 0; }
.requests-layout { display: grid; gap: 20px; align-items: start; }
.request-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.request-filters select { width: auto; min-height: 40px; }
.request-grid { display: grid; gap: 12px; }
.request-card { padding: 0; transition: box-shadow .2s, border-color .2s; }
.request-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.request-link { display: grid; gap: 8px; padding: 16px; color: var(--text); text-decoration: none !important; height: 100%; }
.request-link h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
.request-top { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.request-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: .8rem; color: var(--muted); }
.request-meta span { display: inline-flex; align-items: center; gap: 4px; }
.request-meta .icon { width: 14px; height: 14px; }
.request-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0; font-size: .8rem; margin-top: auto; }
.votes { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; color: var(--brand); }
.votes .icon { width: 16px; height: 16px; }
.req-status.status-open { background: var(--brand-soft); color: var(--brand-soft-ink); }
.req-status.status-review { background: var(--warn-soft); color: var(--warn-ink); }
.req-status.status-fulfilled { background: var(--success-soft); color: var(--success-ink); }
.req-status.status-closed { background: var(--surface-2); color: var(--muted); }
.ranks-box h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.ranks-box h2 .icon { color: var(--success-ink); }
.request-head { display: grid; gap: 8px; margin: 8px 0 16px; }
.request-head h1 { margin: 0; }
.request-head p { margin: 0; }
.request-layout { display: grid; gap: 16px; align-items: start; }
.request-actions { display: grid; gap: 12px; }
.vote-card { display: grid; justify-items: center; gap: 2px; text-align: center; }
.vote-count { font-size: 2rem; font-weight: 800; line-height: 1; }
.vote-card form, .vote-card .btn { width: 100%; margin-top: 10px; }
.fulfil-card { display: grid; gap: 10px; }
.fulfil-card h2 { font-size: 1.05rem; margin: 0; }
.fulfil-card p { margin: 0; }
.link-existing summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--muted); }
.link-existing form { margin-top: 10px; }
.fulfil-banner { margin-bottom: 16px; }
.fulfil-banner a { color: inherit; font-weight: 700; text-decoration: underline; }
.request-box { display: grid; gap: 4px; margin-bottom: 16px; border-color: color-mix(in srgb, var(--success-ink) 30%, var(--border)); }
.request-box h2 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin: 0; }
.request-box h2 .icon { color: var(--success-ink); }
.request-box p { margin: 0; }
.notice-success { background: var(--success-soft); color: var(--success-ink); margin-bottom: 16px; }
.notice-success a { color: inherit; font-weight: 700; text-decoration: underline; }
.notice-early a { color: inherit; }
.note-input { width: 220px !important; min-height: 36px !important; padding: 6px 10px !important; }
.doc-main { display: grid; gap: 0; min-width: 0; }
.uploader { font-weight: 600; color: var(--text); }
.rank-pill-sm { padding: 1px 8px; font-size: .7rem; vertical-align: 1px; }
.rank-pill-sm .icon { width: 11px; height: 11px; }
.badge-list { display: grid; gap: 8px; }
.funder-badge { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.funder-badge:hover { border-color: var(--brand); }
.funder-badge > span:last-child { display: grid; min-width: 0; }
.fb-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #dff7ec, #dbeafe); color: #0b5d3b; flex: none; }
.fb-icon .icon { width: 16px; height: 16px; }
.public-profile .profile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) {
  .request-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .badge-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .requests-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .request-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .home-modules .request-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .badge-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* =========================================================================
   Removal requests, upload review, case linking, statistics, comments, notes
   ========================================================================= */
.pre { white-space: pre-line; overflow-wrap: anywhere; }
.small { font-size: .85rem; }
.avatar-sm { width: 28px; height: 28px; font-size: .8rem; flex: none; }
.segmented-links { display: inline-flex; gap: 4px; padding: 3px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); }
.segmented-links a { padding: 6px 14px; border-radius: var(--r-pill); font-size: .85rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.segmented-links a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.radio-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.radio-inline .radio { padding: 6px 10px; font-size: .88rem; }
.radio-inline legend { margin-bottom: 4px; }
fieldset[hidden] { display: none; }
.is-muted { opacity: .7; }

/* Removal requests */
.removal-disclaimer ul { margin: 6px 0; padding-left: 20px; }
.removal-disclaimer p { margin: 6px 0 0; }
.removal-reasons legend { margin-bottom: 8px; }
.removal-reasons > p { margin: 8px 0 2px; }
.removal-redirect p { margin: 6px 0 0; }
.removal-report-links { display: flex; flex-wrap: wrap; gap: 6px; }
.removal-full { border: 0; padding: 0; margin: 0; display: grid; gap: 16px; min-width: 0; }
.char-count { margin: -10px 0 0; text-align: right; }
.char-count.is-ok { color: var(--success-ink); }
.removal-status { white-space: nowrap; }
.rs-open, .rs-info { background: var(--warn-soft); color: var(--warn-ink); }
.rs-hidden { background: var(--brand-soft); color: var(--brand-soft-ink); }
.rs-rejected { background: var(--surface-2); color: var(--muted); }
.rs-removed { background: var(--success-soft); color: var(--success-ink); }
.removal-link-box { display: grid; gap: 10px; margin-bottom: 16px; border-color: color-mix(in srgb, var(--success-ink) 35%, var(--border)); }
.removal-link-box h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.1rem; }
.removal-link-box h2 .icon { color: var(--success-ink); }
.removal-link-box p { margin: 0; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-size: .85rem; }
.removal-doc { display: block; }
.removal-docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.removal-body h4 { margin: 0 0 4px; font-size: .85rem; }
.removal-decide { border-top: 1px solid var(--border); padding-top: 12px; gap: 12px; }
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.thread-item { padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); max-width: 92%; }
.thread-item p { margin: 4px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.thread-item.from-admin { justify-self: end; background: var(--brand-soft); border-color: transparent; }
.thread-meta { font-size: .78rem; color: var(--muted); font-weight: 600; }
.removal-hint { margin: 10px 0 0; }

/* Upload review */
.review-grid { display: grid; gap: 14px; }
.review-thumb .thumb { width: 120px; aspect-ratio: 3 / 4; }
.review-meta h3 { margin: 0 0 4px; font-size: 1.05rem; }
.review-meta > p { margin: 0 0 8px; }
.review-excerpt summary { cursor: pointer; font-size: .85rem; color: var(--muted); }
.suggest-pair { display: grid; gap: 8px; }
.rejection p { margin: 4px 0 0; }
@media (min-width: 640px) {
  .review-grid { grid-template-columns: 120px 1fr; }
  .suggest-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Case timeline ("Asian vaiheet") */
.case-box { display: grid; gap: 12px; margin-top: 16px; }
.case-box h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.1rem; }
.case-box h2 .icon, .notes-card h2 .icon, .comments h2 .icon { color: var(--brand); }
.case-box h3 { font-size: .95rem; margin: 0 0 4px; }
.case-box p { margin: 0; }
.case-timeline { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; display: grid; gap: 4px; }
.case-timeline::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 2px; background: var(--border-strong); }
.case-timeline li { position: relative; display: grid; padding: 8px 10px; border-radius: var(--r-xs); }
.case-timeline li::before {
  content: ""; position: absolute; left: -18px; top: 14px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.case-timeline li.is-current { background: var(--brand-soft); }
.case-timeline li.is-current::before { background: var(--brand); border-color: var(--brand); }
.ct-stage { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); }
.ct-title { font-weight: 600; }
.case-manage { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.case-stage-form select { width: auto; min-height: 34px; height: 34px; padding: 0 30px 0 10px; font-size: .85rem; border-radius: var(--r-xs); }
.case-suggest-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.case-suggest .plain-list { padding: 0; list-style: none; }
.case-link-form summary { cursor: pointer; font-size: .9rem; color: var(--brand); font-weight: 600; }
.case-link-form form { margin-top: 10px; display: grid; gap: 10px; }

/* Public statistics and landing pages */
.stats-page .chart-grid, .landing-page .chart-grid { margin-bottom: 16px; }
a.cc-col { cursor: pointer; }
a.cc-col:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Comments */
.comments { display: grid; gap: 14px; margin-top: 16px; }
.comments h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.1rem; }
.comments h2 .count { font-size: .75rem; background: var(--surface-2); padding: 1px 8px; border-radius: var(--r-pill); color: var(--muted); }
.comment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 16px); }
.comment:last-child { border-bottom: 0; }
.comment:target { background: var(--brand-soft); border-radius: var(--r-xs); padding-inline: 10px; }
.comment.is-hidden { opacity: .6; }
.comment-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.comment-author { font-weight: 700; color: var(--text); }
.comment-body { margin: 6px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.comment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 6px; }
.comment-report summary { list-style: none; cursor: pointer; color: var(--muted); }
.comment-report summary::-webkit-details-marker { display: none; }
.comment-report[open] { flex-basis: 100%; }
.comment-report-form { display: grid; gap: 8px; margin-top: 8px; }
.comment-form { display: grid; gap: 10px; }
.comment-form .field-hint { display: flex; gap: 6px; align-items: flex-start; }
.comment-form .field-hint .icon { flex: none; margin-top: 2px; }
.inline-settings { display: grid; gap: 12px; margin-bottom: 16px; }
.inline-settings h2 { margin: 0; font-size: 1.05rem; }

/* Private notes */
.notes-card { display: grid; gap: 10px; margin-bottom: 16px; }
.notes-card h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0; font-size: 1.1rem; }
.notes-card h2 .pill { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; }
.notes-card h2 .pill .icon { width: 12px; height: 12px; color: inherit; }
.notes-card form { display: grid; gap: 8px; }
.notes-card textarea { min-height: 96px; }
.notes-actions { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.note-fab { position: absolute; z-index: 8; box-shadow: var(--shadow-lg); }
.note-fab[hidden] { display: none; }
.rbtn.has-notes { color: var(--brand); }
.reader-notes {
  position: absolute; z-index: 6; top: 0; bottom: 0; right: 0; width: min(320px, 88%);
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.reader-notes[hidden] { display: none; }
.rn-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); }
.rn-head strong { flex: 1; }
.rn-hint { margin: 0; padding: 12px 14px; }
.rn-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; display: grid; gap: 8px; align-content: start; flex: 1; }
.rn-item { border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.rn-go { display: grid; gap: 4px; width: 100%; padding: 10px 12px 4px; text-align: left; border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit; }
.rn-go:hover { background: var(--surface-2); border-radius: var(--r-sm) var(--r-sm) 0 0; }
.rn-page { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); }
.rn-go q { font-size: .85rem; color: var(--muted); font-style: italic; border-left: 3px solid var(--mark); padding-left: 8px; quotes: none; }
.rn-go p { margin: 0; font-size: .9rem; white-space: pre-line; overflow-wrap: anywhere; }
.rn-actions { display: flex; gap: 12px; padding: 4px 12px 8px; }
.nd-quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--mark); background: var(--surface-2); border-radius: 0 var(--r-xs) var(--r-xs) 0; font-size: .9rem; max-height: 8em; overflow: auto; }
::highlight(rk-notes) { background-color: rgb(255 200 0 / .45); }
:root[data-theme="dark"] ::highlight(rk-notes) { background-color: rgb(255 200 0 / .35); }
.notes-export { display: flex; flex-wrap: wrap; gap: 8px; }
.noted-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.noted-item { padding: 0; }
.noted-item a { display: flex; gap: 12px; padding: 12px; color: var(--text); text-decoration: none; }
.noted-item a > span { display: grid; gap: 2px; min-width: 0; }
.noted-preview { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.notes-tab { display: grid; gap: 12px; }
@media (min-width: 768px) {
  .reader-notes { position: relative; box-shadow: none; width: 300px; flex: none; }
}
.stats-page .module, .landing-page .module { margin-top: 28px; }

.flash-info { background: var(--brand-soft); color: var(--brand-soft-ink); }
.flash-info a { color: inherit; font-weight: 700; text-decoration: underline; }
.review-box p { margin: 8px 0 0; }
.review-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 10px; }
.review-reject summary { list-style: none; }
.review-reject summary::-webkit-details-marker { display: none; }
.review-reject[open] { flex-basis: 100%; }
.review-reject form { margin-top: 10px; display: grid; gap: 8px; color: var(--text); }

/* Admin overview */
.overview-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.overview-grid .stat-grid { margin: 0; }
.todo-card { display: grid; gap: 10px; align-content: start; }
.todo-card h2 { margin: 0; font-size: 1.05rem; }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; }
.todo-list a { display: flex; align-items: center; gap: 10px; padding: 10px 4px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.todo-list li:last-child a { border-bottom: 0; }
.todo-list a:hover .todo-label { color: var(--brand); }
.todo-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--warn-soft); color: var(--warn-ink); flex: none; }
.todo-icon .icon { width: 16px; height: 16px; }
.todo-label { flex: 1; font-weight: 600; font-size: .92rem; }
.todo-count { font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface-2); padding: 2px 10px; border-radius: var(--r-pill); font-size: .85rem; }
.todo-list a > .icon:last-child { color: var(--muted); width: 16px; height: 16px; }
.todo-empty { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--success-ink); font-weight: 600; }
.stat-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; align-content: start; }
.bar-grid-2 { margin-top: 16px; }
@media (min-width: 960px) {
  .overview-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bar-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (min-width: 768px) {
  .chart-grid.chart-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid.chart-pair > :first-child { grid-column: auto; }
}

/* Case strip above the reader */
.case-strip { display: grid; gap: 8px; margin: 0 0 12px; }
.case-strip-label { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.case-strip-label .icon { width: 15px; height: 15px; color: var(--brand); }
.case-strip ol { list-style: none; margin: 0; padding: 0 0 4px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; }
.case-strip li { flex: none; }
.cs-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none !important;
}
.cs-item > span:last-child { display: grid; line-height: 1.25; }
.cs-item strong { font-size: .88rem; }
.cs-item small { color: var(--muted); font-size: .75rem; }
a.cs-item:hover { border-color: var(--brand); }
.cs-item.is-current { border-color: var(--brand); background: var(--brand-soft); }
.cs-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); font-size: .8rem; font-weight: 700; color: var(--muted); }
.cs-item.is-current .cs-num { background: var(--brand); color: var(--brand-ink); }

/* Extra PDFs in the upload form */
.extra-docs { display: grid; gap: 14px; padding-top: 16px; border-top: 1px solid var(--border); }
.extra-docs[hidden] { display: none; }
.extra-head h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 1.05rem; }
.extra-head h2 .icon { color: var(--brand); }
.extra-head p { margin: 0; }
.extra-list { display: grid; gap: 14px; }
.extra-doc { display: grid; gap: 14px; margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.extra-doc-head { display: flex; justify-content: space-between; align-items: center; }
.extra-file-row { display: flex; gap: 12px; align-items: flex-start; }
.extra-file-row input[type=file] { max-width: 100%; }
.extra-thumb { width: 64px; height: auto; border-radius: 4px; box-shadow: 0 1px 3px rgb(0 0 0 / .15); background: #fff; flex: none; }
.extra-thumb[hidden] { display: none; }
[data-add-extra] { justify-self: start; }
[data-add-extra][hidden] { display: none; }
.review-box a { font-weight: 700; text-decoration: underline; }
.review-reject form .btn { justify-self: start; }
.review-reject form .field { max-width: 520px; }

/* ---------- Mobile overflow fixes ---------- */
html, body { max-width: 100%; overflow-x: clip; }
main, .container, .module, .home-modules, .home-modules > * { min-width: 0; }
.home-modules { grid-template-columns: minmax(0, 1fr); }
.city-tile > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.city-tile .count { flex: none; }
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented button { white-space: nowrap; }
.segmented-links { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented-links a { white-space: nowrap; }
.tabs { max-width: 100%; }
.result-body, .doc-card-body { overflow-wrap: anywhere; }
.result-meta, .doc-card-meta { min-width: 0; }
img, svg, video, canvas { max-width: 100%; }
.requests-layout, .request-grid { grid-template-columns: minmax(0, 1fr); }
.requests-layout > *, .request-grid > * { min-width: 0; }
@media (min-width: 640px) { .request-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .requests-layout { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (min-width: 1140px) { .home-modules .request-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pill-row { max-width: 100%; }
.pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.result-meta { overflow-wrap: anywhere; }
.request-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.request-filters select { width: 100%; max-width: 100%; min-width: 0; }
@media (min-width: 640px) { .request-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Search: group by case */
.group-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.group-toggle input { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); }
.results-bar { flex-wrap: wrap; }
.result-case { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: .82rem; font-weight: 600; }
.result-case .icon { width: 14px; height: 14px; }

/* Document types: "Sisältää myös" checkboxes and document page pills */
.contains-field { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.contains-field legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: .35rem .9rem; }
.doc-types { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .25rem 0 .5rem; }
/* Document type tag next to the crime type tag */
.pill-type { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.result-top { flex-wrap: wrap; row-gap: 4px; }
