:root {
  color-scheme: dark;
  --bg: #0c1015;
  --surface: #121820;
  --surface-2: #171f29;
  --line: #2b3946;
  --ink: #edf2f3;
  --muted: #91a0ab;
  --green: #58d49a;
  --amber: #f0b95f;
  --red: #ff7373;
  --blue: #77b8ff;
  font-family: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font-size: 16px; }
button, input { font: inherit; }
h1, h2, p { margin-top: 0; }

.shell { width: min(100% - 24px, 1440px); margin: 0 auto; padding: 24px 0 56px; }
.masthead { display: flex; flex-direction: column; gap: 24px; align-items: flex-start; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.kicker { margin: 0 0 8px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: 0; }
h1 { margin-bottom: 10px; font-size: 34px; line-height: 1.05; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 20px; line-height: 1.25; letter-spacing: 0; }
.lede { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.toolbar { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 14px; }
.last-update { color: var(--muted); font-size: 13px; white-space: nowrap; }
.icon-button, .primary-button { min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-button { font-size: 22px; line-height: 1; }
.icon-button:hover { border-color: var(--blue); color: var(--blue); }

.auth-panel { display: grid; gap: 20px; align-items: end; margin-top: 24px; padding: 22px; border: 1px solid var(--line); background: var(--surface); }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; outline: 0; background: var(--bg); color: var(--ink); font-size: 16px; }
input:focus { border-color: var(--blue); }
.primary-button { padding: 0 18px; border-color: var(--blue); background: var(--blue); color: #07111b; font-weight: 700; }
.error-text { margin: 0; color: var(--red); font-size: 13px; }

.notice { margin: 20px 0 0; padding: 13px 15px; border-left: 3px solid var(--amber); background: rgba(240,185,95,.08); color: var(--amber); font-size: 14px; line-height: 1.6; }
.critical-notice { border-color: var(--red); background: rgba(255,115,115,.08); color: var(--red); }
.clear-notice { border-color: var(--green); background: rgba(88,212,154,.07); color: var(--green); }

.instance-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 20px; }
.instance { display: flex; min-height: 336px; flex-direction: column; padding: 18px; border: 1px solid var(--line); background: var(--surface); }
.instance.critical { border-color: rgba(255,115,115,.75); }
.instance.watch { border-color: rgba(240,185,95,.7); }
.instance-head { display: flex; min-height: 91px; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.instance-name { margin: 0 0 6px; font-size: 20px; }
.instance-sub, .instance-domain { color: var(--muted); font-size: 12px; line-height: 1.5; }
.instance-domain { color: var(--blue); }
.state { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; color: var(--green); font-size: 12px; font-weight: 700; white-space: nowrap; }
.state.watch { color: var(--amber); }
.state.critical { color: var(--red); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 12px currentColor; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 12px; padding: 17px 0; }
.metric-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.metric-value { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.metric-value.warn, .metric-value.rising { color: var(--amber); }
.metric-value.bad { color: var(--red); }
.metric-value.falling { color: var(--green); }
.metric-value.muted { color: var(--muted); font-size: 16px; }
.instance-foot { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.45; }
.instance-foot span:first-child { color: var(--ink); font-weight: 600; }

.panel { padding: 20px; border: 1px solid var(--line); background: var(--surface); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.panel-note { max-width: 210px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: right; }
.backlog-panel { margin-top: 12px; }
.backlog-table { margin-top: 4px; }
.backlog-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.backlog-row:last-child { border-bottom: 0; padding-bottom: 0; }
.backlog-name { grid-column: 1 / -1; }
.backlog-name strong, .backlog-name span { display: block; }
.backlog-name strong { margin-bottom: 3px; font-size: 16px; }
.backlog-name span { color: var(--muted); font-size: 12px; }
.backlog-number strong, .backlog-change strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.backlog-number span, .backlog-change span { color: var(--muted); font-size: 11px; }
.backlog-change.rising strong { color: var(--amber); }
.backlog-change.falling strong { color: var(--green); }
.backlog-change.muted strong { color: var(--muted); font-size: 13px; }
.backlog-state { justify-self: start; padding: 5px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.backlog-state.ok { border-color: rgba(88,212,154,.5); color: var(--green); }
.backlog-state.watch { border-color: rgba(240,185,95,.6); color: var(--amber); }
.backlog-state.critical { border-color: rgba(255,115,115,.6); color: var(--red); }
.backlog-state.standby { border-color: var(--line); color: var(--blue); }
.backlog-row > p { grid-column: 2 / -1; margin: 0; color: var(--ink); font-size: 13px; text-align: right; }

.lower-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.mono { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-align: right; }
.signals { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 18px; background: var(--line); }
.signal { min-height: 84px; padding: 13px; background: var(--surface); }
.signal strong { display: block; margin-top: 7px; font-size: 21px; font-variant-numeric: tabular-nums; }
.signal span { color: var(--muted); font-size: 12px; line-height: 1.4; }
.signal-note { margin: 17px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.decision-row { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; padding: 15px 0; border-bottom: 1px solid var(--line); }
.decision-row p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.decision-label { padding: 4px 7px; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; font-weight: 700; text-align: center; }
.decision-label.ok { color: var(--green); }
.decision-label.watch { color: var(--amber); }
.decision-label.critical { color: var(--red); }
.status-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px var(--green); }
.watchdog-state { margin-top: 15px; padding: 11px 12px; background: var(--surface-2); color: var(--muted); font-size: 12px; line-height: 1.55; }
.action-button { width: 100%; min-height: 46px; margin-top: 14px; padding: 0 14px; border: 1px solid var(--amber); border-radius: 6px; background: transparent; color: var(--amber); cursor: pointer; font-weight: 700; }
.action-button:hover { background: rgba(240,185,95,.08); }
.action-button:disabled { cursor: wait; opacity: .55; }
.action-status { margin: 12px 0 0; color: var(--ink); font-size: 12px; }

@media (min-width: 720px) {
  .shell { width: min(100% - 40px, 1440px); padding-top: 36px; }
  .masthead { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  h1 { font-size: 48px; }
  .toolbar { width: auto; justify-content: flex-start; }
  .auth-panel { grid-template-columns: 1fr minmax(300px, 420px); }
  .auth-form { flex-direction: row; }
  .error-text { grid-column: 2; }
  .instance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .backlog-row { grid-template-columns: minmax(180px, 1.4fr) 90px 90px 90px 70px minmax(180px, 1fr); }
  .backlog-name { grid-column: auto; }
  .backlog-row > p { grid-column: auto; }
  .signals { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1180px) {
  .instance-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lower-grid { grid-template-columns: 1.25fr .75fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
