* { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  color: #162018;
  background: #f4f6f2;
  overflow-x: hidden;
}
a { color: #176d54; text-decoration: none; }
.shell { min-height: 100vh; display: flex; width: 100%; }
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #14231d;
  color: #f7fbf3;
  padding: 22px 16px;
}
.brand { font-size: 18px; font-weight: 700; margin-bottom: 24px; }
.nav a, .nav form button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  color: #dce8dd;
  border-radius: 6px;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.nav a:hover, .nav form button:hover { background: #20382e; }
.content { flex: 1; min-width: 0; padding: 26px; overflow-x: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.topbar h1 { margin: 0; overflow-wrap: anywhere; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: #fff;
  border: 1px solid #dfe7dc;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(20, 35, 29, .06);
  max-width: 100%;
}
.metric { font-size: 28px; font-weight: 800; margin-top: 6px; }
.muted { color: #647067; font-size: 13px; overflow-wrap: anywhere; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
label { display: block; font-size: 13px; color: #465149; margin-bottom: 5px; overflow-wrap: anywhere; }
input, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd8cf;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  max-width: 100%;
}
textarea {
  width: 100%;
  border: 1px solid #cbd8cf;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
  resize: vertical;
  max-width: 100%;
}
.field { min-width: 180px; flex: 1; }
button, .btn {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  background: #176d54;
  color: #fff;
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: normal;
  text-align: center;
}
.btn.secondary, button.secondary { background: #55615a; }
.btn.warn, button.warn { background: #9b3d32; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #dfe7dc;
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table::after {
  content: "";
}
tbody { display: table; width: 100%; min-width: 720px; }
th, td { padding: 10px; border-bottom: 1px solid #edf1eb; text-align: left; white-space: nowrap; vertical-align: top; }
th { background: #eef4ed; font-size: 13px; }
td:first-child, th:first-child, td .muted { white-space: normal; overflow-wrap: anywhere; }
.diagnostic-samples {
  white-space: normal;
  color: #465149;
  font-size: 13px;
  line-height: 1.55;
}
.trend-chart {
  width: 100%;
  max-width: 100%;
  border: 1px solid #edf1eb;
  border-radius: 6px;
  background: #fbfdf9;
}
.auth {
  max-width: 380px;
  width: calc(100% - 32px);
  margin: 10vh auto;
  background: #fff;
  border: 1px solid #dfe7dc;
  border-radius: 8px;
  padding: 24px;
}
.legal-page {
  max-width: 860px;
  margin: 6vh auto;
  padding: 0 18px;
}
.error { color: #a0332a; margin-bottom: 12px; }
.notice { color: #176d54; margin-bottom: 12px; }
.status-on { color: #176d54; font-weight: 700; }
.status-off { color: #7c817d; }
.risk-low { color: #176d54; font-weight: 700; }
.risk-medium { color: #8a6500; font-weight: 700; }
.risk-high { color: #a0332a; font-weight: 700; }
button.active { background: #2f876b; }
button:disabled, input:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 860px) {
  .shell {
    display: block;
    min-height: 100vh;
  }

  .sidebar {
    width: 100%;
    padding: 12px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(20, 35, 29, .14);
  }

  .brand {
    font-size: 16px;
    margin-bottom: 10px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .nav a,
  .nav form button {
    width: auto;
    white-space: nowrap;
    padding: 8px 10px;
    min-height: 34px;
  }

  .nav form {
    flex: 0 0 auto;
    margin: 0;
  }

  .content {
    padding: 14px;
  }

  .topbar {
    display: block;
    margin-bottom: 14px;
  }

  .topbar h1 {
    font-size: 22px;
    margin-bottom: 6px;
  }

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

  .card {
    padding: 14px;
    border-radius: 6px;
  }

  .metric {
    font-size: 24px;
  }

  .row {
    display: block;
  }

  .row > * {
    margin-bottom: 10px;
  }

  .field {
    min-width: 0;
    width: 100%;
  }

  button,
  .btn {
    width: 100%;
    margin-top: 6px;
  }

  .nav form button {
    width: auto;
    margin-top: 0;
  }

  form[style*="display:inline"],
  form[style*="display: inline"] {
    display: block !important;
    margin-top: 6px;
  }

  table {
    margin: 10px 0 16px;
    border-radius: 6px;
  }

  table:focus-within,
  table:hover {
    border-color: #b8c8bd;
  }

  th,
  td {
    padding: 9px 8px;
    font-size: 13px;
  }

  .trend-chart {
    height: 170px;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 10px;
  }

  .sidebar {
    padding: 10px;
  }

  .brand {
    font-size: 15px;
  }

  .nav a,
  .nav form button {
    font-size: 13px;
    padding: 7px 9px;
  }

  .auth {
    width: calc(100% - 20px);
    margin: 5vh auto;
    padding: 18px;
  }

  .legal-page {
    padding: 0 10px;
    margin: 3vh auto;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 18px;
  }

  tbody {
    min-width: 620px;
  }
}
