:root {
  color-scheme: dark;
  --ink: #edf6ff;
  --ink-soft: #c7d7e7;
  --muted: #8ca0b7;
  --line: rgba(150, 186, 219, .16);
  --line-strong: rgba(150, 186, 219, .27);
  --panel: rgba(13, 30, 49, .82);
  --panel-solid: #0c1d30;
  --cyan: #39e7d0;
  --blue: #5ca8ff;
  --amber: #ffbd66;
  --danger: #ff7186;
  --bg: #07111f;
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 82% -5%, rgba(48, 137, 170, .2), transparent 30rem),
    radial-gradient(circle at -8% 62%, rgba(42, 97, 163, .12), transparent 34rem),
    linear-gradient(120deg, #07111f, #091725 55%, #07121e);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a, button, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.eyebrow { margin: 0 0 10px; color: var(--cyan); font-size: 11px; font-weight: 850; letter-spacing: .2em; }
.muted { color: var(--muted); }
.error-text { color: var(--danger); }

/* Login */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; position: relative; }
.brand-panel, .login-panel { padding: clamp(32px, 7vw, 100px); display: flex; flex-direction: column; justify-content: center; }
.brand-panel { border-right: 1px solid var(--line); }
.brand-panel h1 { margin: 18px 0 24px; font-size: clamp(58px, 8vw, 112px); line-height: .86; letter-spacing: -.065em; }
.brand-copy { max-width: 540px; color: #a8bacd; font-size: clamp(16px, 2vw, 22px); line-height: 1.7; }
.brand-mark { display: flex; gap: 8px; align-items: end; height: 48px; }
.brand-mark span { display: block; width: 10px; border-radius: 10px; background: linear-gradient(var(--cyan), var(--blue)); }
.brand-mark span:nth-child(1) { height: 24px; }
.brand-mark span:nth-child(2) { height: 44px; }
.brand-mark span:nth-child(3) { height: 32px; }
.signal-line { margin-top: 54px; color: #698198; font-size: 10px; font-weight: 800; letter-spacing: .16em; display: flex; align-items: center; gap: 12px; }
.signal-line i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); }
.login-card {
  width: min(100%, 430px);
  margin: auto;
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(18, 42, 66, .88), rgba(7, 19, 34, .94));
  box-shadow: var(--shadow);
}
.login-card h2 { margin: 0; font-size: 36px; }
.login-card label { display: grid; gap: 8px; margin-top: 22px; color: #bdcbd9; font-size: 13px; font-weight: 700; }
.login-card input, .query-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px 16px;
  background: #071526;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.login-card input:focus, .query-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(57, 231, 208, .1); }
.password-field { display: grid; grid-template-columns: 1fr auto; position: relative; }
.password-field input { grid-column: 1 / -1; grid-row: 1; padding-right: 64px; }
.password-toggle { grid-column: 2; grid-row: 1; z-index: 1; border: 0; background: transparent; color: var(--cyan); padding: 0 14px; font-size: 12px; font-weight: 800; }
.login-card > form > button, .query-form button {
  width: 100%;
  margin-top: 26px;
  border: 0;
  border-radius: 13px;
  padding: 15px 18px;
  color: #031319;
  background: linear-gradient(100deg, var(--cyan), #68b8ff);
  font-weight: 900;
  display: flex;
  justify-content: space-between;
  transition: filter .18s, transform .18s;
}
.login-card > form > button:hover, .query-form button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.login-card button:disabled, .query-form button:disabled { opacity: .55; transform: none; }
.form-message { min-height: 20px; color: var(--muted); font-size: 13px; }
.form-message.error { color: var(--danger); }

/* Shared shell */
.topbar {
  height: 74px;
  padding: 0 clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(7, 17, 31, .82);
  backdrop-filter: blur(18px);
}
.wordmark { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.wordmark strong { letter-spacing: .12em; }
.wordmark em { color: var(--muted); font-style: normal; font-size: 12px; }
.mini-mark { display: flex; gap: 3px; align-items: end; }
.mini-mark i { width: 4px; height: 17px; background: var(--cyan); border-radius: 2px; }
.mini-mark i:nth-child(2) { height: 25px; }
.mini-mark i:nth-child(3) { height: 13px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.clock { color: var(--muted); font-size: 12px; margin-right: 8px; font-variant-numeric: tabular-nums; }
.icon-button, .quiet-button, .panel-close {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .035);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 13px;
  transition: border-color .18s, background .18s;
}
.icon-button:hover, .quiet-button:hover, .panel-close:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, .065); }
.icon-button { font-size: 20px; line-height: 1; }
.icon-button.is-refreshing { animation: spin .75s linear infinite; }
.dashboard-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 90px; position: relative; }

/* Home */
.hero { min-height: 260px; display: flex; align-items: center; justify-content: space-between; gap: 40px; border-bottom: 1px solid var(--line); }
.hero h1 { margin: 0 0 16px; font-size: clamp(42px, 7vw, 82px); letter-spacing: -.055em; text-wrap: balance; }
.hero > div > p:last-child { color: var(--muted); font-size: 17px; }
.summary-card { min-width: 270px; padding: 28px 0 28px 34px; border-left: 1px solid var(--line); }
.summary-primary { display: flex; align-items: baseline; gap: 18px; }
.summary-primary span { font-size: 72px; font-weight: 300; letter-spacing: -.08em; font-variant-numeric: tabular-nums; }
.summary-primary p { margin: 0; color: var(--muted); }
.summary-details { display: flex; gap: 28px; margin: 5px 0 24px; }
.summary-details div { display: flex; gap: 8px; align-items: baseline; }
.summary-details dt { color: var(--muted); font-size: 11px; }
.summary-details dd { margin: 0; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pulse { color: var(--cyan); font-size: 12px; font-weight: 800; }
.pulse.has-offline { color: var(--amber); }
.pulse i, .status-pill i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 7px; box-shadow: 0 0 12px currentColor; }
.section-block { padding-top: 52px; }
.section-title { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; }
.section-title h2 { margin: 0; font-size: 28px; }
.section-title > p { color: var(--muted); font-size: 12px; }
.service-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; transition: opacity .2s; }
.service-grid.loading:not(:has(.skeleton-card)) { opacity: .62; }
.service-card {
  min-height: 280px;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(17, 39, 61, .78), rgba(8, 21, 36, .88));
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.service-card::after { content: ""; position: absolute; inset: auto -20% -60% 35%; height: 170px; background: radial-gradient(circle, rgba(57, 231, 208, .08), transparent 68%); pointer-events: none; }
.service-card:hover { transform: translateY(-3px); border-color: rgba(57, 231, 208, .35); box-shadow: 0 18px 50px rgba(0, 0, 0, .2); }
.service-card.status-offline { background: linear-gradient(145deg, rgba(27, 37, 52, .78), rgba(9, 18, 30, .9)); }
.service-card.status-offline:hover { transform: none; border-color: var(--line); box-shadow: none; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.service-icon { font-size: 28px; color: var(--cyan); }
.status-offline .service-icon { color: #6d8094; }
.status-pill { font-size: 11px; color: var(--cyan); display: inline-flex; align-items: center; white-space: nowrap; }
.status-offline .status-pill { color: var(--danger); }
.latency { color: var(--muted); margin-left: 7px; padding-left: 7px; border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.category { margin: 35px 0 7px; color: var(--blue); font-size: 10px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.service-card h3 { margin: 0; font-size: 23px; }
.description { color: var(--muted); line-height: 1.65; font-size: 14px; flex: 1; }
.service-action {
  border: 0;
  border-top: 1px solid var(--line);
  padding: 17px 0 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  text-decoration: none;
  position: relative;
  z-index: 1;
}
.service-action:not(:disabled):hover { color: var(--cyan); }
.service-action:disabled { color: #536577; }
.service-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 17px; position: relative; z-index: 1; }
.service-controls button, .control-row button, .center-control button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(255, 255, 255, .035);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
  transition: border-color .18s, color .18s, background .18s;
}
.service-controls button:hover:not(:disabled), .control-row button:hover:not(:disabled), .center-control button:hover:not(:disabled) { border-color: rgba(57, 231, 208, .42); background: rgba(57, 231, 208, .08); color: var(--cyan); }
.service-controls button:disabled, .control-row button:disabled, .center-control button:disabled { opacity: .38; }
.skeleton-card { min-height: 280px; background: linear-gradient(100deg, rgba(17, 39, 61, .62) 20%, rgba(32, 58, 82, .74) 40%, rgba(17, 39, 61, .62) 60%); background-size: 240% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.operations-section { scroll-margin-top: 90px; }
.operations-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.operations-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-md); background: linear-gradient(145deg, rgba(17, 39, 61, .72), rgba(8, 21, 36, .84)); }
.operations-card > p { min-height: 46px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.operations-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.operations-heading > div { display: flex; align-items: center; gap: 10px; }
.operations-heading h3 { margin: 0; font-size: 18px; }
.operations-icon { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid rgba(57, 231, 208, .28); border-radius: 9px; color: var(--cyan); }
.operations-note, .funnel-status { color: var(--muted); font-size: 11px; font-weight: 750; }
.funnel-status::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }
.funnel-status.is-online { color: var(--cyan); }
.funnel-status.has-warning { color: var(--amber); }
.funnel-status.is-offline { color: var(--danger); }
.control-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 20px; }
.control-row .danger-control { color: #ff9aaa; }
.control-row .danger-control:hover:not(:disabled) { border-color: rgba(255, 113, 134, .45); background: rgba(255, 113, 134, .08); color: var(--danger); }
.center-control { margin-top: 14px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 15px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(7, 20, 35, .62); }
.center-control div { display: grid; gap: 4px; }
.center-control span { color: var(--muted); font-size: 12px; }
.operation-status { min-height: 20px; margin: 12px 2px 0; color: var(--muted); font-size: 12px; }
.query-panel { position: relative; scroll-margin-top: 94px; margin-top: 24px; padding: clamp(26px, 5vw, 50px); border: 1px solid rgba(57, 231, 208, .24); border-radius: 24px; background: rgba(10, 28, 45, .94); box-shadow: var(--shadow); }
.query-panel[hidden] { display: none; }
.query-panel h1, .query-panel h2 { margin: 0; }
.panel-close { position: absolute; right: 20px; top: 20px; font-size: 20px; }
.panel-home-link { display: inline-block; margin-bottom: 22px; color: var(--cyan); text-decoration: none; font-weight: 800; font-size: 13px; }
.query-form { display: grid; grid-template-columns: 1fr 150px; gap: 10px; margin-top: 24px; }
.query-form button { margin: 0; display: block; }
.query-result { margin-top: 24px; overflow: auto; }
.query-result article, .query-result > pre { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 10px; background: rgba(5, 15, 27, .55); }
.query-result pre { white-space: pre-wrap; color: #a9c0d4; }
.relay-panel { max-width: 760px; margin: 40px auto 0; }
.relay-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.relay-action { padding: 17px 0; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; padding: 12px 18px; border-radius: var(--radius-sm); background: var(--cyan); color: #031319; font-weight: 800; box-shadow: var(--shadow); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast[data-tone="error"] { background: var(--danger); color: #21040a; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty-state { grid-column: 1 / -1; padding: 50px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 18px; }
.empty-state strong { display: block; color: var(--ink); font-size: 18px; }
.empty-state p { margin: 8px 0 20px; }
.empty-state button { border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 16px; background: rgba(255, 255, 255, .04); color: var(--ink); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -140% 0; } }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .brand-panel { min-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand-panel h1 { font-size: 64px; }
  .signal-line { display: none; }
  .login-panel { padding-top: 36px; }
  .service-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { align-items: end; }
  .summary-card { min-width: 230px; }
}

@media (max-width: 620px) {
  .topbar { height: 64px; padding-inline: 14px; }
  .clock, .wordmark em { display: none; }
  .top-actions { gap: 7px; }
  .quiet-button { padding-inline: 11px; }
  .dashboard-shell { width: min(100% - 24px, 1280px); padding-top: 34px; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .hero { min-height: 300px; display: block; }
  .hero h1 { font-size: clamp(43px, 13vw, 54px); }
  .hero > div > p:last-child { font-size: 15px; line-height: 1.7; }
  .summary-card { border-left: 0; border-top: 1px solid var(--line); padding: 20px 0; margin-top: 28px; display: grid; grid-template-columns: auto 1fr; column-gap: 18px; align-items: center; }
  .summary-primary { grid-row: 1 / 3; display: block; }
  .summary-primary span { display: block; font-size: 54px; line-height: 1; }
  .summary-primary p { margin-top: 5px; font-size: 12px; }
  .summary-details { margin: 0 0 10px; }
  .pulse { align-self: start; }
  .section-block { padding-top: 38px; }
  .section-title { align-items: center; }
  .service-grid { grid-template-columns: 1fr; }
  .service-card, .skeleton-card { min-height: 245px; }
  .operations-grid { grid-template-columns: 1fr; }
  .operations-card > p { min-height: auto; }
  .center-control { align-items: stretch; flex-direction: column; }
  .center-control button { width: 100%; }
  .query-form, .relay-actions { grid-template-columns: 1fr; }
  .login-panel, .brand-panel { padding: 30px 22px; }
  .brand-panel { min-height: 36vh; }
  .brand-panel h1 { font-size: 54px; }
  .brand-copy { font-size: 15px; }
  .login-card { padding: 26px 22px; }
  .query-panel { border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
