:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --line: #d9e1e2;
  --line-strong: #bac8ca;
  --text: #162326;
  --muted: #627174;
  --accent: #16806d;
  --accent-strong: #0d6657;
  --accent-soft: #dff3ef;
  --warning: #c28513;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(25, 45, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(22, 128, 109, 0.08), rgba(194, 133, 19, 0.06)),
    var(--bg);
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-box h1,
.topbar h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.25;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: #142326;
  color: #f7fbfb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f4bf45;
  color: #1b2527;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 17px;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.userbar {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.view {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 36px;
}

.panel,
.metric,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(20, 35, 38, 0.02);
}

.panel {
  padding: 18px;
}

.table-panel {
  overflow: hidden;
}

.stack {
  display: grid;
  gap: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h3 {
  margin: 0;
  font-size: 17px;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.filter-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.filter-checks {
  min-height: 38px;
  max-height: 86px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.filter-checks:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 128, 109, 0.12);
}

.filter-checks label {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbfb;
  color: var(--text);
  white-space: nowrap;
}

.filter-checks input {
  width: auto;
  min-height: auto;
  padding: 0;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 128, 109, 0.12);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.tiny-button {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 13px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--text);
}

.ghost-button {
  border-color: transparent;
  background: var(--surface-soft);
  color: var(--text);
}

.danger-button {
  border-color: #f0b8b2;
  background: #fff4f2;
  color: var(--danger);
}

.tiny-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

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

.metric {
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.15;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e5ecec;
  overflow: hidden;
}

.bar-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #e0aa2f);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfb;
  color: #3a4a4d;
  font-weight: 750;
}

tbody tr:hover {
  background: #fbf8f0;
}

tbody tr.total-row {
  background: #fbfcf8;
  font-weight: 800;
}

tbody tr.total-row:hover {
  background: #f6faef;
}

.muted {
  color: var(--muted);
}

.computed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.computed-item {
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fbfb;
}

.computed-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.computed-item strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
}

.tabs button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.checkbox-group input {
  width: auto;
  min-height: auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.off {
  background: #f2f2f2;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #172527;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 14px;
}

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

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
  }

  .brand {
    padding-bottom: 10px;
  }

  .nav {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .nav button {
    white-space: nowrap;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .view {
    padding: 18px 14px 28px;
  }

  .form-grid,
  .form-grid.compact,
  .form-grid.three,
  .computed-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}
