:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1c1f24;
  --muted: #6b7380;
  --accent: #ff6f3d;
  --accent-hover: #f25a24;
  --accent-soft: #fff0ea;
  --ok: #18a058;
  --ok-soft: #e6f6ee;
  --off: #9aa1ad;
  --off-soft: #eef0f3;
  --warn: #d97706;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2a2f39;
    --text: #e8eaee; --muted: #9098a6; --accent-soft: #3a2219;
    --ok-soft: #12301f; --off-soft: #23272f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2a2f39;
  --text: #e8eaee; --muted: #9098a6; --accent-soft: #3a2219;
  --ok-soft: #12301f; --off-soft: #23272f; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Open Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner, main { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.brand small { font-weight: 500; color: var(--muted); }
.spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.user { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* ---------- toolbar ---------- */
.hero { padding: 36px 0 20px; display: flex; flex-wrap: wrap; align-items: end; gap: 16px; justify-content: space-between; }
.hero h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.search {
  display: flex; align-items: center; gap: 8px; width: min(320px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; height: 40px;
}
.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; width: 100%; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding-bottom: 48px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px;
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.version { font-size: 30px; font-weight: 750; letter-spacing: -.02em; line-height: 1; margin-right: 4px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.link {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
}
.link:hover { background: var(--accent); color: #fff; }
.link.primary { background: var(--accent); color: #fff; }
.link.primary:hover { background: var(--accent-hover); }
.link svg { width: 14px; height: 14px; }
.card.offline .link { opacity: .55; }

.meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.online { color: var(--ok); background: var(--ok-soft); }
.badge.offline { color: var(--off); background: var(--off-soft); }
.badge.loading { color: var(--muted); background: var(--surface-2); }
.badge.loading::before { animation: pulse 1s infinite ease-in-out; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; grid-column: 1 / -1; }
.footer-note { color: var(--muted); font-size: 13px; padding-bottom: 32px; }

@keyframes pulse { 50% { opacity: .3; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 32px 28px;
}
.login .brand { margin-bottom: 24px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { margin: 0 0 20px; color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; outline: 0;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  width: 100%; height: 44px; border: 0; border-radius: 10px; background: var(--accent);
  color: #fff; font-weight: 700; cursor: pointer; margin-top: 6px;
}
.btn:hover { background: var(--accent-hover); }
.error { background: #fdecec; color: #b42318; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 16px; }
:root[data-theme="dark"] .error { background: #3b1717; color: #ff9b91; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .error { background: #3b1717; color: #ff9b91; } }

@media (max-width: 600px) {
  .topbar-inner, main { padding: 0 16px; }
  .brand small, .user { display: none; }
  .grid { grid-template-columns: 1fr; }
}
