:root {
  --bg: #0b0d11;
  --surface: #11151b;
  --surface-2: #171c24;
  --line: #2a3039;
  --text: #eef1f4;
  --muted: #858e9a;
  --blue: #82aee8;
  --cyan: #78c9bf;
  --red: #e87d89;
  --green: #72cf9e;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 25% 5%, rgba(70, 94, 126, .12), transparent 32%), var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
code, .mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
[v-cloak] { display: none; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  background: rgba(11, 13, 17, .86);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; margin-right: auto; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: #d6dce5; color: #171b21; font-weight: 850; }
.brand b, .brand small { display: block; }
.brand b { font-size: 14px; letter-spacing: .01em; }
.brand small { font-size: 9px; color: var(--muted); letter-spacing: .18em; margin-top: 2px; }
.endpoint { display: flex; align-items: center; gap: 9px; color: #a8b0bb; font-size: 12px; background: #10141a; border: 1px solid var(--line); border-radius: 100px; padding: 8px 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(114, 207, 158, .6); }

.button { border: 1px solid transparent; border-radius: 9px; padding: 10px 16px; color: var(--text); background: var(--surface-2); font-weight: 650; transition: .18s ease; }
.button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button.primary { color: #101419; background: #d4dbe4; box-shadow: 0 8px 22px rgba(120, 140, 165, .13); }
.button.ghost { border-color: var(--line); background: rgba(20, 25, 32, .8); }
.button.compact { padding: 8px 11px; font-size: 12px; }
.button.wide { width: 100%; padding: 12px; }

.login-shell { min-height: calc(100vh - 72px); max-width: 1080px; margin: auto; padding: 70px 32px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 10vw; align-items: center; }
.session-gate { min-height: calc(100vh - 72px); display: grid; place-items: center; padding: 32px; }
.session-gate-card { display: flex; align-items: center; gap: 14px; color: #99a9bc; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.session-spinner { width: 18px; height: 18px; border: 2px solid rgba(153, 169, 188, .22); border-top-color: #9cb4cf; border-radius: 50%; animation: session-spin .75s linear infinite; }
@keyframes session-spin { to { transform: rotate(360deg); } }
.hero-copy h1 { font-size: clamp(46px, 5.5vw, 72px); letter-spacing: -.055em; line-height: 1; margin: 20px 0 28px; }
.hero-copy h1 em { font-style: normal; color: #99a9bc; }
.hero-copy > p { max-width: 560px; color: #969faa; line-height: 1.85; font-size: 16px; }
.eyebrow, .card-kicker { font-size: 10px; letter-spacing: .2em; color: var(--cyan); font-weight: 800; }
.protocol-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 26px; }
.protocol-list span { font-size: 11px; color: #939ca7; border: 1px solid var(--line); background: rgba(16, 20, 26, .7); padding: 7px 10px; border-radius: 7px; }

.login-card { max-width: 410px; width: 100%; justify-self: end; padding: 32px; background: linear-gradient(145deg, rgba(24, 29, 37, .96), rgba(15, 18, 24, .96)); border: 1px solid #2d343e; border-radius: 18px; box-shadow: var(--shadow); }
.login-card h2 { font-size: 26px; margin: 12px 0 6px; }
.login-card > p { color: var(--muted); margin: 0 0 25px; }
.login-card label, .modal label { display: block; color: #b3bbc5; font-size: 13px; font-weight: 650; margin-bottom: 17px; }
.login-card input, .modal input, .modal select, .modal textarea, .filters input, .filters select, .test-form input, .test-form select { display: block; width: 100%; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; background: #0d1116; color: var(--text); padding: 10px 12px; outline: none; }
.login-card input:focus, .modal input:focus, .modal select:focus, .modal textarea:focus, .filters input:focus, .filters select:focus, .test-form input:focus, .test-form select:focus { border-color: #6684aa; box-shadow: 0 0 0 3px rgba(102, 132, 170, .12); }
.modal textarea { resize: vertical; min-height: 150px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; line-height: 1.55; }
.captcha-row { display: grid; grid-template-columns: 1fr 170px; gap: 10px; align-items: stretch; margin-top: 8px; }
.captcha-row input { margin-top: 0; text-transform: uppercase; letter-spacing: .16em; }
.captcha-image { height: 42px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #0d1116; color: var(--muted); }
.captcha-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.captcha-image:hover { border-color: #6684aa; }
.turnstile-wrap { min-height: 65px; margin: 8px 0 12px; }
.path-editor { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.path-editor input { min-width: 0; }
.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 4px 0 15px; }
.alert.error { background: rgba(232, 84, 104, .09); border: 1px solid rgba(232, 84, 104, .23); color: #f09aa4; }
.alert.warning { background: rgba(221, 174, 84, .08); border: 1px solid rgba(221, 174, 84, .22); color: #ddbc7f; }

.dashboard { max-width: 1460px; margin: auto; padding: 46px clamp(20px, 4vw, 58px) 80px; }
.welcome-row { display: flex; justify-content: space-between; gap: 28px; align-items: flex-end; margin-bottom: 30px; }
.welcome-row h1 { font-size: 36px; letter-spacing: -.04em; margin: 10px 0 8px; }
.welcome-row p, .panel-head p, .test-panel p, .usage-panel p { color: var(--muted); margin: 0; }
.welcome-actions { display: flex; gap: 9px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 17px; }
.stat-card { min-height: 138px; padding: 22px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, rgba(20, 25, 32, .94), rgba(14, 17, 22, .94)); overflow: hidden; }
.stat-card span, .stat-card small { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; font-size: 29px; letter-spacing: -.04em; margin: 14px 0 6px; }
.stat-card strong.online { color: var(--green); font-size: 20px; letter-spacing: .04em; }
.stat-card small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel { border: 1px solid var(--line); border-radius: 14px; background: rgba(16, 20, 26, .9); box-shadow: 0 12px 34px rgba(0, 0, 0, .16); }
.panel-head { padding: 23px; display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; border-bottom: 1px solid var(--line); }
.panel h2, .panel-head h2 { margin: 0 0 7px; font-size: 18px; }
.panel-head code { color: #aac1de; }
.filters { display: flex; gap: 8px; align-items: center; }
.filters input, .filters select { margin: 0; min-width: 190px; padding: 9px 11px; }
.filters select { min-width: 118px; }
.alert.inside { margin: 16px 23px 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1000px; }
th, td { text-align: left; padding: 14px 17px; border-bottom: 1px solid rgba(42, 48, 57, .75); font-size: 13px; }
th { color: #7f8893; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 800; background: rgba(9, 12, 16, .35); }
tbody tr { transition: .15s; }
tbody tr:hover { background: rgba(110, 140, 180, .035); }
tbody tr.discovery-source-row { background: rgba(120, 201, 191, .035); }
tbody tr.discovery-source-row:hover { background: rgba(120, 201, 191, .065); }
tbody tr:last-child td { border-bottom: 0; }
.state, .type-badge { display: inline-flex; border-radius: 6px; padding: 5px 7px; font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.state.on { background: rgba(73, 207, 144, .1); color: var(--green); }
.state.off { background: rgba(140, 149, 160, .1); color: #929ba7; }
.type-badge { background: rgba(105, 145, 198, .12); color: #9bb8de; }
.name-cell { color: #dce4ee; }
.value-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #aeb7c2; }
.muted { color: var(--muted); }
.row-actions { white-space: nowrap; }
.row-actions button { border: 0; background: transparent; color: #91add1; font-size: 12px; padding: 4px 6px; }
.row-actions button.danger-text { color: #d9828c; }
.empty { text-align: center; color: var(--muted); padding: 46px; }

.bottom-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 17px; margin-top: 17px; }
.test-panel, .usage-panel { padding: 23px; }
.test-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 19px; }
.test-form { display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: start; }
.test-form input, .test-form select { margin: 0; }
.test-result { grid-column: 1 / -1; padding: 13px; border: 1px solid var(--line); background: #0c1015; border-radius: 9px; color: #aeb7c2; font-size: 13px; }
.test-result span { font-weight: 800; margin-right: 12px; }
.test-result .match { color: var(--green); }
.test-result .miss { color: #ddb16f; }
.test-result div { margin-top: 8px; }
.usage-panel p { line-height: 1.65; }
.copy-box { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 19px; border: 1px solid var(--line); background: #0a0e12; color: #abc0da; border-radius: 9px; padding: 13px; text-align: left; }
.copy-box code { overflow: hidden; text-overflow: ellipsis; }
.copy-box span { color: var(--cyan); font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(3, 5, 8, .8); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(7px); }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow: auto; border: 1px solid #303741; border-radius: 16px; background: #13171e; padding: 27px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.modal-head h2 { margin: 9px 0 0; }
.close { border: 0; background: transparent; color: #8e97a2; font-size: 28px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.modal label small { display: block; color: #747d88; font-weight: 400; margin-top: 7px; line-height: 1.4; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 9px; }
.settings-copy { color: var(--muted); line-height: 1.7; margin: -8px 0 23px; }
.switch-row { display: flex !important; align-items: center; justify-content: space-between; padding: 15px; border: 1px solid var(--line); border-radius: 9px; }
.switch-row span b, .switch-row span small { display: block; }
.switch-row span small { margin-top: 4px !important; }
.switch-row input { width: 18px !important; height: 18px; margin: 0 !important; }
.settings-modal > label:not(.switch-row) { margin-top: 21px; }
.logs-modal { width: min(1180px, 100%); }
.log-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; margin-bottom: 16px; }
.log-stats span { padding: 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 11px; }
.log-stats b { display: block; color: var(--text); font-size: 19px; margin-bottom: 4px; }
.log-toolbar { display: grid; grid-template-columns: minmax(180px, 1fr) 120px 110px auto auto; gap: 8px; margin-bottom: 14px; }
.log-toolbar input, .log-toolbar select { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: #0d1116; color: var(--text); padding: 9px 11px; outline: none; }
.danger-outline { color: #e3939c; border-color: rgba(232, 125, 137, .35) !important; }
.log-table { max-height: 52vh; border: 1px solid var(--line); border-radius: 9px; }
.log-table table { min-width: 1180px; }
.diagnostic { position: relative; }
.diagnostic summary { color: #9bb8de; cursor: pointer; font-size: 11px; white-space: nowrap; }
.diagnostic pre { width: min(560px, 72vw); max-height: 360px; overflow: auto; margin: 10px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #080b0f; color: #aebdcd; font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-time { white-space: nowrap; color: var(--muted); }
.log-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 14px; color: var(--muted); font-size: 12px; }

@media (max-width: 1000px) {
  .login-shell { gap: 6vw; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; }
  .filters input { flex: 1; }
  .bottom-grid { grid-template-columns: 1fr; }
  .endpoint { display: none; }
}
@media (max-width: 720px) {
  .topbar { height: 66px; padding: 0 14px; }
  .login-shell { min-height: auto; padding: 50px 20px; display: block; }
  .hero-copy h1 { font-size: 46px; }
  .hero-copy { margin-bottom: 46px; }
  .login-card { justify-self: auto; padding: 25px; }
  .dashboard { padding: 30px 14px 60px; }
  .welcome-row { align-items: flex-start; flex-direction: column; }
  .welcome-actions { width: 100%; }
  .welcome-actions .button { flex: 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .filters { display: grid; grid-template-columns: 1fr 110px auto; }
  .filters input, .filters select { min-width: 0; }
  .test-panel { grid-template-columns: 1fr; }
  .test-form { grid-template-columns: 1fr 80px auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .modal { padding: 21px; }
  .log-stats { grid-template-columns: repeat(2, 1fr); }
  .log-toolbar { grid-template-columns: 1fr 1fr; }
  .log-toolbar input { grid-column: 1 / -1; }
}
@media (max-width: 450px) {
  .brand small { display: none; }
  .topbar { gap: 7px; }
  .button.compact { padding: 7px 9px; }
  .stats-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .filters .button { width: 100%; }
  .test-form { grid-template-columns: 1fr 90px; }
  .test-form .button { grid-column: 1 / -1; }
  .hero-copy h1 { font-size: 39px; }
  .captcha-row { grid-template-columns: 1fr 150px; }
}
