:root {
  --bg: #0f1c17;
  --panel: #163027;
  --panel-2: #1c3a2f;
  --line: #2f5646;
  --text: #e8f2ec;
  --muted: #9bb5a8;
  --accent: #2f9e6b;
  --accent-2: #d4a017;
  --danger: #c45c4a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font-display: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--font-display); color: var(--text); background:
  radial-gradient(1200px 600px at 10% -10%, #245c45 0%, transparent 55%),
  radial-gradient(900px 500px at 100% 0%, #3a4d28 0%, transparent 50%),
  linear-gradient(160deg, #0d1713, #13241c 45%, #0f1a15);
}

.hidden { display: none !important; }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card, .modal-card {
  width: min(420px, 100%);
  background: rgba(22, 48, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.login-card .brand, .side-brand {
  font-size: 28px; font-weight: 700; letter-spacing: 0.04em; color: #f3f8f5;
}
.login-card .sub { color: var(--muted); margin: 6px 0 22px; }
label { display: grid; gap: 8px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: #10241c; color: var(--text);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
button {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 10px; padding: 9px 14px; cursor: pointer;
}
button.primary, .login-card button[type="submit"] {
  background: linear-gradient(135deg, #2f9e6b, #247a54); border-color: transparent; width: 100%;
  font-weight: 600; margin-top: 6px;
}
button:hover { filter: brightness(1.08); }
.error { color: #ffb4a8; min-height: 1.2em; font-size: 13px; }

#appView { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: rgba(14, 28, 22, 0.9); border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 18px;
}
.side nav { display: grid; gap: 8px; }
.side .nav { text-align: left; background: transparent; }
.side .nav.active { background: rgba(47, 158, 107, 0.2); border-color: var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.main { padding: 24px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 650; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions input, .actions select { width: auto; min-width: 140px; }
.table-wrap {
  margin-top: 18px; overflow: auto; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(16, 36, 28, 0.7);
}
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 14px; border-bottom: 1px solid rgba(47, 86, 70, 0.55); text-align: left; font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: rgba(0,0,0,0.15); }
td .link { color: #8fd6b3; background: transparent; border: none; padding: 0; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #244637; }
.badge.off { background: #4a2f2a; color: #ffc7be; }
.badge.risk { background: #4a3a1d; color: #ffd98a; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: grid; place-items: center; padding: 20px; z-index: 20;
}
.modal-card { width: min(720px, 100%); max-height: 90vh; overflow: auto; }
.modal-card h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.wx-list { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.wx-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #10241c;
}
.wx-meta {
  color: var(--muted); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  font-size: 13px;
}
.status-group { display: inline-flex; align-items: center; gap: 6px; }
.toggle-chip {
  width: auto; margin: 0; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); cursor: pointer; line-height: 1.4;
}
.toggle-chip.on { background: rgba(47, 158, 107, 0.25); border-color: var(--accent); color: #b8efd2; }
.toggle-chip.off { background: #4a2f2a; border-color: #7a4338; color: #ffc7be; }
.toggle-chip.ok { background: rgba(47, 158, 107, 0.18); border-color: #3f7a5f; color: #b8efd2; }
.toggle-chip.risk { background: #4a3a1d; border-color: #8a6a2a; color: #ffd98a; }
.toggle-chip:hover { filter: brightness(1.12); }
.toggle-chip:disabled { opacity: 0.6; cursor: wait; }

@media (max-width: 860px) {
  #appView { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { display: flex; }
  .side-foot { margin-top: 0; margin-left: auto; }
  .form-grid { grid-template-columns: 1fr; }
}
