:root {
  --bg: #12110d;
  --bg-2: #18160f;
  --panel: #221f18;
  --line: #3c3628;
  --brass: #c9a227;
  --brass-2: #e8c96a;
  --ink: #f4efe4;
  --muted: #9a917f;
  --online: #5ad67a;
  --offline: #6e6758;
  --danger: #e05a4f;
  --warn: #e8a54b;
  --ok: #6ec8a0;
  --shadow: 0 18px 50px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.5 "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(201, 162, 39, .12), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(90, 214, 122, .06), transparent 50%),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 100% 4px;
  opacity: .35;
}

.layout { display: flex; min-height: 100vh; align-items: stretch; }
.sider {
  width: 228px;
  flex-shrink: 0;
  background: #18160f;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 12;
}
.sider-brand { padding: 22px 18px 16px; }
.sider-nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; }
.nav-item {
  appearance: none;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  line-height: 1.35;
}
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.03); }
.nav-item.active {
  color: var(--ink);
  border-color: var(--brass);
  background: rgba(201,162,39,.12);
}
.workspace { flex: 1; min-width: 0; }
.page.hidden { display: none !important; }

.topbar, main { width: auto; margin: 0; padding-left: 22px; padding-right: 22px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px 10px;
  position: sticky;
  top: 0;
  z-index: 11;
  background: linear-gradient(180deg, #12110d 72%, rgba(18,17,13,0));
}
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand p, .brand-lg p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.brand-lg { margin-bottom: 18px; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(160deg, #3a3324, #1a1813);
  border: 1px solid var(--brass);
  box-shadow: inset 0 0 0 3px #16140f, 0 0 0 1px rgba(201,162,39,.25);
  position: relative;
}
.mark::before, .mark::after {
  content: "";
  position: absolute;
  background: var(--brass-2);
  border-radius: 1px;
}
.mark::before { left: 16px; top: 8px; width: 3px; height: 20px; }
.mark::after { left: 9px; top: 16px; width: 17px; height: 3px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.live-hint { color: var(--muted); font-size: 12px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: #2a261c;
  color: var(--ink); border-radius: 8px; padding: 8px 12px; cursor: pointer;
  font: inherit;
}
.btn:hover { border-color: var(--brass); }
.btn.primary { background: linear-gradient(180deg, #d7b34a, #b48a1c); color: #1a1406; border-color: #e8c96a; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { background: #4a221e; border-color: #8a3d36; color: #ffd4cf; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--ink); cursor: pointer; font-size: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
  margin: 18px 0 14px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
}
.stat:hover, .stat.active { border-color: var(--brass); box-shadow: 0 0 0 1px rgba(201,162,39,.25); }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 24px; font-variant-numeric: tabular-nums; margin-top: 4px; letter-spacing: .02em; }
.stat.online .v { color: var(--online); }

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 5px 10px; cursor: pointer; font: inherit;
}
.chip.active { color: var(--ink); border-color: var(--brass); background: rgba(201,162,39,.12); }
.search input {
  width: min(280px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
.search input:focus { outline: 1px solid var(--brass); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid th { color: var(--muted); font-weight: 550; font-size: 12px; background: #1c1a14; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: rgba(255,255,255,.03); }
.grid tbody tr.selected { background: rgba(201,162,39,.08); }
.empty { text-align: center; color: var(--muted); padding: 48px 12px !important; cursor: default; }
.robot-id { font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 8px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.on { color: #baf7c8; border-color: rgba(90,214,122,.4); background: rgba(90,214,122,.08); }
.badge.off { color: var(--muted); }
.badge.warn { color: #ffe0a8; border-color: rgba(232,165,75,.45); background: rgba(232,165,75,.1); }
.badge.bad { color: #ffc7c1; border-color: rgba(224,90,79,.45); background: rgba(224,90,79,.1); }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--offline);
}
.badge.on .dot {
  background: var(--online);
  box-shadow: 0 0 0 0 rgba(90,214,122,.7);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(90,214,122,0); }
}

.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: var(--muted); font-size: 12px; }
.pager .pages { display: flex; gap: 6px; }

.overlay {
  position: fixed; inset: 0; background: rgba(8,7,5,.72);
  display: grid; place-items: center; z-index: 40; padding: 16px;
}
.drawer[hidden] { display: none !important; }
.overlay.hidden, .backdrop.hidden { display: none !important; }
.dialog {
  width: min(440px, 100%);
  background: #1d1b15;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.dialog h2 { margin: 0 0 12px; font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.field { display: block; margin: 12px 0; }
.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.field input, .field-select {
  width: 100%; background: #12110d; border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 9px 10px; font: inherit;
}
.field-select { display: block; }
.btn.hidden { display: none !important; }
.form-error { color: var(--danger); font-size: 13px; }
.month-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.month-picks button.active { border-color: var(--brass); color: var(--brass-2); }
.created-id { font-family: ui-monospace, Consolas, monospace; font-size: 18px; margin: 8px 0; }

.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 100%);
  background: #1b1914; border-left: 1px solid var(--line); z-index: 30;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px; overflow: auto; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px 10px; margin-bottom: 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.timeline li { padding: 0 0 14px 14px; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -4px; top: 6px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.timeline li.up::before { background: var(--online); }
.timeline li.down::before { background: var(--danger); }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 20; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: #2a261c; border: 1px solid var(--line); color: var(--ink);
  padding: 10px 12px; border-radius: 10px; min-width: 220px; box-shadow: var(--shadow);
}
.toast.ok { border-color: rgba(110,200,160,.5); }
.toast.err { border-color: rgba(224,90,79,.5); }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .grid th:nth-child(5), .grid td:nth-child(5) { display: none; }
  .layout { flex-direction: column; }
  .sider { width: 100%; height: auto; position: relative; border-right: 0; border-bottom: 1px solid var(--line); }
  .sider-nav { flex-direction: row; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
}
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .grid th:nth-child(4), .grid td:nth-child(4) { display: none; }
}
