:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #657084;
  --line: #d9dee7;
  --ok: #18794e;
  --off: #6b7280;
  --warn: #b25e09;
  --bad: #b42318;
  --unknown: #4b5563;
  --brand: #1f6feb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button.ghost {
  background: #eef2f7;
  color: var(--text);
  border: 1px solid var(--line);
}

.button-link {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 700;
}

.button-link.ghost {
  background: #eef2f7;
  color: var(--text);
  border: 1px solid var(--line);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 40px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.card h2,
.login-panel h1 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 34px);
}

.subtitle,
.card p,
.login-panel p,
.notice {
  color: var(--muted);
}

.userbar {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 24px clamp(16px, 4vw, 40px) 40px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}

.card-primary,
.log-card {
  grid-column: span 2;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

.card h2 {
  font-size: 20px;
}

.card p {
  margin: 4px 0 0;
}

.status-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.status-list.compact {
  grid-template-columns: 1fr;
}

.status-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 72px;
}

dt {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.state,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  text-transform: uppercase;
}

.state-online,
.state-on,
.badge-online {
  background: var(--ok);
}

.state-offline,
.state-off,
.badge-offline {
  background: var(--off);
}

.state-failed,
.badge-failed {
  background: var(--bad);
}

.state-executing,
.badge-executing {
  background: var(--warn);
}

.state-unknown,
.badge-unknown {
  background: var(--unknown);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.gateway-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
}

.gateway-actions .notice {
  flex: 1 1 220px;
  margin: 0;
}

.alert {
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
}

.alert-error {
  color: #7a271a;
  background: #fef3f2;
  border: 1px solid #fecdca;
}

.hidden {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(440px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  color: white;
  background: var(--text);
  box-shadow: 0 16px 30px rgba(15, 23, 42, .22);
}

.log-detail-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(340px, .9fr);
  gap: 18px;
  padding: 24px clamp(16px, 4vw, 40px) 40px;
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 210px);
  overflow-y: auto;
}

.log-list-item {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  display: grid;
  gap: 5px;
  text-align: left;
  font-weight: 700;
}

.log-list-item small {
  color: var(--muted);
  font-weight: 400;
}

.log-list-item.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, .16);
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.empty-state {
  color: var(--muted);
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

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

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.login-form input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-primary,
  .log-card {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .userbar {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard,
  .status-list {
    grid-template-columns: 1fr;
  }

  .card-primary,
  .log-card {
    grid-column: span 1;
  }

  .actions button {
    flex: 1 1 130px;
  }

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

  .gateway-actions button {
    min-height: 52px;
    width: 100%;
  }

  .log-detail-layout {
    grid-template-columns: 1fr;
  }

  .log-list {
    max-height: none;
  }
}

/* ===== Server Control Gateway UI adjustment 2026-08-25 ===== */

.gateway-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
}

.gateway-actions .notice {
  flex: none;
  width: 100%;
  margin: 0;
  line-height: 1.5;
}

.gateway-actions button {
  width: auto;
  min-width: 160px;
}

