:root {
  --ink: #202226;
  --muted: #737780;
  --line: #e5e6e8;
  --paper: #f5f5f3;
  --surface: #ffffff;
  --accent: #d94b4b;
  --accent-dark: #b83737;
  --success: #279064;
  --warning: #d48a2d;
  --shadow: 0 18px 50px rgba(24, 27, 31, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(360px, 0.9fr);
}
.login-brand {
  padding: clamp(42px, 8vw, 120px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #f8f7f2;
  background: #222429;
  position: relative;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  right: -150px;
  bottom: -130px;
}
.rocket-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 2px solid #f8f7f2;
  border-radius: 50%;
  font-size: 31px;
  margin-bottom: 42px;
}
.login-brand h1 {
  font-size: clamp(56px, 7vw, 100px);
  line-height: .92;
  letter-spacing: -.055em;
  margin: 12px 0 28px;
}
.login-copy { color: #bfc1c6; font-size: 18px; }
.login-card {
  width: min(430px, calc(100% - 48px));
  margin: auto;
  padding: 44px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 24px;
}
.login-card h2, .panel h2 { margin: 5px 0 8px; }

label { display: grid; gap: 8px; font-weight: 650; font-size: 14px; }
input, textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbfa;
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus {
  border-color: #888c94;
  box-shadow: 0 0 0 3px rgba(32,34,38,.08);
}
.primary-button, .secondary-button {
  border: 0;
  border-radius: 10px;
  padding: 13px 18px;
  font-weight: 750;
}
.primary-button { color: white; background: var(--ink); }
.primary-button:hover { background: #000; }
.secondary-button { background: white; border: 1px solid var(--line); color: var(--ink); }
.compact { padding: 10px 15px; width: auto; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}
.form-error { margin: 0; color: var(--accent-dark); min-height: 20px; font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 20px 22px;
  background: #222429;
  color: #f7f6f2;
  display: flex;
  flex-direction: column;
}
.wordmark { font-size: 22px; font-weight: 850; letter-spacing: .04em; padding: 4px 12px 34px; }
.wordmark span { color: #f06464; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item {
  border: 0;
  border-radius: 10px;
  padding: 12px;
  color: #bfc1c6;
  background: transparent;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 650;
}
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.08); }
.nav-symbol { width: 24px; text-align: center; font-size: 18px; }
.sidebar-footer {
  margin-top: auto;
  padding: 18px 12px 0;
  border-top: 1px solid rgba(255,255,255,.1);
  color: #bfc1c6;
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.status-dot, .legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.text-button { grid-column: 2; width: max-content; border: 0; padding: 0; color: #fff; background: none; }

main { min-width: 0; padding: 36px clamp(22px, 4vw, 58px) 60px; }
.topbar, .page-tools, .panel-heading, .dialog-heading, .dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar { margin-bottom: 34px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.035em; }
.top-actions { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.summary-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.summary-card strong { display: block; margin-top: 14px; font-size: 31px; letter-spacing: -.04em; }
.summary-card small { color: var(--muted); }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.panel-heading { margin-bottom: 20px; }
.legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
tbody tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge.success { color: #19734e; background: #e9f6ef; }
.badge.warning { color: #9b5d17; background: #fff3df; }
.badge.offline { color: #7b7e85; background: #eff0f1; }
.flag { font-size: 22px; margin-right: 8px; vertical-align: middle; }
.page-tools { margin-bottom: 18px; }
.search-input { max-width: 360px; background: white; }
.server-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.server-card { position: relative; overflow: hidden; }
.server-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 5px; height: 100%;
  background: var(--accent);
}
.server-title { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.server-title h2 { margin: 0; }
.server-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.server-meta div { min-width: 0; }
.server-meta small { display: block; color: var(--muted); margin-bottom: 4px; }
.server-meta code { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.danger-button, .link-button {
  padding: 8px 10px; border: 0; border-radius: 8px; font-weight: 700; background: transparent;
}
.danger-button { color: var(--accent-dark); }
.link-button { color: var(--ink); background: #f1f1ef; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.setting-card { display: grid; align-content: start; gap: 18px; }
.switch-row { grid-template-columns: 1fr auto; align-items: center; }
.switch-row span { display: grid; gap: 5px; }
.switch-row small { color: var(--muted); font-weight: 400; }
.switch-row input { width: 42px; height: 22px; accent-color: var(--ink); }
.settings-save { grid-column: 1 / -1; justify-self: end; width: 180px; }

dialog {
  width: min(680px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 0;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(0,0,0,.24);
}
dialog::backdrop { background: rgba(20,22,26,.55); backdrop-filter: blur(3px); }
#editorForm { padding: 26px; }
.icon-button { border: 0; background: #f1f1ef; border-radius: 50%; width: 36px; height: 36px; font-size: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.checkbox-label { display: flex; align-items: center; gap: 9px; }
.checkbox-label input { width: auto; }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(120px);
  opacity: 0;
  padding: 13px 16px;
  color: white;
  background: var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: .25s;
  z-index: 100;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .server-grid, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 42vh; padding: 42px 28px; }
  .login-brand h1 { font-size: 54px; }
  .rocket-mark { margin-bottom: 20px; }
  .login-card { margin: 28px auto; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 18px; }
  .sidebar nav { grid-template-columns: repeat(4, minmax(68px, 1fr)); }
  .nav-item { justify-content: center; font-size: 0; }
  .nav-symbol { font-size: 19px; }
  .wordmark { padding: 0 6px 16px; }
  .sidebar-footer { display: none; }
  main { padding: 26px 16px 45px; }
  .topbar { align-items: flex-end; }
  #lastUpdated { display: none; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}

