:root {
  --bg: #eef2f5;
  --ink: #152026;
  --muted: #68757d;
  --line: #d8e0e5;
  --panel: #ffffff;
  --panel-strong: #f7fafb;
  --accent: #0f7c80;
  --accent-dark: #075c60;
  --danger: #b93d3d;
  --ok: #177245;
  --warn: #9a6a0a;
  --shadow: 0 18px 48px rgba(18, 38, 48, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 124, 128, 0.14), transparent 38%),
    linear-gradient(180deg, #f8fbfc 0%, var(--bg) 100%);
  font-family: "Noto Sans TC", "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary,
button.ghost {
  color: var(--ink);
  background: #e7eef1;
}

button.secondary:hover,
button.ghost:hover {
  background: #d8e2e7;
}

button.danger {
  background: var(--danger);
}

button.mini {
  min-height: 30px;
  padding: 0 10px;
  color: var(--ink);
  background: #e7eef1;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-panel h1,
.sidebar h1,
.topbar h2 {
  margin: 0;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px);
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav-item.active {
  color: #fff;
  background: var(--accent);
}

.sidebar .ghost {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.metric,
.panel,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(18, 38, 48, 0.06);
}

.metric {
  padding: 20px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.panel {
  padding: 18px;
}

.panel h3 {
  margin: 0 0 14px;
}

.panel-head,
.toolbar,
.actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar {
  align-items: center;
  flex-wrap: wrap;
}

.toolbar label {
  width: 220px;
}

.toolbar input {
  max-width: 360px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.details-row td {
  white-space: normal;
  background: #fbfdfe;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.details-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.details-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.details-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.contact-box {
  display: grid;
  gap: 8px;
}

.contact-line {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 90px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.contact-line span {
  color: var(--ok);
  font-weight: 700;
}

.contact-line code {
  overflow-wrap: anywhere;
  white-space: normal;
}

.contact-line small,
.muted {
  color: var(--muted);
}

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

.status {
  display: inline-flex;
  min-width: 86px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status.online {
  color: var(--ok);
  background: #e4f4ea;
}

.status.offline {
  color: var(--warn);
  background: #fff5d8;
}

textarea {
  min-height: 220px;
  resize: vertical;
}

.code-editor {
  min-height: calc(100vh - 220px);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.terminal {
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  border-radius: 6px;
  padding: 14px;
  color: #d8f3e9;
  background: #102024;
  white-space: pre-wrap;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .details-grid,
  .contact-line {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }
}
