:root {
  --bg: #05080d;
  --sidebar: #070d14;
  --panel: #0a111a;
  --panel-2: #0d1621;
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.22);
  --text: #e8f1fa;
  --muted: #8a9bb0;
  --faint: #52657a;
  --accent: #2dd4bf;
  --accent-2: #67e8f9;
  --blue: #60a5fa;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: Consolas, "SFMono-Regular", Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
code { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: rgba(148, 163, 184, 0.08); font-family: var(--mono); font-size: 11px; }

.app-shell { display: grid; grid-template-columns: 212px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh;
  padding: 22px 14px 16px; border-right: 1px solid var(--line);
  background: radial-gradient(90% 40% at 10% 0%, rgba(45, 212, 191, 0.08), transparent 70%), var(--sidebar);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 22px; border-bottom: 1px solid var(--line); }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(103, 232, 249, 0.28); border-radius: 11px; background: linear-gradient(145deg, rgba(17, 83, 92, 0.7), rgba(7, 20, 31, 0.95)); color: var(--accent-2); font-size: 18px; font-weight: 800; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.brand-copy strong { display: block; font-size: 15px; letter-spacing: 0.18em; }
.brand-copy span { display: block; margin-top: 3px; color: var(--faint); font-family: var(--mono); font-size: 8px; letter-spacing: 0.12em; }
.nav { display: grid; gap: 4px; margin-top: 20px; }
.nav-item { display: flex; gap: 11px; align-items: center; width: 100%; padding: 10px 12px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #8798ab; text-align: left; transition: background 0.18s, color 0.18s, border-color 0.18s; }
.nav-item:hover { background: rgba(148, 163, 184, 0.06); color: var(--text); }
.nav-item.is-active { border-color: rgba(45, 212, 191, 0.18); background: rgba(45, 212, 191, 0.09); color: #c8fff7; }
.nav-icon { display: grid; width: 18px; place-items: center; color: var(--accent); font-family: var(--mono); font-size: 14px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--line); }
.server-state { display: flex; gap: 7px; align-items: center; color: var(--faint); font-size: 10px; }
.server-state i { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px rgba(251, 191, 36, 0.7); }
.server-state.is-online i { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.8); }
.server-state.is-offline i { background: var(--red); box-shadow: 0 0 8px rgba(251, 113, 133, 0.7); }
.logout { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); font-size: 10px; text-align: left; }
.logout:hover { border-color: var(--line-strong); color: var(--text); }

.main { min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; padding: 28px 34px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(11, 20, 30, 0.8), rgba(5, 8, 13, 0)); }
.topbar-eyebrow { color: var(--accent); font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em; }
.topbar h1 { margin: 7px 0 4px; font-size: 25px; font-weight: 700; letter-spacing: -0.02em; }
.topbar p { margin: 0; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; gap: 8px; }
.btn { display: inline-flex; gap: 7px; align-items: center; justify-content: center; padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(148, 163, 184, 0.06); color: var(--text); font-size: 11px; font-weight: 600; transition: background 0.18s, border-color 0.18s, transform 0.12s; }
.btn:hover { background: rgba(148, 163, 184, 0.11); border-color: rgba(148, 163, 184, 0.32); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: transparent; background: linear-gradient(135deg, #42e2cc, #22b8a5); color: #03221f; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { border-color: rgba(251, 113, 133, 0.28); background: rgba(251, 113, 133, 0.08); color: #fecdd3; }
.btn.danger:hover { background: rgba(251, 113, 133, 0.14); }
.btn.ghost { background: transparent; }
.btn:disabled { cursor: wait; opacity: 0.6; }
.content { padding: 22px 34px 50px; }
.view { animation: rise 0.28s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.stat-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.stat-card { position: relative; overflow: hidden; min-height: 106px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(150deg, rgba(148, 163, 184, 0.045), rgba(10, 17, 26, 0.7)); }
.stat-card::after { content: ""; position: absolute; right: -20px; bottom: -40px; width: 90px; height: 90px; border-radius: 50%; background: rgba(45, 212, 191, 0.06); }
.stat-card > span { display: block; color: var(--muted); font-size: 10px; }
.stat-card strong { display: block; margin: 11px 0 5px; font-family: var(--mono); font-size: 28px; font-weight: 600; letter-spacing: -0.04em; }
.stat-card small { color: var(--faint); font-size: 9px; }
.stat-card.accent strong { color: var(--accent-2); }
.stat-card.danger strong { color: var(--red); }

.panel { margin-top: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 650; }
.panel-head p { margin: 4px 0 0; color: var(--faint); font-size: 10px; }
.link-btn { border: 0; background: transparent; color: var(--accent); font-size: 10px; }
.link-btn:hover { color: var(--accent-2); }
.split-panel { display: grid; grid-template-columns: 260px 1fr; }
.split-panel .panel-head { grid-column: 1; border-right: 1px solid var(--line); border-bottom: 0; }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.meta-item { padding: 14px 16px; background: var(--panel); }
.meta-item span { display: block; color: var(--faint); font-size: 9px; }
.meta-item strong { display: block; margin-top: 5px; font-family: var(--mono); font-size: 11px; font-weight: 500; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--faint); font-size: 9px; font-weight: 600; letter-spacing: 0.08em; text-align: left; text-transform: uppercase; }
td { max-width: 360px; padding: 10px 12px; border-bottom: 1px solid rgba(148, 163, 184, 0.07); color: #b5c3d2; font-size: 11px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(148, 163, 184, 0.025); }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.empty { padding: 34px 12px; color: var(--faint); text-align: center; }
.cell-strong { color: var(--text); font-weight: 600; }
.cell-sub { display: block; margin-top: 3px; color: var(--faint); font-size: 9px; }
.mono { font-family: var(--mono); font-size: 10px; }
.ellipsis { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.url-cell { max-width: 280px; }
.url-cell a { color: #9cc9ee; text-decoration: none; }
.url-cell a:hover { text-decoration: underline; }
.badge { display: inline-flex; gap: 4px; align-items: center; padding: 3px 7px; border: 1px solid transparent; border-radius: 99px; font-size: 9px; }
.badge.green { border-color: rgba(52, 211, 153, 0.2); background: rgba(52, 211, 153, 0.08); color: #86efac; }
.badge.red { border-color: rgba(251, 113, 133, 0.2); background: rgba(251, 113, 133, 0.08); color: #fda4af; }
.badge.amber { border-color: rgba(251, 191, 36, 0.2); background: rgba(251, 191, 36, 0.08); color: #fde68a; }
.badge.gray { border-color: var(--line); background: rgba(148, 163, 184, 0.06); color: var(--muted); }
.badge.blue { border-color: rgba(96, 165, 250, 0.2); background: rgba(96, 165, 250, 0.08); color: #bfdbfe; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.mini-btn { padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-size: 9px; }
.mini-btn:hover { border-color: var(--line-strong); color: var(--text); }
.mini-btn.danger { color: #fda4af; border-color: rgba(251, 113, 133, 0.18); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 1px; }
.toolbar .search { flex: 1; max-width: 380px; }
input, select, textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: #08111a; color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: rgba(45, 212, 191, 0.55); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.07); }
input::placeholder { color: #4c5f73; }
select { color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: 10px; }
.pager div { display: flex; gap: 6px; align-items: center; }
.pager button { padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-size: 10px; }
.pager button:hover { color: var(--text); border-color: var(--line-strong); }
.pager span { min-width: 24px; text-align: center; font-family: var(--mono); }

.prose { padding: 22px 25px; color: #aebdcd; font-size: 12px; line-height: 1.9; }
.prose h2 { margin: 0 0 8px; color: var(--text); font-size: 14px; }
.prose h2:not(:first-child) { margin-top: 26px; }
.prose ol { padding-left: 20px; }
.prose li { margin: 7px 0; }
.prose p { margin: 8px 0; }

.modal { width: min(620px, calc(100vw - 40px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line-strong); border-radius: 15px; background: var(--panel); color: var(--text); box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65); }
.modal::backdrop { background: rgba(2, 5, 9, 0.72); backdrop-filter: blur(3px); }
.modal-card { padding: 22px; }
.modal-head { display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; margin-bottom: 19px; }
.modal-head h2 { margin: 6px 0 4px; font-size: 21px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 10px; }
.icon-btn { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); font-size: 17px; line-height: 1; }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 10px; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid .check-line { display: flex; flex-direction: row; gap: 8px; align-items: center; align-self: end; padding-bottom: 9px; color: #fda4af; }
.form-grid .check-line input { width: 14px; height: 14px; accent-color: var(--red); }
.quick-days { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 13px; color: var(--faint); font-size: 9px; }
.quick-days button { padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-size: 9px; }
.quick-days button:hover { border-color: rgba(45, 212, 191, 0.4); color: var(--accent); }
.alert { margin-top: 13px; padding: 10px 12px; border: 1px solid rgba(251, 113, 133, 0.25); border-radius: 8px; background: rgba(251, 113, 133, 0.07); color: #fda4af; font-size: 11px; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 21px; }
.modal-actions.between { justify-content: space-between; }
.modal-actions.between > div { display: flex; gap: 8px; }
.code-success { display: flex; gap: 12px; align-items: center; padding: 13px; border: 1px solid rgba(52, 211, 153, 0.2); border-radius: 9px; background: rgba(52, 211, 153, 0.06); }
.code-success > span { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: rgba(52, 211, 153, 0.16); color: var(--green); font-size: 15px; }
.code-success strong { display: block; font-size: 12px; }
.code-success p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.code-list { display: grid; gap: 7px; max-height: 290px; margin-top: 13px; overflow-y: auto; }
.code-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: #08111a; }
.code-row code { border: 0; background: transparent; color: var(--accent-2); font-size: 12px; letter-spacing: 0.04em; }
.code-row small { display: block; margin-top: 3px; color: var(--faint); font-size: 9px; }
.copy-btn { padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); font-size: 9px; }
.copy-btn:hover { color: var(--text); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; padding: 10px 15px; border: 1px solid rgba(45, 212, 191, 0.25); border-radius: 9px; background: #0c1a1d; color: #c8fff7; font-size: 11px; box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45); animation: toast-in 0.25s var(--ease); }
.toast.is-error { border-color: rgba(251, 113, 133, 0.3); background: #1b0d12; color: #fecdd3; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split-panel { grid-template-columns: 1fr; }
  .split-panel .panel-head { border-right: 0; border-bottom: 1px solid var(--line); }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; }
  .brand { border: 0; padding: 0 8px 0 0; }
  .nav { display: flex; flex-wrap: wrap; margin: 0; }
  .nav-item { width: auto; padding: 7px 9px; }
  .sidebar-foot { width: 100%; margin: 0; padding: 8px 0 0; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 20px; }
  .content { padding: 16px 20px 40px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { max-width: none; width: 100%; }
}

/* ---- client builder ---- */
.builder-panel { overflow: hidden; }
.builder-form { padding: 18px 18px 4px; }
.builder-form .form-grid { gap: 12px; }
.builder-form input[type="file"] { padding: 7px 9px; color: var(--muted); font-size: 10px; }
.icon-preview-line { display: flex; gap: 10px; align-items: center; margin-top: 12px; color: var(--faint); font-size: 9.5px; line-height: 1.5; }
.icon-preview-line img { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 9px; object-fit: contain; background: #08111a; }
.builder-actions { display: flex; justify-content: space-between; gap: 15px; align-items: center; margin: 16px 0 14px; }
.builder-note { color: var(--faint); font-size: 9.5px; }
.build-status { margin: 0 18px 18px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #08111a; }
.build-status-head { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 10px; }
.build-status-head strong { color: var(--text); font-size: 11px; }
.build-progress { height: 5px; margin-top: 9px; overflow: hidden; border-radius: 99px; background: rgba(148, 163, 184, 0.1); }
.build-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2dd4bf, #60a5fa); transition: width 0.4s var(--ease); }
.build-log { max-height: 190px; margin: 11px 0 12px; overflow: auto; color: #7f93a7; font-family: var(--mono); font-size: 9px; line-height: 1.65; white-space: pre-wrap; word-break: break-all; }
.build-status .btn { margin-top: 2px; }
@media (max-width: 780px) { .builder-actions { align-items: flex-start; flex-direction: column; } }

/* ---- grouped access log ---- */
.event-group-row td { background: rgba(12, 24, 36, 0.35); }
.event-detail-row td { padding: 0 14px 14px; background: #081019; }
.event-detail { padding: 12px 0 2px; }
.event-detail-head { margin-bottom: 8px; color: var(--muted); font-size: 10px; }
.nested-table { width: 100%; border-collapse: collapse; }
.nested-table th { padding: 7px 8px; color: var(--faint); font-size: 9px; text-align: left; border-bottom: 1px solid var(--line); }
.nested-table td { padding: 8px; font-size: 10px; border-bottom: 1px solid rgba(148, 163, 184, 0.08); vertical-align: top; }
.nested-table tr:last-child td { border-bottom: 0; }
.input-cell { min-width: 160px; }
.input-line { display: flex; gap: 6px; align-items: baseline; margin: 2px 0; line-height: 1.5; }
.input-line span { color: var(--faint); font-size: 9px; white-space: nowrap; }
.input-line b { color: #a7f3d0; font-weight: 500; word-break: break-all; }
.muted { color: var(--faint); }

.event-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-modes { display: flex; gap: 6px; }
