:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --panel: #111111;
  --panel-2: #161616;
  --panel-3: #1c1c1c;
  --ink: #ededed;
  --muted: #8a8a8a;
  --line: #222222;
  --line-strong: #2e2e2e;
  --accent: #e07a4f;
  --accent-hover: #eb885c;
  --danger: #f07178;
  --good: #3ecf8e;
  --warn: #e6b450;
  --info: #6cb6ff;
  --rail: 220px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Noto Sans SC", "Segoe UI", "Microsoft YaHei UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  font-family: var(--font);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 300, "GRAD" 0, "opsz" 24;
  font-size: 18px;
  line-height: 1;
  user-select: none;
  vertical-align: middle;
}
.mi-sm { font-size: 16px !important; }
.mi-lg { font-size: 24px !important; }

/* chrome */
.titlebar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: transparent;
  color: var(--accent);
}
.brand-mark .material-symbols-outlined { font-size: 20px; color: var(--accent); }
.brand-mark.lg { width: 36px; height: 36px; }
.brand-mark.lg .material-symbols-outlined { font-size: 22px; }

.title-actions { display: flex; align-items: center; gap: 8px; }
.who {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}
.icon-btn, .text-btn {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s ease, color .12s ease;
}
.icon-btn { width: 32px; padding: 0; justify-content: center; }
.icon-btn:hover, .text-btn:hover { background: #1a1a1a; color: var(--ink); }

.nav-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.nav-toggle:hover { color: var(--ink); background: var(--panel-2); }
.nav-toggle-ico { width: 16px; height: 16px; transition: transform .25s var(--ease-out); }
.shell.rail-collapsed .nav-toggle {
  background: var(--panel-3);
  color: var(--accent);
  border-color: #3a2a22;
}
.shell.rail-collapsed .nav-toggle-ico { transform: rotate(90deg); }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  min-width: 200px;
  max-width: min(360px, 92vw);
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 13px;
}
.toast.ok { border-color: #1f3a2c; background: #14241c; color: var(--good); }
.toast.err { border-color: #5a2b2f; background: #2a1719; color: var(--danger); }

.kook-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kook-cell strong { font-size: 13px; font-weight: 500; color: #fff; }
.kook-cell small { color: var(--muted); font-family: var(--mono); font-size: 11px; }

.edit-drawer {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
}

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: calc(100vh - 52px);
  transition: grid-template-columns .35s var(--ease-out);
}
.shell.rail-collapsed { grid-template-columns: 0 minmax(0, 1fr); }

.rail {
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  width: var(--rail);
  min-width: 0;
  opacity: 1;
  transform: translateX(0);
  transition: transform .35s var(--ease-out), opacity .25s ease, width .35s var(--ease-out), border-color .25s ease;
}
.shell.rail-collapsed .rail {
  width: 0;
  border-right-color: transparent;
  transform: translateX(-12px);
  opacity: 0;
  pointer-events: none;
}

.rail nav {
  display: flex;
  flex-direction: column;
  padding: 10px 8px 16px;
  gap: 2px;
  width: var(--rail);
}
.nav-group {
  margin: 12px 10px 6px;
  font-size: 11px;
  color: #555;
  letter-spacing: 0.06em;
}
.nav-group:first-child { margin-top: 4px; }

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  transition: background .12s ease, color .12s ease;
}
.nav .material-symbols-outlined { color: inherit; font-size: 18px; }
.nav:hover { background: #151515; color: #ddd; }
.nav.active {
  background: #1a1a1a;
  color: #fff;
}
.nav.active .material-symbols-outlined {
  font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 0, "opsz" 24;
}

.main {
  padding: 20px 24px 40px;
  width: 100%;
  min-width: 0;
  animation: fadeSoft .2s ease;
}
.main.swap { animation: fadeSoft .2s ease; }
@keyframes fadeSoft {
  from { opacity: 0; }
  to { opacity: 1; }
}

.page-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 16px;
}
.page-title .material-symbols-outlined { display: none; }
h1 { font-size: 26px; font-weight: 600; margin: 0; color: #fff; letter-spacing: 0; }
h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
h2 .material-symbols-outlined { font-size: 16px; color: var(--muted); }
.sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 14px;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.stat:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}
.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.stat-head .material-symbols-outlined {
  color: var(--muted);
  font-size: 18px;
}
.stat b {
  display: block;
  font-size: 22px;
  margin-top: 8px;
  color: #fff;
  font-weight: 600;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.lbl { display: inline-flex; align-items: center; gap: 4px; }

input, select {
  min-width: 120px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel-2);
  color: var(--ink);
  height: 34px;
}
input:focus, select:focus {
  outline: none;
  border-color: #3a3a3a;
}
option { background: #161616; }

.primary, .ghost, .danger {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 12px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.primary { background: var(--accent); color: #1a100c; }
.primary:hover { background: var(--accent-hover); }
.ghost {
  background: var(--panel-2);
  border-color: var(--line-strong);
  color: var(--ink);
  text-decoration: none;
}
.ghost:hover { background: var(--panel-3); }
.danger {
  background: #2a1719;
  color: var(--danger);
  border-color: #5a2b2f;
}
.danger:hover { background: #3a1d1f; }
.primary .material-symbols-outlined,
.ghost .material-symbols-outlined,
.danger .material-symbols-outlined { font-size: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: #777; font-weight: 500; font-size: 12px; }
tbody tr:hover { background: #151515; }
tbody tr:last-child td { border-bottom: 0; }
code { font-family: var(--mono); font-size: 12px; color: #cfcfcf; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: #1f2a36;
  color: var(--info);
}
.tag .material-symbols-outlined { font-size: 14px; }
.tag.ok { background: #14241c; color: var(--good); }
.tag.warn { background: #2a2415; color: var(--warn); }
.tag.bad { background: #2a1719; color: var(--danger); }
tr.row-warn { background: rgba(230, 180, 80, 0.05); }
tr.row-bad { background: rgba(240, 113, 120, 0.05); }

.result-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

/* login */
.login-split {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-hero { display: none; }
.login-panel {
  width: min(380px, 100%);
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.login-form h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
}
.login-desc {
  margin: -4px 0 4px;
  color: var(--muted);
  font-size: 13px;
}
.login-form label {
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.login-form input {
  min-width: 0;
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 0 12px;
  color: var(--ink);
}
.login-form input:focus {
  outline: none;
  border-color: #3a3a3a;
}
.login-submit {
  margin-top: 4px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #1a100c;
  font-size: 14px;
  font-weight: 600;
}
.login-submit:hover { background: var(--accent-hover); }
.login-foot {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.login-form .error { margin: 0; min-height: 1.2em; font-size: 13px; }
.login-brand-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  margin-bottom: 2px;
  font-size: 14px;
}
.login-brand-row strong { color: var(--ink); font-weight: 600; }
.login-brand-row .material-symbols-outlined { color: var(--accent); font-size: 20px; }

.audit-filter-panel { margin-bottom: 12px; }
.audit-filter-row { gap: 8px; flex-wrap: wrap; align-items: center; }
.audit-filter-row input,
.audit-filter-row select { min-width: 140px; }
.audit-count { margin-left: auto; font-size: 12px; }
.audit-table-panel { overflow: auto; }
.audit-table { width: 100%; border-collapse: collapse; }
.audit-table th {
  text-align: left;
  font-size: 12px;
  color: #777;
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.audit-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
}
.audit-table tbody tr:hover td { background: #151515; }
.audit-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #1f2a36;
  color: var(--info);
  font-size: 12px;
  font-weight: 500;
}
.audit-detail {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}
.mono { font-family: var(--mono); font-size: 12px; }

.nect-kick-mask {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 40%, rgba(0, 0, 0, 0.62));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  animation: nect-kick-mask-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  color-scheme: inherit;
}
.nect-kick-mask.is-leaving { animation: nect-kick-mask-out 0.22s ease forwards; }
.nect-kick-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  transform: translateY(18px) scale(0.96);
  opacity: 0;
  animation: nect-kick-card-in 0.38s cubic-bezier(0.16, 1, 0.3, 1) 0.04s forwards;
}
.nect-kick-mask.is-leaving .nect-kick-card { animation: nect-kick-card-out 0.2s ease forwards; }
.nect-kick-accent {
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--warn));
}
.nect-kick-body { padding: 22px 22px 10px; }
.nect-kick-kicker {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.nect-kick-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.nect-kick-lead {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.nect-kick-card button,
#nect-kick-ok {
  appearance: none;
  width: calc(100% - 44px);
  margin: 8px 22px 18px;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #141414;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.nect-kick-card button:hover,
#nect-kick-ok:hover {
  background: var(--accent-hover);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 32%, transparent);
}
.nect-kick-card button:active,
#nect-kick-ok:active { transform: translateY(1px); }

html[data-theme="light"] .nect-kick-mask,
:root[data-theme="light"] .nect-kick-mask {
  background: color-mix(in srgb, #f4f4f5 45%, rgba(15, 23, 42, 0.35));
}
html[data-theme="light"] .nect-kick-card,
:root[data-theme="light"] .nect-kick-card {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #111827;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] .nect-kick-card h2,
:root[data-theme="light"] .nect-kick-card h2 { color: #111827; }
html[data-theme="light"] .nect-kick-lead,
:root[data-theme="light"] .nect-kick-lead { color: #6b7280; }
html[data-theme="light"] .nect-kick-card button,
html[data-theme="light"] #nect-kick-ok,
:root[data-theme="light"] .nect-kick-card button,
:root[data-theme="light"] #nect-kick-ok {
  color: #fff;
}
@keyframes nect-kick-mask-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nect-kick-mask-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes nect-kick-card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes nect-kick-card-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(10px) scale(0.98); }
}

@media (max-width: 860px) {
  .shell,
  .shell.rail-collapsed,
  .shell.rail-open {
    grid-template-columns: 1fr;
  }
  .rail {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 30;
    background: #0d0d0d;
    box-shadow: 0 0 0 1px var(--line);
    transform: translateX(-105%);
    opacity: 1;
    border-right: 1px solid var(--line);
  }
  .shell.rail-open .rail {
    transform: translateX(0);
    pointer-events: auto;
  }
  .shell.rail-collapsed .rail {
    transform: translateX(-105%);
    width: min(280px, 86vw);
    opacity: 1;
    pointer-events: none;
  }
  .main { padding: 16px 14px 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
