:root {
  --bg: #e8eef4;
  --bg-elev: #f7fafc;
  --ink: #0d1b2a;
  --muted: #5a6b7d;
  --line: #c5d0dc;
  --accent: #1a6f8a;
  --accent-ink: #0c3d4d;
  --accent-soft: rgba(26, 111, 138, 0.12);
  --warn: #b45309;
  --danger: #b42318;
  --ok: #1a6f8a;
  --shadow: 0 20px 48px rgba(13, 27, 42, 0.1);
  --font-display: "Syne", "Avenir Next", sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(900px 480px at 0% 0%, #d4e8f0 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 10%, #dfe6f2 0%, transparent 50%),
    linear-gradient(165deg, #f0f5f9 0%, var(--bg) 45%, #d9e3ec 100%);
  background-attachment: fixed;
}

body {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.sidebar {
  padding: 1.6rem 1rem;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(247, 250, 252, 0.92), rgba(232, 238, 244, 0.85));
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  position: relative;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, #1a6f8a, #3d8fa8 40%, transparent);
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
  padding-left: 0.35rem;
}

.brand span {
  display: block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.4rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.nav a {
  padding: 0.72rem 0.9rem;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 160ms ease, transform 160ms ease, color 160ms ease;
}

.nav a:hover {
  background: var(--accent-soft);
  text-decoration: none;
  transform: translateX(3px);
}

.nav a.active {
  background: var(--ink);
  color: #eef6fa;
}

.sidebar-foot {
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 0.35rem;
}

main {
  padding: 2rem 2.2rem 3rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.35rem;
  letter-spacing: -0.04em;
  font-weight: 750;
}

.page-head p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  max-width: 42rem;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  animation: rise 420ms ease both;
}

.panel + .panel { margin-top: 1rem; }

.panel h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(12, 1fr);
}

.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.metric {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.metric .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 700;
}

.metric .value {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 500;
}

.metric .hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  min-height: 1.1em;
  word-break: break-word;
}

.bar {
  height: 9px;
  background: #d7e0e8;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.55rem;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2487a3, #1a6f8a);
  border-radius: inherit;
  transition: width 500ms ease;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.4rem;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

td.mono { font-family: var(--font-mono); font-size: 0.88rem; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--ink);
  color: #eef6fa;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn.secondary {
  background: transparent;
  color: var(--accent-ink);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.danger-zone {
  border: 2px solid rgba(180, 35, 24, 0.45);
  background: linear-gradient(165deg, #fff8f7 0%, #fff 55%);
}

.danger-zone h2 {
  margin: 0 0 0.65rem;
  font-family: Syne, sans-serif;
  font-size: 1.15rem;
  color: var(--danger);
}

.danger-lead {
  margin: 0 0 0.85rem;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.45;
}

.danger-list {
  margin: 0 0 1.1rem;
  padding-left: 1.2rem;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.45;
}

.danger-list li { margin-bottom: 0.35rem; }

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.actions .btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

td .actions {
  justify-content: flex-end;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
}

label.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

input, select {
  font: inherit;
  font-weight: 500;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus {
  outline: 2px solid rgba(26, 111, 138, 0.35);
  border-color: var(--accent);
}

.toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  background: var(--ink);
  color: #eef6fa;
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
  max-width: min(28rem, calc(100vw - 2rem));
  z-index: 50;
  font-weight: 600;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.badge.warn { background: #f3e2d2; color: var(--warn); }
.badge.bad { background: #f3d7dc; color: var(--danger); }
.badge.ok { background: #d8eee3; color: #176848; }

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  grid-template-columns: 1fr;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  padding: 2rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: rise 500ms ease both;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, #1a6f8a, #5eb3c9);
}

.login-card h1 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 2.1rem;
  letter-spacing: -0.04em;
}

.login-card p {
  margin: 0 0 1.4rem;
  color: var(--muted);
}

label.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1.1rem;
  font-size: 0.92rem;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

label.check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.follow-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  user-select: none;
}

.follow-toggle input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.log-panel {
  display: flex;
  flex-direction: column;
  min-height: min(70vh, 40rem);
  padding: 0;
  overflow: hidden;
}

.log-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  font-family: var(--font-mono);
}

.log-view {
  margin: 0;
  flex: 1;
  min-height: 24rem;
  max-height: calc(100vh - 14rem);
  overflow: auto;
  padding: 1rem 1.1rem;
  background: #0f1a24;
  color: #d7e6ef;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.console-panel .log-view {
  max-height: calc(100vh - 18rem);
}

.console-compose {
  position: relative;
  border-top: 1px solid var(--line);
  background: rgba(247, 250, 252, 0.92);
}

.console-suggest {
  position: absolute;
  left: 0.55rem;
  right: 0.55rem;
  bottom: calc(100% + 0.25rem);
  max-height: 16rem;
  overflow: auto;
  background: #0f1a24;
  border: 1px solid #2a3d4f;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(13, 27, 42, 0.28);
  z-index: 5;
  padding: 0.25rem;
}

.suggest-row {
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  color: #d7e6ef;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.suggest-row:hover,
.suggest-row.active {
  background: rgba(126, 200, 227, 0.16);
}

.suggest-icon {
  width: 1.15rem;
  height: 1.15rem;
  image-rendering: pixelated;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
}

.suggest-icon-empty {
  display: inline-block;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.suggest-badge {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 3px;
  background: rgba(126, 200, 227, 0.18);
  color: #7ec8e3;
  font-weight: 700;
  font-size: 0.7rem;
}

.suggest-main {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.suggest-sub {
  color: #7a8b9a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.console-form {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 0.9rem;
  border-top: 0;
  background: transparent;
}

.console-prompt {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  user-select: none;
}

.console-form input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.console-cmd { color: #7ec8e3; }
.console-out { color: #d7e6ef; }
.console-err { color: #f0a0a0; }
.console-muted { color: #7a8b9a; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar::after { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .col-4, .col-6, .col-8 { grid-column: span 12; }
  main { padding: 1.25rem; }
  .page-head { flex-direction: column; align-items: start; }
}
