:root,
html[data-theme="dark"] {
  --bg: #0e1117;
  --bg-elevated: #161b22;
  --bg-card: #1c2128;
  --bg-hover: #22272e;
  --border: #30363d;
  --border-soft: #21262d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #2f81f7;
  --accent-soft: rgba(47, 129, 247, 0.15);
  --green: #3fb950;
  --green-soft: rgba(63, 185, 80, 0.15);
  --orange: #d29922;
  --orange-soft: rgba(210, 153, 34, 0.15);
  --red: #f85149;
  --purple: #a371f7;
  --purple-soft: rgba(163, 113, 247, 0.15);
  --cyan: #39d2c0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --nav-h: 60px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --nav-bg: rgba(22, 27, 34, 0.92);
  --input-bg: #0e1117;
  --code-bg: #0e1117;
}

html[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #eef2f6;
  --border: #d0d7de;
  --border-soft: #eaeef2;
  --text: #1f2328;
  --text-muted: #656d76;
  --text-dim: #8b949e;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.12);
  --green: #1a7f37;
  --green-soft: rgba(26, 127, 55, 0.12);
  --orange: #9a6700;
  --orange-soft: rgba(154, 103, 0, 0.12);
  --red: #cf222e;
  --purple: #8250df;
  --purple-soft: rgba(130, 80, 223, 0.12);
  --cyan: #1192aa;
  --shadow: 0 8px 24px rgba(31, 35, 40, 0.08);
  --nav-bg: rgba(255, 255, 255, 0.92);
  --input-bg: #f6f8fa;
  --code-bg: #eef2f6;
}

html[data-theme="light"] .topnav {
  background: var(--nav-bg);
}

html[data-theme="light"] .input,
html[data-theme="light"] .select {
  background: var(--input-bg);
  color: var(--text);
}

html[data-theme="light"] .brand-sub {
  color: var(--text-muted);
}

html[data-theme="light"] .theme-icon-moon { display: none; }
html[data-theme="light"] .theme-icon-sun { display: inline; }
html[data-theme="dark"] .theme-icon-moon { display: inline; }
html[data-theme="dark"] .theme-icon-sun { display: none; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: 0.15s ease;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--text-dim);
}

.theme-icon {
  pointer-events: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

/* ===== NAV ===== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: var(--nav-bg, rgba(22, 27, 34, 0.92));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topnav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topnav-brand:hover {
  text-decoration: none;
  color: #fff;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2f81f7, #a371f7);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.brand-sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: -2px;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-link.active {
  color: #fff;
  background: var(--accent-soft);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ===== LAYOUT ===== */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.page-wide {
  max-width: 1400px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #388bfd;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: #fff;
  border-color: var(--text-dim);
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.btn-soft:hover {
  background: rgba(47, 129, 247, 0.25);
  color: #79b8ff;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  color: #ff7b72;
  border-color: rgba(248, 81, 73, 0.35);
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.28);
  color: #ffa198;
  border-color: rgba(248, 81, 73, 0.5);
}

/* ===== SETTINGS ===== */
.settings-section {
  margin-bottom: 2rem;
}

.settings-form {
  margin-bottom: 0;
}

.settings-form-card {
  max-width: 920px;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.settings-form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
  align-items: start;
}

.settings-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
}

.field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.field-checks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.15rem;
}

.field-label-like {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.check-label input {
  accent-color: var(--accent);
}

.code-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.alert-ok {
  background: var(--green-soft);
  border: 1px solid rgba(63, 185, 80, 0.35);
  color: var(--green);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

.data-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.td-strong {
  font-weight: 600;
}

.td-muted {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.td-entity {
  max-width: 220px;
  word-break: break-all;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.td-flags {
  white-space: nowrap;
}

.td-actions {
  white-space: nowrap;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.inline-form {
  display: inline;
}

.settings-legend {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-danger-zone {
  margin-top: 2rem;
  max-width: 920px;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius);
  background: rgba(248, 81, 73, 0.06);
}

.settings-danger-zone h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: #ff7b72;
}

@media (max-width: 900px) {
  .settings-form-grid,
  .settings-form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .settings-form-grid,
  .settings-form-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ===== CARDS / STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  margin-bottom: 1.75rem;
}

.stats-grid-6 {
  grid-template-columns: repeat(6, 1fr);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  opacity: 0.12;
  transform: translate(30%, -30%);
}

.stat-card.blue::after { background: var(--accent); }
.stat-card.green::after { background: var(--green); }
.stat-card.orange::after { background: var(--orange); }
.stat-card.purple::after { background: var(--purple); }
.stat-card.cyan::after { background: var(--cyan); }

a.stat-card-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

a.stat-card-link:hover {
  border-color: #484f58;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}

a.stat-card-link .stat-hint {
  color: var(--orange);
  font-weight: 600;
}

a.stat-card-link.cyan .stat-hint {
  color: var(--cyan);
}

.storage-card {
  border-color: rgba(57, 210, 192, 0.25);
}

.storage-card::after {
  background: var(--cyan);
}

.storage-bar {
  position: relative;
  margin-top: 0.65rem;
  height: 6px;
  border-radius: 99px;
  background: rgba(139, 148, 158, 0.18);
  overflow: hidden;
}

.storage-bar-disk {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(139, 148, 158, 0.35);
  border-radius: 99px;
}

.storage-bar-media {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--cyan), var(--accent));
  border-radius: 99px;
  min-width: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.stat-value {
  margin-top: 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-hint {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ===== GROUP GRID ===== */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  color: inherit;
}

.group-card:hover {
  border-color: #484f58;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.group-card-priority {
  border-color: rgba(210, 153, 34, 0.55);
  box-shadow: 0 0 0 1px rgba(210, 153, 34, 0.15);
}

.group-card-priority:hover {
  border-color: rgba(210, 153, 34, 0.8);
}

.group-card-main {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  color: inherit;
  text-decoration: none;
}

.group-card-main:hover {
  text-decoration: none;
  color: inherit;
}

.group-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.group-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent-soft), var(--purple-soft));
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.group-name {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.group-entity {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.75rem;
  word-break: break-all;
}

.group-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.3;
}

.badge-blue { background: var(--accent-soft); color: #79b8ff; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-purple { background: var(--purple-soft); color: #d2a8ff; }
.badge-gray { background: rgba(139, 148, 158, 0.15); color: var(--text-muted); }

html[data-theme="light"] .badge-blue { color: #0969da; }
html[data-theme="light"] .badge-purple { color: #8250df; }
html[data-theme="light"] .badge-gray { background: rgba(175, 184, 193, 0.25); }

.group-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-soft);
}

.group-stats-row-4 {
  grid-template-columns: repeat(4, 1fr);
}

.gs-val-sm {
  font-size: 0.92rem !important;
}

.gs-item {
  text-align: center;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  padding: 0.25rem 0.15rem;
}

a.gs-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
  color: inherit;
}

a.gs-media:hover .gs-val {
  color: var(--orange);
}

.gs-val {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
}

.gs-lab {
  display: block;
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.1rem;
}

.group-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.group-footer-actions {
  flex-wrap: wrap;
}

.group-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  justify-content: flex-end;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}

.td-groups {
  max-width: 280px;
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-word;
}

.filters-grid-users {
  grid-template-columns: 1.6fr repeat(4, minmax(0, 1fr)) auto;
}

.group-meta-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
}

.group-about {
  margin: 0.45rem 0 0.55rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.msg-forward,
.msg-reply,
.msg-links {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin: 0.2rem 0 0.35rem;
}

.msg-forward {
  color: var(--orange);
}

.user-profile-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.user-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  background: var(--bg-hover);
  border: 1px solid var(--border);
}

.user-avatar-lg.placeholder,
.user-avatar-sm.placeholder {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}

.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  display: inline-grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-hover);
  border: 1px solid var(--border-soft);
}

.msg-card-album .msg-side {
  min-width: min(100%, 320px);
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.4rem;
  margin: 0.45rem 0;
  max-width: 360px;
}

.album-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  display: grid;
  place-items: center;
}

.album-cell img,
.album-cell video.album-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.album-file {
  font-size: 0.7rem;
  padding: 0.35rem;
  text-align: center;
  word-break: break-all;
}

.stats-grid-jobs {
  grid-template-columns: repeat(4, 1fr);
}

.job-payload,
.job-result {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
}

.text-err {
  color: #ff7b72;
}

.msg-links a {
  color: var(--cyan);
  word-break: break-all;
  font-size: 0.78rem;
}

.msg-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.jobs-live-bar {
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
  background: rgba(47, 129, 247, 0.12);
  border-bottom: 1px solid rgba(47, 129, 247, 0.35);
  padding: 0.35rem 1.25rem;
  font-size: 0.8rem;
  text-align: center;
}

.jobs-live-bar a {
  color: #79b8ff;
  font-weight: 600;
  text-decoration: none;
}

.jobs-live-bar a:hover {
  text-decoration: underline;
}

.jobs-live-bar.is-busy {
  background: rgba(210, 153, 34, 0.12);
  border-color: rgba(210, 153, 34, 0.4);
}

.jobs-live-bar.is-busy a {
  color: var(--orange);
}

@media (max-width: 1100px) {
  .stats-grid[style*="repeat(5"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

.gallery-album-badge {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  z-index: 2;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* ===== FILTERS ===== */
.filters {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  align-items: end;
}

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input,
.select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder {
  color: var(--text-dim);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

.filters-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.25rem;
  grid-column: 1 / -1;
  justify-content: flex-start;
}

/* ===== MESSAGES ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.result-count {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.result-count strong {
  color: var(--text);
}

.live-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.live-dot.on {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  animation: pulse 1.6s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem 1rem;
  transition: border-color 0.15s;
}

.msg-card:hover {
  border-color: #3d444d;
}

.msg-card.is-new {
  border-color: rgba(63, 185, 80, 0.45);
  box-shadow: 0 0 0 1px var(--green-soft);
}

.msg-card.is-highlight {
  border-color: rgba(47, 129, 247, 0.65);
  box-shadow: 0 0 0 2px var(--accent-soft);
  animation: highlight-pulse 1.4s ease 2;
}

@keyframes highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent-soft); }
  50% { box-shadow: 0 0 0 6px rgba(47, 129, 247, 0.2); }
}

.msg-main {
  min-width: 0;
}

.msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.55rem;
}

.msg-author {
  font-weight: 600;
  font-size: 0.92rem;
}

.msg-author-id {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.msg-date {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-left: auto;
}

.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #d0d7de;
}

.msg-text:empty::after {
  content: "—";
  color: var(--text-dim);
}

.msg-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 140px;
}

.media-box {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 220px;
}

.media-box img {
  display: block;
  max-height: 180px;
  width: auto;
  max-width: 220px;
  object-fit: cover;
  cursor: zoom-in;
}

.media-box video {
  display: block;
  max-height: 180px;
  max-width: 220px;
  background: #000;
}

.media-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 220px;
}

.media-file a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-id {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
}

.page-link {
  min-width: 36px;
  height: 36px;
  padding: 0 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.page-link:hover {
  background: var(--bg-hover);
  text-decoration: none;
  color: #fff;
}

.page-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.page-link.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ===== LIGHTBOX (simple photo) ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(1, 4, 9, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: min(96vw, 1100px);
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: default;
}

/* ===== GALLERY GRID ===== */
.gallery-filters-grid {
  grid-template-columns: 2fr 1fr 1fr auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
}

.gallery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}

.gallery-card:hover {
  border-color: #484f58;
  transform: translateY(-2px);
}

.gallery-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: #0d1117;
  cursor: pointer;
  overflow: hidden;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--text-muted);
  background: linear-gradient(145deg, #161b22, #0d1117);
}

.gallery-placeholder .ph-icon {
  font-size: 1.6rem;
  opacity: 0.9;
}

.gallery-placeholder .ph-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gallery-placeholder.video .ph-icon { color: var(--accent); }
.gallery-placeholder.audio .ph-icon { color: var(--purple); }
.gallery-placeholder.missing { opacity: 0.7; }

.gallery-type-badge {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  background: rgba(1, 4, 9, 0.72);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.gallery-meta {
  padding: 0.55rem 0.65rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.gallery-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.gallery-author {
  font-size: 0.8rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-msg-link {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.95rem;
}

.gallery-msg-link:hover {
  background: rgba(47, 129, 247, 0.3);
  color: #79b8ff;
  text-decoration: none;
}

.gallery-meta-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.gallery-group {
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== GALLERY VIEWER ===== */
.gviewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.gviewer[hidden] {
  display: none !important;
}

.gviewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 4, 9, 0.9);
  backdrop-filter: blur(4px);
}

.gviewer-panel {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  max-height: 94vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.gviewer-top,
.gviewer-bottom {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-soft);
}

.gviewer-bottom {
  border-bottom: 0;
  border-top: 1px solid var(--border-soft);
  flex-direction: column;
  align-items: stretch;
}

.gviewer-info {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  min-width: 0;
}

.gviewer-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.gviewer-author {
  font-weight: 600;
  font-size: 0.9rem;
}

.gviewer-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.gviewer-stage {
  position: relative;
  flex: 1;
  min-height: 280px;
  max-height: 62vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #010409;
}

.gviewer-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.gviewer-content img,
.gviewer-content video {
  max-width: 100%;
  max-height: 58vh;
  border-radius: 6px;
}

.gviewer-content audio {
  width: min(480px, 90%);
}

.gviewer-content .gv-file {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.gviewer-content .gv-file a {
  display: inline-block;
  margin-top: 0.75rem;
}

.gviewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(22, 27, 34, 0.85);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
}

.gviewer-nav:hover {
  background: var(--bg-hover);
  border-color: var(--text-dim);
}

.gviewer-nav.prev { left: 0.65rem; }
.gviewer-nav.next { right: 0.65rem; }

.gviewer-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gviewer-text {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: #d0d7de;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.5em;
  overflow: auto;
}

body.gviewer-open {
  overflow: hidden;
}

/* ===== LOGIN ===== */
.login-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(47, 129, 247, 0.18), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(163, 113, 247, 0.14), transparent 50%),
    var(--bg);
}

.login-theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

html[data-theme="light"] .login-page {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(9, 105, 218, 0.10), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(130, 80, 223, 0.08), transparent 50%),
    var(--bg);
}

html[data-theme="light"] .alert-error {
  color: #cf222e;
}

html[data-theme="light"] .alert-info {
  color: #0969da;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand .brand-mark {
  margin: 0 auto 0.85rem;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 1.25rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.login-brand p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.login-field {
  margin-bottom: 1rem;
}

.login-field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.alert {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.35);
  color: #ff7b72;
}

.alert-info {
  background: var(--accent-soft);
  border: 1px solid rgba(47, 129, 247, 0.3);
  color: #79b8ff;
}

/* ===== GROUP HEADER CHIPS ===== */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.65rem;
}

.back-link:hover {
  color: var(--text);
  text-decoration: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .filters-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .filters-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .stats-grid,
  .stats-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters-grid-users {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .filters-grid,
  .gallery-filters-grid {
    grid-template-columns: 1fr 1fr;
  }

  .msg-card {
    grid-template-columns: 1fr;
  }

  .msg-side {
    align-items: flex-start;
  }

  .msg-date {
    margin-left: 0;
  }

  .page {
    padding: 1rem 0.85rem 2rem;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .gviewer-nav {
    width: 36px;
    height: 36px;
  }

  .topnav-right .user-chip span:last-child {
    display: none;
  }
}

@media (max-width: 520px) {
  .stats-grid,
  .stats-grid-6 {
    grid-template-columns: 1fr;
  }

  .filters-grid,
  .filters-grid-users {
    grid-template-columns: 1fr;
  }

  .group-stats-row,
  .group-stats-row-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== Sessions wizard ===== */
.session-wizard {
  max-width: 720px;
}

.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.wizard-step {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg-elevated);
}

.wizard-step.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wizard-pane {
  margin-top: 0.5rem;
}

.check-inline {
  display: inline-flex !important;
  margin-right: 0.65rem;
  margin-bottom: 0.25rem;
}

.roles-cell {
  min-width: 12rem;
}

.td-actions {
  white-space: nowrap;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.field-label-text {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stats-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 900px) {
  .stats-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .stats-grid-4 {
    grid-template-columns: 1fr;
  }
  .td-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

.alert-ok {
  background: var(--green-soft);
  border: 1px solid rgba(63, 185, 80, 0.35);
  color: var(--green);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* ===== SITES / BOARD ===== */
.sites-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
  max-width: 100%;
}

.sites-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.sites-tab:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}

.sites-tab.active {
  color: #fff;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(47, 129, 247, 0.25);
}

html[data-theme="light"] .sites-tab.active {
  color: var(--accent);
}

.stats-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 1100px) {
  .stats-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .stats-grid-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.filters-grid-board {
  grid-template-columns: 2fr 1.4fr 1fr 1fr 0.8fr auto;
}

@media (max-width: 1100px) {
  .filters-grid-board {
    grid-template-columns: 1fr 1fr;
  }
}

.board-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.board-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  transition: border-color 0.15s;
}

.board-card:hover {
  border-color: #484f58;
}

.board-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.board-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
}

.board-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.board-card-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.board-card-title a {
  color: var(--text);
  text-decoration: none;
}

.board-card-title a:hover {
  color: var(--accent);
}

.board-card-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
}

.board-card-text {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.board-detail-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 900px) {
  .board-detail-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.board-detail-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-size: 0.95rem;
}

.meta-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.meta-list > div {
  display: grid;
  gap: 0.15rem;
}

.meta-list dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 600;
}

.meta-list dd {
  margin: 0;
  font-size: 0.92rem;
  word-break: break-word;
}

/* ===== BOARD EXTRACT CHIPS ===== */
.extract-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.55rem;
}

.extract-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  background: rgba(139, 148, 158, 0.12);
  color: var(--text-muted);
  border: 1px solid transparent;
  text-decoration: none;
  max-width: 100%;
  word-break: break-all;
}

a.extract-chip:hover {
  text-decoration: none;
  border-color: var(--border);
  color: var(--text);
}

.extract-chip-tg {
  background: rgba(47, 129, 247, 0.14);
  color: #79b8ff;
}

.extract-chip-phone {
  background: rgba(63, 185, 80, 0.14);
  color: var(--green);
}

.extract-chip-place,
.extract-chip-metro {
  background: rgba(210, 153, 34, 0.14);
  color: var(--orange);
}

.extract-chip-params {
  background: rgba(163, 113, 247, 0.14);
  color: #d2a8ff;
  font-variant-numeric: tabular-nums;
}

.extract-chip-role {
  background: rgba(57, 210, 192, 0.14);
  color: var(--cyan);
}

.extract-chip-pref {
  background: rgba(139, 148, 158, 0.14);
  color: var(--text-muted);
}

.extract-chip-ok {
  background: rgba(63, 185, 80, 0.14);
  color: var(--green);
}

.extract-chip-warn {
  background: rgba(210, 153, 34, 0.14);
  color: var(--orange);
}

.board-parser-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 1rem;
  margin: 0 0 1rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 0.85rem;
}
.board-parser-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex: 0 0 auto;
}
.board-parser-status.is-online .board-parser-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.board-parser-status.is-offline .board-parser-dot {
  background: var(--orange);
}
.board-parser-status.is-online strong { color: var(--green); }
.board-parser-status.is-offline strong { color: var(--orange); }
.board-parser-err {
  color: var(--red);
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-grid-board-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 1100px) {
  .stats-grid-board-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .stats-grid-board-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.filters-grid-board {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1100px) {
  .filters-grid-board {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== PARSER CONTROL ===== */
.parser-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 1.15rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.parser-control-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.parser-control.is-paused { border-color: var(--orange); }
.parser-control.is-focus { border-color: var(--accent); }
.parser-control.is-paused strong { color: var(--orange); }
.parser-control.is-focus strong { color: var(--accent); }
.parser-control.is-all strong { color: var(--green); }

/* ===== PERSONS / TOPICS ===== */
.person-grid, .topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.person-card, .topic-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: inherit;
  text-decoration: none;
}
.person-card:hover, .topic-card:hover { background: var(--bg-hover); }
.person-avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  background: var(--bg-elevated);
}
.person-avatar.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: var(--text-muted);
}
.person-card h3, .topic-card h3 { margin: 0 0 0.2rem; font-size: 1rem; }
.person-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.person-media-item { margin: 0; position: relative; }
.person-media-item img, .person-media-item video {
  width: 100%; height: 110px; object-fit: cover; border-radius: 8px;
}
.person-media-item figcaption { font-size: 0.75rem; color: var(--text-muted); }
.plain-list { margin: 0; padding-left: 1.1rem; }
.plain-list li { margin: 0.25rem 0; }

/* ===== DATASET ===== */
.dataset-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.25rem;
}
