:root {
  color-scheme: dark;
  --bg: #0f1720;
  --bg-soft: #151f2b;
  --panel: rgba(23, 34, 47, 0.92);
  --panel-strong: #1b2735;
  --line: rgba(148, 163, 184, 0.2);
  --text: #edf4ff;
  --muted: #9caec2;
  --brand: #ee4f9a;
  --brand-strong: #ff72b2;
  --cyan: #38c8ff;
  --green: #57d68d;
  --danger: #ff6173;
  --warning: #ffc857;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(56, 200, 255, 0.08), transparent 35%),
    linear-gradient(315deg, rgba(238, 79, 154, 0.09), transparent 34%),
    var(--bg);
}

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

button {
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--brand), #b74dff);
  color: white;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.24);
  filter: brightness(1.04);
}

button.secondary { background: #3c4b5e; }
button.danger { background: #cf3048; }
button.ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
  color: var(--text);
}
button.small { padding: 5px 9px; font-size: 12px; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: rgba(7, 12, 18, 0.62);
  color: var(--text);
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(56, 200, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(56, 200, 255, 0.12);
}

textarea { resize: vertical; }
label { display: grid; gap: 7px; color: var(--muted); }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

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

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: rgba(23, 34, 47, 0.82);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  font-weight: 800;
}

.login-card p { color: var(--muted); line-height: 1.7; }
.message { min-height: 20px; color: var(--danger); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 14px;
  background: rgba(9, 14, 21, 0.92);
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  font-weight: 900;
}

.brand strong { display: block; font-size: 17px; }
.brand span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

.side-status {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.dot.online { background: var(--green); box-shadow: 0 0 14px rgba(87, 214, 141, 0.8); }

nav {
  display: grid;
  gap: 5px;
}

nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dbe8f7;
  border-color: transparent;
  padding: 10px 12px;
}

nav button.active, nav button:hover {
  background: rgba(238, 79, 154, 0.13);
  border-color: rgba(238, 79, 154, 0.28);
}

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

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

.topbar h2 { font-size: 24px; }
#panelSubTitle { margin-top: 6px; color: var(--muted); }

.top-actions, .quick-actions, .form-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}
.status-pill.online { color: var(--green); border-color: rgba(87, 214, 141, 0.35); }
.status-pill.offline { color: var(--danger); border-color: rgba(255, 97, 115, 0.35); }

.notice {
  margin-bottom: 14px;
  padding: 11px 13px;
  color: #dfffea;
  background: rgba(87, 214, 141, 0.14);
  border: 1px solid rgba(87, 214, 141, 0.28);
  border-radius: 10px;
}

.panel { display: none; }
.panel.active { display: block; }

.grid, .future-grid {
  display: grid;
  gap: 14px;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.future-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
}

.metric-card {
  min-height: 98px;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 16px;
  border-top: 3px solid var(--cyan);
}
.metric-card span { color: var(--muted); }
.metric-card strong { font-size: 27px; }
.metric-card.pink { border-top-color: var(--brand); }
.metric-card.green, .metric-card.ok { border-top-color: var(--green); }
.metric-card.danger { border-top-color: var(--danger); }
.metric-card.cyan { border-top-color: var(--cyan); }

.card {
  padding: 16px;
  margin-bottom: 14px;
}
.card h3 { margin-bottom: 14px; }
.card-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-head h3 { margin: 0; }

.form-grid {
  display: grid;
  gap: 13px;
}
.form-grid.narrow { max-width: 820px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  margin-bottom: 12px;
}
.inline-form.compact-form {
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) auto;
  margin-bottom: 0;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.switch-line input {
  appearance: none;
  width: 42px;
  height: 23px;
  border-radius: 999px;
  padding: 0;
  background: #354253;
  position: relative;
  flex: 0 0 auto;
}
.switch-line input::after {
  content: "";
  position: absolute;
  width: 17px;
  height: 17px;
  left: 3px;
  top: 2px;
  border-radius: 50%;
  background: #dce7f5;
  transition: transform .18s ease;
}
.switch-line input:checked {
  background: linear-gradient(135deg, var(--brand), var(--cyan));
}
.switch-line input:checked::after {
  transform: translateX(18px);
}
.switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.search { max-width: 280px; }

.list {
  display: grid;
  gap: 10px;
}
.list.compact { gap: 7px; }

.item {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px;
  display: grid;
  gap: 8px;
  background: rgba(255, 255, 255, 0.035);
}
.item.slim {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.muted, .hint { color: var(--muted); }
.hint { margin-top: 12px; }
.empty {
  padding: 16px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 9px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(56, 200, 255, 0.12);
  color: var(--cyan);
  font-size: 12px;
}
.tag.ok { background: rgba(87, 214, 141, 0.12); color: var(--green); }
.tag.danger { background: rgba(255, 97, 115, 0.13); color: var(--danger); }
.muted-tag { background: rgba(156, 174, 194, 0.12); color: var(--muted); }

.table {
  width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 14px;
}
td, th {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}
th {
  color: #bad1e8;
  font-weight: 650;
  background: rgba(255, 255, 255, 0.03);
}

.summary {
  display: grid;
  gap: 10px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.summary-row span { color: var(--muted); }

.quick-card { margin-top: 14px; }
.future-card p { color: var(--muted); line-height: 1.6; }

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .future-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 3;
  }
  nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  nav button {
    width: auto;
    flex: 0 0 auto;
  }
  .content { padding: 16px; }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .grid.two, .form-row, .future-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .inline-form, .inline-form.compact-form { grid-template-columns: 1fr; }
  .card-head {
    align-items: stretch;
    flex-direction: column;
  }
  .search { max-width: none; }
}

@media (max-width: 520px) {
  .brand { grid-template-columns: 40px minmax(0, 1fr); }
  .brand-logo { width: 40px; height: 40px; }
  .metric-grid { grid-template-columns: 1fr; }
  .switch-grid { grid-template-columns: 1fr; }
  .top-actions, .quick-actions, .form-actions { width: 100%; }
  .top-actions button, .quick-actions button, .form-actions button { flex: 1 1 auto; }
  .item.slim { grid-template-columns: 1fr; }
}
