:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f7f9fc; --ink: #14202e; --ink-2: #45546a; --muted: #7b8798;
  --line: #e3e8ef; --brand: #1d5fd6; --brand-2: #0f3f9a; --brand-soft: #e7efff; --accent: #12a879; --warn: #d9822b; --danger: #d64545;
  --hit: #fff1a8; --radius: 14px; --shadow: 0 1px 2px rgba(20,32,46,.06), 0 8px 24px -12px rgba(20,32,46,.18);
  --shadow-lg: 0 24px 60px -20px rgba(20,32,46,.35);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f141b; --surface: #171e27; --surface-2: #1d2631; --ink: #e9eef5; --ink-2: #b4bfcd; --muted: #7f8ca0;
  --line: #273140; --brand: #5b93ff; --brand-2: #8ab3ff; --brand-soft: #1b2a45; --hit: #5a4a00;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
} }
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171e27; --surface-2: #1d2631; --ink: #e9eef5; --ink-2: #b4bfcd; --muted: #7f8ca0;
  --line: #273140; --brand: #5b93ff; --brand-2: #8ab3ff; --brand-soft: #1b2a45; --hit: #5a4a00;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6); --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: .92em; }
mark { background: var(--hit); color: inherit; border-radius: 3px; padding: 0 1px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
.topbar .inner { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; font-size: 17px; color: var(--ink); }
.logo .mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #4f8bff); display: grid; place-items: center; flex: none; }
.logo .mark svg { width: 18px; height: 18px; }
.logo .sub { font-weight: 500; color: var(--muted); font-size: 12px; display: block; line-height: 1.1; }
.spacer { flex: 1; }
.nav { display: flex; gap: 4px; }
.nav a, .nav button { white-space: nowrap; padding: 7px 12px; border-radius: 9px; color: var(--ink-2); font-weight: 500; background: none; border: 0; cursor: pointer; }
.nav a.active, .nav a:hover, .nav button:hover { background: var(--brand-soft); color: var(--brand); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }

/* ---------- layout */
.page { max-width: 1080px; margin: 0 auto; padding: 24px 16px 80px; }
.hero { text-align: center; padding: 36px 0 20px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--ink-2); }
.searchbox { position: relative; max-width: 720px; margin: 22px auto 0; display: flex; gap: 8px; }
.searchbox .field { flex: 1; position: relative; }
.searchbox input { width: 100%; padding: 15px 18px 15px 48px; font-size: 17px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); outline: none; transition: box-shadow .15s, border-color .15s; }
.searchbox input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft), var(--shadow); }
.searchbox .icon { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.searchbox select { padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.chip { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 26px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.stat .v.sm { font-size: 15px; }

.results-head { display: flex; align-items: baseline; gap: 12px; margin: 20px 0 10px; color: var(--muted); font-size: 13px; }
.results { display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; transition: transform .12s, border-color .12s; }
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card .addr { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.card .own { color: var(--ink-2); }
.maplink { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); font-size: 13px; font-weight: 600; text-decoration: none; vertical-align: middle; }
.maplink:hover { text-decoration: underline; }
.card .addr .maplink { padding: 2px 4px; border-radius: 6px; }
.card .addr .maplink:hover { background: var(--brand-soft); }
.card .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.card .val { text-align: right; font-weight: 700; font-size: 17px; grid-column: 2; grid-row: 1 / span 3; align-self: center; }
.card .val small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); vertical-align: middle; }
.badge.warn { background: #fff0e0; color: var(--warn); } .badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.green { background: #e2f7ee; color: #0c7a56; }
:root[data-theme="dark"] .badge.warn, :root:not([data-theme="light"]) .badge.warn { background: #3a2a14; }
.empty { text-align: center; padding: 50px 0; color: var(--muted); }
.more { margin: 16px auto 0; display: block; }

/* ---------- buttons/forms */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: 14px; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.danger { color: var(--danger); } .btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; } .btn:disabled { opacity: .5; cursor: default; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.input, select.input, textarea.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; background: var(--line); cursor: pointer; border: 0; padding: 0; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on { background: var(--accent); } .switch.on::after { left: 21px; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 14px; background: var(--brand-soft); color: var(--brand); }
.alert.err { background: #fdeaea; color: var(--danger); } .alert.ok { background: #e2f7ee; color: #0c7a56; }
:root[data-theme="dark"] .alert.err, :root:not([data-theme="light"]) .alert.err { background: #3b1c1c; }

/* ---------- modal / detail */
.overlay { position: fixed; inset: 0; background: rgba(10,16,24,.55); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.panel { width: min(640px, 100%); height: 100%; background: var(--bg); overflow-y: auto; box-shadow: var(--shadow-lg); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.panel-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 20px; display: flex; align-items: center; gap: 12px; z-index: 2; }
.panel-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; flex: 1; }
.panel-body { padding: 18px 20px 60px; display: grid; gap: 16px; }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.section h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.section h3 .spacer { flex: 1; }
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 7px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 13px; } dl.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.valgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.valgrid .box { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.valgrid .box .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.valgrid .box .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.valgrid .box .d { font-size: 12px; margin-top: 2px; } .up { color: var(--accent); } .down { color: var(--danger); }
.note { border-left: 3px solid var(--brand); background: var(--surface-2); border-radius: 0 10px 10px 0; padding: 10px 12px; margin-bottom: 8px; }
.note.guest { border-color: var(--accent); }
.note .who { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-bottom: 3px; }
.note .who .spacer { flex: 1; } .note .body { white-space: pre-wrap; }
.note .actions button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px; font-size: 12px; } .note .actions button:hover { color: var(--brand); }
.rawtable { width: 100%; border-collapse: collapse; font-size: 13px; } .rawtable td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rawtable td:first-child { color: var(--muted); white-space: nowrap; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 13px; }

/* ---------- login */
.login-wrap { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow-lg); display: grid; gap: 14px; }
.login h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }

/* ---------- admin */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-color: var(--brand); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), #4f8bff); transition: width .4s; }
.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 40px; }

@media (max-width: 640px) {
  .topbar .inner { padding: 8px 12px; gap: 8px; } .logo .sub { display: none; } .nav a span.t { display: none; }
  .page { padding: 12px 12px 60px; } .hero { padding: 18px 0 8px; }
  .searchbox { flex-direction: column; } .searchbox select { padding: 12px 14px; }
  .card { grid-template-columns: 1fr; } .card .val { text-align: left; grid-column: 1; grid-row: auto; font-size: 15px; } .card .val small { display: inline; margin-left: 6px; }
  .valgrid { grid-template-columns: 1fr 1fr; } .panel { width: 100%; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; } dl.kv dd { margin-bottom: 8px; }
}
