:root {
  --ink: #16202a;
  --muted: #5c6b73;
  --paper: #f3efe6;
  --card: #fffcf7;
  --line: #d7d0c4;
  --teal: #0e3a3a;
  --teal-2: #1c5c57;
  --gold: #c4a35a;
  --ok: #2c6e49;
  --off: #8a3b3b;
  --warn: #8a5a12;
  --shadow: 0 12px 40px rgba(22, 32, 42, 0.08);
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(196, 163, 90, 0.18), transparent 40%),
    linear-gradient(165deg, #0e3a3a 0%, #16202a 55%, #1c2c28 100%);
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--card);
  border-radius: 18px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}
.login-mark, .brand-mark {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--teal); color: #e8d5a3;
  display: grid; place-items: center;
  font-weight: 700; letter-spacing: 0.05em;
}
.login-card h1 { font-size: 1.35rem; margin: 16px 0 4px; }
.login-sub { margin: 0 0 24px; color: var(--muted); font-size: 0.9rem; }
.login-card label, .inline-form label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 14px; }
.login-card input, .inline-form input, .inline-form select {
  display: block; width: 100%; margin-top: 6px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 10px 12px; color: var(--ink);
}
.login-card button, .inline-form button {
  width: 100%; border: 0; background: var(--teal); color: #f7f2e8;
  border-radius: 8px; padding: 11px 14px; margin-top: 4px;
}
.login-card button:hover, .inline-form button:hover { background: var(--teal-2); }
.form-error { min-height: 1.2em; color: var(--off); font-size: 0.88rem; margin: 10px 0 0; }

#app-view { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
#app-view[hidden], #login-view[hidden], .panel[hidden] { display: none !important; }

.sidebar {
  background: var(--teal);
  color: #f3efe6;
  display: flex; flex-direction: column;
  padding: 22px 16px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand strong { display: block; font-size: 0.95rem; }
.brand small { color: #e8d5a3; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav button {
  text-align: left; border: 0; background: transparent; color: #e6efe9;
  padding: 10px 12px; border-radius: 8px;
}
.sidebar nav button.active, .sidebar nav button:hover { background: rgba(232, 213, 163, 0.16); color: #fff; }
.sidebar-foot { font-size: 0.82rem; color: #c9d4ce; display: flex; justify-content: space-between; align-items: center; }
.linkish { background: none; border: 0; color: #e8d5a3; padding: 0; }

main { padding: 28px 36px 48px; }
.topbar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 20px; }
.topbar h2 { margin: 0; font-size: 1.4rem; }
.clock { color: var(--muted); margin: 0; font-size: 0.9rem; }
.hint { color: var(--muted); margin-top: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card, .block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 0.8rem; margin: 0 0 6px; }
.card .value { font-size: 1.4rem; margin: 0; font-weight: 650; }
.card .note { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.block h3 { margin: 0 0 12px; font-size: 1rem; }
.kv { margin: 0; display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 0.75rem; }
.badge-ok { background: #e3f2e9; color: var(--ok); }
.badge-off { background: #f8e8e8; color: var(--off); }
.badge-lock { background: #f3ead8; color: var(--warn); }

.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: top; }
.table th { background: #ece6da; font-weight: 600; }
.ident-item { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.once { background: #16202a; color: #e8d5a3; padding: 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.inline-form { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px; align-items: end; }
.inline-form button { width: auto; padding: 10px 18px; margin: 0 0 14px; }
.tunnel { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tunnel:last-child { border-bottom: 0; }

@media (max-width: 900px) {
  #app-view { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2, .inline-form { grid-template-columns: 1fr; }
}
