:root {
  --bg-deep: #081224;
  --bg-main: #101d37;
  --card: #142343;
  --card-hover: #1a2d52;
  --line: #294170;
  --text: #e7efff;
  --muted: #a8bde8;
  --primary: #3b82f6;
  --primary-dark: #1f4fca;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 12px 28px rgba(2, 8, 23, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg-deep), var(--bg-main));
}

.hidden {
  display: none !important;
}

a {
  color: #9ec5ff;
}

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

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

.brand-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

.user-badge {
  display: inline-block;
  font-size: 12px;
  color: #d7e8ff;
  background: #1f3666;
  border: 1px solid #3a5f9f;
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 14px;
}

.nav-group-title {
  font-size: 11px;
  color: #7f9fd4;
  margin: 12px 0 6px;
  letter-spacing: 0.08em;
}

.nav-btn {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  background: #111f3e;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.nav-btn:hover {
  background: var(--card-hover);
}

.nav-btn.active {
  background: #1a2f58;
  border-color: #4b74bb;
}

.logout-btn {
  margin-top: 14px;
  width: 100%;
  background: #30172a;
  border-color: #633252;
  color: #ffd8ea;
}

.main-area {
  padding: 18px 20px 28px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
}

.page-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.status-line {
  font-size: 12px;
  color: #c5d9ff;
  text-align: right;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.kpi-card {
  background: linear-gradient(180deg, #132445, #111d35);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

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

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  margin: 10px 0 4px;
}

.kpi-foot {
  font-size: 12px;
  color: #8ea8dc;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

input,
select,
button,
textarea {
  font: inherit;
  color: var(--text);
  background: #122343;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

button {
  cursor: pointer;
}

button.primary {
  background: var(--primary-dark);
  border-color: #3a66d6;
}

button.success {
  background: #166534;
  border-color: #22804a;
}

button.warn {
  background: #7c4a0f;
  border-color: #a86412;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

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

th,
td {
  padding: 10px;
  border-bottom: 1px solid #2a3f68;
  text-align: left;
  font-size: 13px;
}

th {
  background: #192c53;
  color: #d2e2ff;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #152240;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #4f6da5;
}

.tag.ok {
  background: #163b2a;
  border-color: #2f8962;
  color: #ccffe0;
}

.tag.warn {
  background: #3e2d14;
  border-color: #9a6d1d;
  color: #ffe8c7;
}

.tag.bad {
  background: #3f1624;
  border-color: #9f3551;
  color: #ffd4da;
}

.chart-box {
  width: 100%;
  height: 340px;
}

.chart-box.sm {
  height: 260px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 420px;
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.login-card .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.login-form input {
  width: 100%;
  margin-bottom: 10px;
}

.login-form button {
  width: 100%;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.empty-tip {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.report-box {
  width: 100%;
  min-height: 320px;
  resize: vertical;
}

.stat-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.stat-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: #1a2e57;
  border: 1px solid #3f5f9a;
  font-size: 12px;
}

.footer-note {
  margin-top: 16px;
  font-size: 12px;
  color: #7f9fd4;
  text-align: center;
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col {
    grid-template-columns: 1fr;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
}

@media (max-width: 700px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
