:root {
  color-scheme: dark;
  --bg: #171717;
  --top: #2b2b2b;
  --panel: #2e2f2f;
  --panel-2: #252626;
  --line: #3a3b3d;
  --text: #f0f2f4;
  --muted: #8d949e;
  --soft: #cfd5dc;
  --blue: #1f7ae8;
  --green: #2fca64;
  --yellow: #f3bd4d;
  --cyan: #55a7f4;
  --danger: #d84e4e;
  --shadow: 0 18px 50px rgba(0, 0, 0, .26);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #70aff7;
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .015), rgba(255, 255, 255, 0) 220px),
    var(--bg);
}

.topbar {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: var(--top);
  border-bottom: 1px solid #111;
}

.brand,
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand {
  min-width: 106px;
  color: #eef1f4;
}

.brand-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #e6e9ed;
}

.tabs {
  display: flex;
  gap: 4px;
  height: 100%;
  align-items: center;
}

.tab {
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  color: #d8dde3;
  background: transparent;
}

.tab.active {
  background: #202122;
  color: #fff;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions form {
  margin: 0;
}

.save-status {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.save-status[data-tone="saving"] {
  color: #f5cf78;
}

.save-status[data-tone="saved"] {
  color: #8de5ad;
}

.save-status[data-tone="warning"] {
  color: #f5cf78;
}

.save-status[data-tone="error"] {
  color: #ff9a9a;
}

.workspace {
  padding: 32px 48px 54px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  margin-bottom: 22px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn,
.icon-btn,
.segment {
  border: 1px solid transparent;
  background: #2c2d2f;
  color: #e7ebef;
  height: 48px;
  border-radius: 6px;
  padding: 0 22px;
  font-weight: 700;
}

.btn:hover,
.icon-btn:hover,
.segment:hover {
  filter: brightness(1.08);
}

.btn.primary,
.segment.active {
  background: var(--blue);
  color: #fff;
}

.btn.danger {
  background: rgba(216, 78, 78, .16);
  color: #ff9a9a;
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.icon-btn {
  width: 58px;
  padding: 0;
  display: grid;
  place-items: center;
}

.icon-btn.plain {
  width: 38px;
  height: 38px;
  background: transparent;
}

.icon-btn.compact {
  width: 36px;
  height: 36px;
  padding: 0;
  color: #cdd3da;
  background: #222324;
  border-color: #3b3c3e;
}

.icon-btn.compact svg {
  width: 18px;
  height: 18px;
}

.switch {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: var(--blue);
  border-radius: 19px;
  font-size: 14px;
  font-weight: 700;
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: #fff;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segment {
  min-width: 78px;
  border-radius: 0;
  border-right: 1px solid var(--line);
}

.segment:last-child {
  border-right: 0;
}

.search {
  width: min(330px, 100%);
  height: 54px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: #242526;
  border-radius: 8px;
  color: #dfe4ea;
}

.search input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-weight: 700;
}

.search input::placeholder {
  color: #777d85;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-strip article {
  min-height: 70px;
  padding: 14px 16px;
  background: #222323;
  border: 1px solid #303133;
  border-radius: 8px;
}

.stats-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 7px;
}

.stats-strip strong {
  font-size: 22px;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 14px;
}

.server-card {
  min-height: 250px;
  background: var(--panel);
  border: 1px solid #363739;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .02) inset;
  contain: layout paint style;
  content-visibility: auto;
  contain-intrinsic-size: auto 250px;
}

.server-card.offline {
  background: #282929;
  border-color: #453434;
}

.server-card.offline .card-body,
.server-card.offline .card-head h2 {
  opacity: .74;
}

.card-head {
  min-height: 58px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 15px 10px;
  border-bottom: 1px solid #373838;
}

.card-head h2,
.card-head p,
.card-body p {
  margin: 0;
}

.card-head h2 {
  max-width: 250px;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.16;
}

.card-head p {
  margin-top: 4px;
  color: #858c96;
  font-size: 13px;
  font-family: Consolas, "Cascadia Mono", monospace;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin-top: 7px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.online {
  color: #9df0ba;
  background: rgba(47, 202, 100, .12);
}

.status-pill.offline {
  color: #ff9a9a;
  background: rgba(216, 78, 78, .16);
}

.gear {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 3px;
}

.gear svg {
  width: 18px;
  height: 18px;
}

.card-body {
  padding: 12px 15px 14px;
  color: var(--text);
  font-weight: 700;
}

.load-line,
.network-line {
  line-height: 1.55;
}

.network-line {
  margin-bottom: 6px;
}

.up {
  color: var(--yellow);
  padding: 0 4px 0 8px;
}

.down {
  color: var(--cyan);
  padding: 0 4px 0 12px;
}

.offline-text {
  color: #ff9a9a;
}

.metric {
  margin-top: 8px;
}

.metric-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  line-height: 1.15;
  color: #e8edf2;
  overflow-wrap: anywhere;
}

.bar {
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 8px;
  background: #171b1f;
}

.bar span {
  display: block;
  height: 100%;
  width: 0;
  min-width: 5px;
  border-radius: inherit;
  background:
    repeating-linear-gradient(
      115deg,
      rgba(255, 255, 255, .24) 0 7px,
      rgba(255, 255, 255, 0) 7px 20px
    ),
    linear-gradient(90deg, #20b957 0%, #42e07c 48%, #24bd5c 100%);
  background-size: 46px 100%, 100% 100%;
  box-shadow:
    0 0 12px rgba(47, 202, 100, .35),
    inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: width .45s ease;
}

.server-card.offline .bar span {
  min-width: 0;
  background: #62666c;
  box-shadow: none;
  animation: none;
}

.empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #3a3c40;
  border-radius: 8px;
}

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

.editor {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
  background: #242526;
  color: var(--text);
  border: 1px solid #414347;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.editor::backdrop {
  background: rgba(0, 0, 0, .56);
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid #383a3d;
}

.editor-head strong {
  display: block;
  font-size: 20px;
}

.editor-head span {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}

.form-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: #c9cfd6;
  font-weight: 700;
  font-size: 14px;
}

.form-grid input,
.form-grid select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid #3e4145;
  border-radius: 6px;
  background: #1d1e1f;
  color: #fff;
  padding: 0 11px;
  outline: 0;
}

.form-grid select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #9aa2ad 50%),
    linear-gradient(135deg, #9aa2ad 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 18px,
    calc(100% - 10px) 18px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(31, 122, 232, .2);
}

.editor-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  padding: 16px 20px 20px;
  border-top: 1px solid #383a3d;
}

.login-page {
  min-height: 100vh;
  background: #171717;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(400px, 100%);
  padding: 30px;
  background: #252626;
  border: 1px solid #393a3c;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: #fff;
  background: var(--blue);
  border-radius: 8px;
}

.login-brand svg {
  width: 25px;
  height: 25px;
}

.login-heading h1,
.login-heading p {
  margin: 0;
}

.login-heading h1 {
  font-size: 24px;
  line-height: 1.25;
}

.login-heading p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.login-error {
  margin-top: 18px;
  padding: 10px 12px;
  color: #ffb1b1;
  background: rgba(216, 78, 78, .12);
  border: 1px solid rgba(216, 78, 78, .34);
  border-radius: 6px;
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: #cfd5dc;
  font-size: 14px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: #fff;
  background: #1b1c1d;
  border: 1px solid #414347;
  border-radius: 6px;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

@media (max-width: 1360px) {
  .panel-grid {
    grid-template-columns: repeat(3, minmax(260px, 1fr));
  }
}

@media (max-width: 1020px) {
  .workspace {
    padding: 22px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-right,
  .search {
    width: 100%;
  }

  .stats-strip,
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 14px;
  }

  .tabs {
    display: none;
  }

  .save-status {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .workspace {
    padding: 16px;
  }

  .toolbar-left,
  .toolbar-right {
    align-items: stretch;
  }

  .btn,
  .file-btn,
  .icon-btn,
  .segmented,
  .search {
    flex: 1 1 auto;
  }

  .stats-strip,
  .panel-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .editor-actions {
    grid-template-columns: 1fr 1fr;
  }

  .editor-actions span {
    display: none;
  }

  .login-shell {
    padding: 16px;
  }

  .login-panel {
    padding: 24px 20px;
  }
}
