:root {
  --bg: #0c0f12;
  --bg-elev: #14191f;
  --bg-soft: #1a2129;
  --line: #2a3440;
  --text: #e7edf4;
  --muted: #8b9aab;
  --amber: #e4a12c;
  --amber-dim: rgba(228, 161, 44, 0.16);
  --cyan: #4ecdc4;
  --danger: #ef5d4d;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --font: "IBM Plex Sans", "PingFang SC", "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(228, 161, 44, 0.08), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(78, 205, 196, 0.06), transparent 50%),
    var(--bg);
}

button, input, select { font: inherit; color: inherit; }
a { color: var(--cyan); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--amber);
  margin: 0 0 8px;
}

.btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: border-color .15s, background .15s, transform .1s, box-shadow .15s;
}
.btn:hover { border-color: #415062; background: #222b35; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #f0b84a, var(--amber));
  border-color: #c78a1c;
  color: #1a1205;
  box-shadow: 0 8px 20px rgba(228, 161, 44, 0.18);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger {
  background: rgba(239, 93, 77, 0.14);
  border-color: rgba(239, 93, 77, 0.45);
  color: #ffb4ab;
}
.btn.ghost { background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.main > .topbar,
.main > .stats,
.main > .panel {
  animation: rise .45s ease both;
}
.main > .stats { animation-delay: .05s; }
.main > .panel { animation-delay: .1s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 12px;
  font-size: 13px;
}
.alert.danger {
  background: rgba(239, 93, 77, 0.12);
  border: 1px solid rgba(239, 93, 77, 0.35);
  color: #ffb4ab;
}

.login-body {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -0.03em; }
.field { display: grid; gap: 6px; margin: 18px 0; }
.field span { font-size: 12px; color: var(--muted); }
.field input, .filters input:not([type="checkbox"]):not([type="radio"]), .filters select {
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f1419;
  padding: 0 12px;
  outline: none;
}
.field input:focus, .filters input:not([type="checkbox"]):not([type="radio"]):focus, .filters select:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-dim);
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(10, 13, 16, 0.92);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(228, 161, 44, 0.35);
}
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); }
.nav { display: grid; gap: 6px; }
.nav button {
  text-align: left;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
}
.nav button:hover { background: var(--bg-soft); color: var(--text); }
.nav button.active {
  background: var(--amber-dim);
  color: var(--amber);
}
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.refresh-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg-elev);
}
.refresh-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}
.refresh-interval {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.refresh-interval input {
  width: 56px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}
.refresh-interval input:focus {
  outline: none;
  border-color: var(--cyan);
}
.refresh-meta { margin-top: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.refresh-box.paused { border-color: rgba(239, 93, 77, 0.4); }
.refresh-box.paused .refresh-row { color: #ffb4ab; }

.main { padding: 22px 24px 40px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat b { font-size: 22px; font-family: var(--mono); font-weight: 600; }
.stat.ok b { color: var(--ok); }
.stat.danger b { color: var(--danger); }
.stat.warn b { color: var(--warn); }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.filters input:not([type="checkbox"]):not([type="radio"]),
.filters select { min-width: 140px; }

.col-picker { position: relative; }
.col-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: 168px;
  max-height: min(320px, 50vh);
  overflow: auto;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #10151b;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}
.col-picker-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  color: var(--text);
}
.col-picker-menu label:hover { background: rgba(255, 255, 255, 0.04); }
.col-picker-menu input[type="checkbox"] {
  width: 14px;
  height: 14px;
  min-width: 14px;
  margin: 0;
  flex: 0 0 14px;
  accent-color: var(--amber);
}
.col-picker-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.table-wrap { overflow: auto; max-height: calc(100vh - 320px); border: 1px solid var(--line); border-radius: 10px; }
.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data th, .data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.data th {
  position: sticky;
  top: 0;
  background: #12171d;
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
}
.data tbody tr { cursor: pointer; }
.data tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.data .mono { font-family: var(--mono); font-size: 12px; }
.mark-ok { color: var(--ok); font-weight: 700; }
.mark-fail { color: var(--danger); font-weight: 700; }
.mark-na { color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge.remote { background: rgba(78, 205, 196, 0.12); color: var(--cyan); }
.badge.warn { background: rgba(240, 180, 41, 0.14); color: var(--warn); }
.badge.danger { background: rgba(239, 93, 77, 0.14); color: #ffb4ab; }

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
}
.pager button, .pager span {
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pager button { cursor: pointer; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

.flag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.flag {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #10151b;
}
.flag.sensitive { border-color: rgba(240, 180, 41, 0.35); background: rgba(240, 180, 41, 0.05); }
.flag label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.flag .title { font-weight: 600; line-height: 1.35; }
.flag .key {
  display: block;
  margin-top: 4px;
  margin-left: 26px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.policy-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.note { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 14px; }

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elev);
  color: var(--text);
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog-inner { margin: 0; }
.dialog-inner header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.dialog-inner pre {
  margin: 0;
  padding: 14px;
  max-height: 60vh;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flag-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-wrap { max-height: none; }
}
