:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e5e5e5;
  --accent: #0f6cbd;
  --accent-hover: #115ea3;
  --danger: #c42b1c;
  --rail: 232px;
  --logs: 320px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
  font-family: "Noto Sans SC", "Segoe UI Variable", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: 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" 400, "GRAD" 0, "opsz" 24;
  font-size: 20px;
  line-height: 1;
  user-select: none;
  vertical-align: middle;
}
.mi-sm { font-size: 18px !important; }
.mi-lg { font-size: 28px !important; }

.titlebar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 10px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(145deg, #eaf3fc, #d7e9f9);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15, 108, 189, 0.12);
  animation: markIn 560ms var(--ease-out);
}
.brand-mark.lg {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}
.brand-mark .material-symbols-outlined { font-size: 18px; }
.brand-mark.lg .material-symbols-outlined { font-size: 26px; }
@keyframes markIn {
  from { opacity: 0; transform: scale(0.86) rotate(-8deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.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: 6px;
  background: transparent; color: var(--ink);
  padding: 6px 10px; height: 34px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 160ms var(--ease), transform 140ms var(--ease), color 160ms var(--ease);
}
.icon-btn { width: 34px; padding: 0; justify-content: center; }
.icon-btn:hover, .text-btn:hover { background: rgba(0, 0, 0, 0.05); }
.icon-btn:active, .text-btn:active { transform: scale(0.97); }

.nav-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #f4f6f8;
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition:
    background 180ms var(--ease),
    border-color 180ms var(--ease),
    transform 140ms var(--ease),
    box-shadow 180ms var(--ease),
    color 180ms var(--ease);
}
.nav-toggle:hover {
  background: #eaf3fc;
  border-color: #cfe4f6;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 108, 189, 0.12);
}
.nav-toggle:active { transform: scale(0.96); }
.nav-toggle-ico {
  width: 18px;
  height: 18px;
  transition: transform 280ms var(--ease-out);
}
.shell.rail-collapsed .nav-toggle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.shell.rail-collapsed .nav-toggle-ico {
  transform: rotate(90deg);
}

.toast {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 80;
  min-width: 220px;
  max-width: min(420px, 92vw);
  padding: 12px 14px;
  border-radius: 10px;
  background: #1f1f1f;
  color: #fff;
  box-shadow: var(--shadow);
  animation: toastIn 280ms var(--ease-out);
}
.toast.ok { background: #0f7b3c; }
.toast.err { background: var(--danger); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.kook-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.kook-cell strong { font-size: 13px; font-weight: 600; }
.kook-cell small { color: var(--muted); font-family: Consolas, monospace; font-size: 11px; }

.edit-drawer {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #cfe4f6;
  border-radius: 10px;
  background: #f7fbff;
  animation: rise 280ms var(--ease-out);
}

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

.rail {
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  width: var(--rail);
  min-width: 0;
  opacity: 1;
  transform: translateX(0);
  transition:
    transform 420ms var(--ease-out),
    opacity 280ms var(--ease),
    width 420ms var(--ease-out),
    border-color 280ms var(--ease);
  transform-origin: left center;
  will-change: transform, opacity, width;
}
.shell.rail-collapsed .rail {
  width: 0;
  border-right-color: transparent;
  transform: translateX(-18px);
  opacity: 0;
  pointer-events: none;
}

.rail nav {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 4px;
  width: var(--rail);
}
.nav {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; text-align: left;
  padding: 10px 12px; border-radius: 8px; color: var(--ink);
  transition: background 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease);
}
.nav .material-symbols-outlined {
  color: var(--muted);
  transition: color 160ms var(--ease), transform 220ms var(--ease-out);
}
.nav:hover { background: #f5f5f5; transform: translateX(2px); }
.nav:hover .material-symbols-outlined { color: var(--ink); transform: scale(1.06); }
.nav:active { transform: translateX(1px) scale(0.99); }
.nav.active {
  background: #eaf3fc;
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav.active .material-symbols-outlined {
  color: var(--accent);
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
  transform: scale(1.08);
}

.main {
  padding: 22px 28px 40px;
  width: 100%;
  min-width: 0;
  animation: viewIn 380ms var(--ease-out);
}
.main.swap {
  animation: viewIn 380ms var(--ease-out);
}

.logs-rail {
  border-left: 1px solid var(--line);
  background: #fafbfc;
  width: var(--logs);
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
  position: sticky;
  top: 48px;
  overflow: hidden;
  opacity: 1;
  transform: translateX(0);
  transition:
    transform 420ms var(--ease-out),
    opacity 280ms var(--ease),
    width 420ms var(--ease-out),
    border-color 280ms var(--ease);
  will-change: transform, opacity, width;
}
.shell.logs-collapsed .logs-rail {
  width: 0;
  border-left-color: transparent;
  transform: translateX(18px);
  opacity: 0;
  pointer-events: none;
}
.logs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.logs-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  min-width: 0;
}
.logs-title .material-symbols-outlined {
  color: var(--accent);
  font-size: 18px;
}
.logs-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--muted);
}
.logs-list {
  flex: 1;
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.logs-empty {
  margin: 24px 8px;
  text-align: center;
  font-size: 13px;
}
.log-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  animation: rise 320ms var(--ease-out) both;
  transition: border-color 160ms var(--ease), transform 160ms var(--ease);
}
.log-item:hover {
  border-color: #d0d7de;
  transform: translateY(-1px);
}
.log-item:nth-child(1) { animation-delay: 20ms; }
.log-item:nth-child(2) { animation-delay: 40ms; }
.log-item:nth-child(3) { animation-delay: 60ms; }
.log-item:nth-child(4) { animation-delay: 80ms; }
.log-item:nth-child(5) { animation-delay: 100ms; }
.log-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.log-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.log-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.log-actor {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  word-break: break-all;
}
.log-detail {
  font-size: 12px;
  color: #444;
  line-height: 1.4;
  word-break: break-word;
  font-family: Consolas, "Segoe UI Mono", monospace;
}
.logs-toggle.active {
  background: #eaf3fc;
  color: var(--accent);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
}
.page-title .material-symbols-outlined {
  color: var(--accent);
  font-size: 26px;
  animation: iconPop 420ms var(--ease-out);
}
@keyframes iconPop {
  from { opacity: 0; transform: scale(0.7) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 {
  font-size: 15px; font-weight: 600; margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
h2 .material-symbols-outlined { font-size: 18px; color: var(--muted); }
.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), border-color 200ms var(--ease);
  animation: rise 420ms var(--ease-out) both;
  position: relative;
  overflow: hidden;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.stat::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 108, 189, 0.08), transparent 70%);
  pointer-events: none;
}
.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stat-head .material-symbols-outlined {
  color: var(--accent);
  opacity: 0.85;
  font-size: 22px;
  transition: transform 280ms var(--ease-out);
}
.stat:hover .stat-head .material-symbols-outlined {
  transform: translateY(-2px) scale(1.08);
}
.stat:nth-child(1) { animation-delay: 40ms; }
.stat:nth-child(2) { animation-delay: 80ms; }
.stat:nth-child(3) { animation-delay: 120ms; }
.stat:nth-child(4) { animation-delay: 160ms; }
.stat:nth-child(5) { animation-delay: 200ms; }
.stat:nth-child(6) { animation-delay: 240ms; }
.stat:nth-child(7) { animation-delay: 280ms; }
.stat:nth-child(8) { animation-delay: 320ms; }
.stat:nth-child(9) { animation-delay: 360ms; }
.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: #d6d6d6;
}
.stat b { display: block; font-size: 22px; margin-top: 4px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  animation: rise 400ms var(--ease-out) both;
}
.panel:nth-of-type(2) { animation-delay: 60ms; }

.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);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease), transform 140ms var(--ease);
}
input:hover, select:hover { border-color: #cfcfcf; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 108, 189, 0.18);
}

.primary, .ghost, .danger {
  border-radius: 6px; border: 1px solid transparent; padding: 8px 14px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), transform 140ms var(--ease), box-shadow 160ms var(--ease);
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(15, 108, 189, 0.28); }
.primary:active, .ghost:active, .danger:active { transform: scale(0.97); }
.ghost { background: #fff; border-color: var(--line); color: inherit; text-decoration: none; }
.ghost:hover { background: #f7f7f7; }
.danger { background: #fff; color: var(--danger); border-color: #f3c6c2; }
.danger:hover { background: #fff5f4; }
.primary .material-symbols-outlined,
.ghost .material-symbols-outlined,
.danger .material-symbols-outlined {
  font-size: 18px;
  transition: transform 180ms var(--ease);
}
.primary:hover .material-symbols-outlined,
.ghost:hover .material-symbols-outlined {
  transform: translateX(1px);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr {
  transition: background 140ms var(--ease), transform 160ms var(--ease);
  animation: rowIn 320ms var(--ease-out) both;
}
tbody tr:nth-child(1) { animation-delay: 20ms; }
tbody tr:nth-child(2) { animation-delay: 40ms; }
tbody tr:nth-child(3) { animation-delay: 60ms; }
tbody tr:nth-child(4) { animation-delay: 80ms; }
tbody tr:nth-child(5) { animation-delay: 100ms; }
tbody tr:nth-child(6) { animation-delay: 120ms; }
tbody tr:nth-child(7) { animation-delay: 140ms; }
tbody tr:nth-child(8) { animation-delay: 160ms; }
@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
tbody tr:hover { background: #fafafa; }
code { font-family: Consolas, "Segoe UI Mono", monospace; font-size: 12px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.tag .material-symbols-outlined { font-size: 14px; }
.tag.ok { background: #e8f6ee; color: #0f7b3c; }
.tag.warn { background: #fff4df; color: #9a6700; }
.tag.bad { background: #fdecec; color: #b42318; }
tr.row-warn { background: #fffaf0; }
tr.row-bad { background: #fff5f5; }

.result-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 12px;
}

.login-split {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  z-index: 50;
  background: #f5f5f5;
}
.login-hero {
  position: relative;
  background:
    radial-gradient(680px 420px at 18% 110%, rgba(180, 120, 60, 0.18), transparent 55%),
    #0b0b0b;
  color: #fff;
  overflow: hidden;
  animation: heroIn 560ms var(--ease-out);
}
@keyframes heroIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
.login-hero-foot {
  position: absolute;
  left: 48px;
  right: 48px;
  bottom: 56px;
}
.login-eyebrow {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}
.login-brand-name {
  margin: 0;
  font-family: Syne, "Noto Sans SC", sans-serif;
  font-size: clamp(48px, 7vw, 84px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.login-brand-sub {
  margin: 14px 0 0;
  font-size: 22px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}
.login-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background: #f5f5f5;
  animation: panelIn 560ms var(--ease-out);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.login-form {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-form h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #111;
}
.login-desc {
  margin: -6px 0 8px;
  color: #777;
  font-size: 13px;
}
.login-form label {
  gap: 8px;
  font-size: 13px;
  color: #666;
  font-weight: 500;
}
.login-form input {
  min-width: 0;
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: #e8f0fe;
  padding: 0 12px;
  color: #111;
  box-shadow: none;
}
.login-form input:hover { border-color: transparent; }
.login-form input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px #111;
  background: #eef4ff;
}
.login-submit {
  margin-top: 8px;
  height: 48px;
  border: 0;
  border-radius: 0;
  background: #111;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  transition: background 160ms var(--ease), transform 120ms var(--ease);
}
.login-submit:hover { background: #000; }
.login-submit:active { transform: scale(0.99); }
.login-foot {
  margin: 8px 0 0;
  color: #999;
  font-size: 12px;
  line-height: 1.5;
}
.login-form .error { margin: 0; min-height: 1.2em; font-size: 13px; }

@media (max-width: 860px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { min-height: 34vh; }
  .login-hero-foot { left: 28px; right: 28px; bottom: 28px; }
  .login-brand-name { font-size: 44px; }
  .login-brand-sub { font-size: 18px; }
}

@media (max-width: 1100px) {
  .shell,
  .shell.rail-collapsed,
  .shell.logs-open,
  .shell.rail-collapsed.logs-open {
    grid-template-columns: var(--rail) minmax(0, 1fr);
  }
  .shell.rail-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }
  .shell.logs-collapsed,
  .shell.rail-collapsed.logs-collapsed {
    grid-template-columns: var(--rail) minmax(0, 1fr);
  }
  .shell.rail-collapsed.logs-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }
  .logs-rail {
    position: fixed;
    top: 48px;
    right: 0;
    bottom: 0;
    width: min(340px, 90vw);
    z-index: 28;
    box-shadow: var(--shadow);
    transform: translateX(105%);
    opacity: 1;
    border-left: 1px solid var(--line);
  }
  .shell.logs-open .logs-rail {
    transform: translateX(0);
    pointer-events: auto;
  }
  .shell.logs-collapsed .logs-rail {
    transform: translateX(105%);
    width: min(340px, 90vw);
    opacity: 1;
    pointer-events: none;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
    position: relative;
  }
  .shell.rail-collapsed,
  .shell.rail-open,
  .shell.logs-open,
  .shell.logs-collapsed,
  .shell.rail-collapsed.logs-collapsed,
  .shell.rail-collapsed.logs-open {
    grid-template-columns: 1fr;
  }
  .rail {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    z-index: 30;
    box-shadow: var(--shadow);
    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;
  }
}
