:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e4e7ec;
  --accent: #f2a900; --accent-soft: #fff4d6; --bad: #d64545; --good: #2f9e5b; --bar: #f2b632;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --card: #1b1f27; --text: #e6e8ee; --muted: #8b93a7; --line: #2a303b;
          --accent: #f5b82e; --accent-soft: #3a3020; --bad: #ef6b6b; --good: #4cc27f; --bar: #d99d1c; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: #1d1d1d; font-weight: 600; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button:disabled { opacity: .6; cursor: default; }
input, select { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
h3 { margin: 0 0 12px; font-size: 15px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; display: grid; gap: 12px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
       padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; }
nav { display: flex; gap: 4px; }
.tab { background: transparent; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--accent-soft); color: var(--text); }
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; display: grid; gap: 16px; }
section { display: grid; gap: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } main { padding: 12px; } }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.bars .b { flex: 1; background: var(--bar); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .b:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--card); padding: 2px 6px; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: 140px 1fr 44px; gap: 8px; align-items: center; }
.hbar .track { background: var(--bg); border-radius: 4px; height: 14px; overflow: hidden; }
.hbar .fill { background: var(--bar); height: 100%; border-radius: 4px; }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.kv dt, .kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { min-width: 260px; flex: 1; max-width: 420px; }
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--card); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--accent-soft); }
.av { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--line); display: grid; place-items: center;
      font-weight: 700; color: var(--muted); font-size: 14px; }
.uname { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 12px; background: var(--bg); margin-right: 4px; white-space: nowrap; }
.badge.bad { color: var(--bad); }
.badge.good { color: var(--good); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-body { position: relative; width: 100%; max-width: 820px; max-height: 92vh; overflow: auto; }
.close { position: absolute; top: 8px; right: 8px; background: transparent; color: var(--muted); font-size: 22px; padding: 2px 10px; }
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.profile-head .av { width: 72px; height: 72px; font-size: 28px; }
.profile-head h2 { margin: 0; font-size: 20px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.gallery a img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); }
pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; }
.section-title { margin: 16px 0 8px; font-weight: 600; }

.gallery button { padding: 0; background: none; border-radius: 8px; overflow: hidden; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; transition: transform .15s; }
.gallery button:hover img { transform: scale(1.04); }
.profile-head img.av { cursor: zoom-in; }

.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.92); display: grid; place-items: center; touch-action: pan-y; }
.lb-img { max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: 6px; box-shadow: 0 8px 40px rgba(0,0,0,.5); user-select: none; }
.lb-close { position: absolute; top: 12px; right: 16px; background: transparent; color: #fff; font-size: 34px; line-height: 1; padding: 4px 12px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff;
          font-size: 40px; line-height: 1; width: 56px; height: 72px; padding: 0; border-radius: 10px; }
.lb-nav:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: 16px; } .lb-next { right: 16px; }
.lb-nav[hidden] { display: none; }
.lb-counter { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #ddd; font-size: 14px;
              background: rgba(0,0,0,.4); padding: 4px 12px; border-radius: 12px; }
@media (max-width: 600px) { .lb-nav { width: 44px; height: 56px; font-size: 32px; } .lb-prev { left: 6px; } .lb-next { right: 6px; } }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.ph { padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-align: left; color: var(--text); font-weight: 400; }
.ph img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.ph .cap { padding: 6px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph .cap .muted { display: block; font-size: 11px; }
.ph:hover { border-color: var(--accent); }
.lb-caption { position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center;
              background: rgba(0,0,0,.55); color: #fff; padding: 8px 10px 8px 14px; border-radius: 12px; max-width: 92vw; }
.lb-owner { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-owner .sub { color: #bbb; font-size: 12px; }
.lb-profile { padding: 6px 12px; font-size: 13px; }
