:root {
  --bg: #f3f3f3;
  --panel: #ffffff;
  --line: #e5e5e5;
  --text: #1a1a1a;
  --muted: #605e5c;
  --accent: #0078d4;
  --accent2: #106ebe;
  --ok: #107c10;
  --warn: #f7630c;
  --bad: #d13438;
  --sidebar: #202020;
  --sidebar-text: #f3f3f3;
  --shadow: 0 8px 24px rgba(0,0,0,.08);
  --radius: 8px;
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }

.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(0,120,212,.12), transparent 40%),
    linear-gradient(180deg, #e8eef5, #f3f3f3 50%, #ebe6df);
}
.win-titlebar {
  position: fixed; top: 0; left: 0; right: 0; height: 36px;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: #fff; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.win-dots { display: flex; gap: 6px; }
.win-dots i { width: 10px; height: 10px; border-radius: 50%; display: block; background: #c8c8c8; }
.win-dots i:nth-child(1){background:#ff6058} .win-dots i:nth-child(2){background:#ffbd2e} .win-dots i:nth-child(3){background:#28c840}

.login-card {
  width: min(420px, 92vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 600; }
.login-card .sub { margin: 0 0 22px; color: var(--muted); }
.login-card label { display:block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.login-card input, .toolbar input {
  width: 100%; height: 36px; border: 1px solid #8a8886; border-radius: 4px;
  padding: 0 10px; font: inherit; background: #fff;
}
.login-card input:focus, .toolbar input:focus { outline: 2px solid rgba(0,120,212,.35); border-color: var(--accent); }

.btn {
  height: 36px; border-radius: 4px; border: 1px solid #8a8886; background: #fff;
  padding: 0 14px; font: inherit; cursor: pointer;
}
.btn.primary { width: 100%; margin-top: 18px; background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: #666; color: var(--sidebar-text); width: 100%; }
.err { color: var(--bad); min-height: 1.2em; font-size: 13px; }

.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); padding: 18px 14px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 14px; border-bottom: 1px solid #333; }
.logo {
  width: 40px; height: 40px; border-radius: 8px; display:grid; place-items:center;
  background: linear-gradient(135deg, #0078d4, #5b2c6f); font-weight: 700;
}
.brand small { display:block; color:#aaa; }
nav { display: flex; flex-direction: column; gap: 6px; }
.nav {
  text-align: left; border: 0; background: transparent; color: #ddd; padding: 10px 12px;
  border-radius: 6px; cursor: pointer; font: inherit;
}
.nav.active, .nav:hover { background: #2f2f2f; color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.switch-row { display:flex; justify-content:space-between; align-items:center; font-size:13px; color:#ccc; padding: 0 4px; }
.neko-box { display:grid; gap:6px; padding: 8px 4px 0; border-top: 1px solid #333; }
.neko-box label { font-size:12px; color:#aaa; }
.neko-box input {
  width: 100%; border: 1px solid #444; background:#111; color:#eee;
  border-radius: 6px; padding: 8px 10px; font-size: 12px;
}
.neko-row { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.neko-row small { color:#888; font-size:11px; overflow:hidden; text-overflow:ellipsis; }

.switch { position: relative; width: 44px; height: 24px; display:inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #555; border-radius: 24px; transition: .2s;
}
.slider:before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(20px); }

main { padding: 22px 28px; }
.top { display:flex; justify-content:space-between; gap: 16px; align-items:flex-start; margin-bottom: 16px; }
.top h2 { margin: 0; font-size: 28px; font-weight: 600; }
.top p { margin: 6px 0 0; color: var(--muted); }
.stats { display:flex; gap: 10px; flex-wrap: wrap; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; min-width: 96px;
  box-shadow: var(--shadow);
}
.stat b { display:block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden;
}
.toolbar { display:flex; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: #fafafa; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; word-break: break-all; }
.badge {
  display:inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.pending { background: #fff4ce; color: #8a6116; }
.badge.approved { background: #dff6dd; color: #0e700e; }
.badge.denied { background: #fde7e9; color: #a4262c; }
.ops { display:flex; gap: 6px; flex-wrap: wrap; }
.svc-banner {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 8px;
  background: #fff4ce; border: 1px solid #f0c36d; color: #8a6116; font-size: 13px;
}
.svc-banner.off { background: #fde7e9; border-color: #f1aeb5; color: #a4262c; }
.rpc-hint {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 8px;
  background: #f3f2f1; border: 1px solid var(--line); color: var(--muted); font-size: 12px;
  font-family: Consolas, "Cascadia Mono", monospace; white-space: pre-wrap;
}
.empty-hint {
  padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  nav { flex-direction: row; flex-wrap: wrap; }
}

/* portal */
.portal-body { background: linear-gradient(160deg, #eef3f9, #f6f1ea); }
.portal-shell { max-width: 480px; margin: 48px auto; padding: 0 16px 40px; }
.portal-head { display:flex; flex-direction:column; gap:14px; margin-bottom: 18px; }
.portal-brand { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }
.portal-brand span { color: var(--accent); font-weight: 600; }
.portal-tabs { display:flex; gap:8px; flex-wrap:wrap; }
.portal-tabs .tab {
  border:1px solid var(--line); background:#fff; border-radius:999px; padding:8px 14px;
  cursor:pointer; font:inherit; color:var(--muted);
}
.portal-tabs .tab.active, .portal-tabs .tab:hover { color:var(--accent); border-color:#bcd6ef; }
.portal-tabs .tab.link { text-decoration:none; display:inline-flex; align-items:center; }
.portal-card {
  background:#fff; border:1px solid var(--line); border-radius:14px; padding:24px;
  box-shadow: var(--shadow);
}
.portal-card h1 { margin:0 0 6px; font-size:22px; }
.portal-card .sub { margin:0 0 18px; color:var(--muted); font-size:13px; }
.portal-card label { display:block; font-size:12px; color:var(--muted); margin:12px 0 6px; }
.portal-card input {
  width:100%; height:38px; border:1px solid #8a8886; border-radius:6px; padding:0 10px; font:inherit;
}
.err { color:var(--bad); min-height:1.2em; font-size:13px; margin-top:10px; }
.err.ok { color:var(--ok); }
.pill { display:inline-block; padding:2px 8px; border-radius:999px; background:#e8f2fc; color:#0b5cab; font-size:12px; }
.table-wrap { overflow:auto; }
.small { font-size:11px; }
.modal {
  position:fixed; inset:0; background:rgba(0,0,0,.35); display:grid; place-items:center; z-index:50;
}
.modal-card {
  width:min(440px,92vw); background:#fff; border-radius:12px; padding:20px; border:1px solid var(--line);
}
.modal-card label { display:block; font-size:12px; color:var(--muted); margin:10px 0 4px; }
.modal-card input, .modal-card select {
  width:100%; height:36px; border:1px solid #8a8886; border-radius:4px; padding:0 8px; font:inherit;
}
.modal-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
.code-form { flex-wrap:wrap; align-items:center; }
.code-form select, .code-form input { height:34px; border:1px solid #8a8886; border-radius:4px; padding:0 8px; }
.btn.sm { height:28px; padding:0 10px; font-size:12px; }
