:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --surface-2: #f1eee6;
  --ink: #20242a;
  --muted: #676d75;
  --line: #ded8cc;
  --primary: #21584f;
  --primary-dark: #163d37;
  --blue: #2e6b9c;
  --green: #23815f;
  --amber: #ad6c19;
  --red: #b5473f;
  --violet: #6553a8;
  --shadow: 0 8px 24px rgba(38, 44, 52, 0.08);
  font-family: "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(32, 36, 42, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(32, 36, 42, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

button, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.62; }

.shell {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 58px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.25; }
.subtitle { max-width: 680px; margin-bottom: 0; color: var(--muted); line-height: 1.7; }

.top-actions,
.control-row,
.scope-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button,
.text-button,
.scope-button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 750;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.button { padding: 0 16px; }
.button:hover,
.scope-button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--primary); box-shadow: 0 6px 16px rgba(33, 88, 79, 0.2); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { color: var(--primary); background: #dfe9e2; }
.text-button { padding: 0 10px; color: var(--muted); background: transparent; }

.login-card,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.login-card {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 38px;
  max-width: 880px;
  margin: 64px auto 0;
  padding: 34px;
}

.badge {
  display: inline-flex;
  margin-bottom: 16px;
  padding: 5px 9px;
  border-radius: 8px;
  color: var(--primary);
  background: #dfe9e2;
  font-size: 12px;
  font-weight: 800;
}

.login-copy p,
.form-message,
.dashboard-message,
.unit {
  color: var(--muted);
}

label { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 750; }
input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  border: 1px solid #c9c1b4;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(33, 88, 79, 0.14); }
.credential-fields { display: grid; grid-template-columns: 1fr; gap: 14px; }
.credential-fields label { margin: 0; }
.credential-fields input { margin-top: 8px; }
.login-submit { width: 100%; margin-top: 18px; }
.form-message { min-height: 22px; margin: 10px 0 0; font-size: 13px; }
.form-message.error,
.dashboard-message.error { color: var(--red); }

.control-row {
  justify-content: space-between;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}
.auto-refresh-label {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary);
  background: rgba(255, 253, 248, 0.72);
  white-space: nowrap;
}
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(35, 129, 95, 0.14);
}
.scope-toggle {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.scope-button {
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}
.scope-button.active {
  color: #fff;
  background: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.metric-card {
  position: relative;
  min-height: 138px;
  overflow: hidden;
  padding: 20px;
}
.metric-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  content: "";
  background: currentColor;
}
.metric-card > span { display: block; color: var(--muted); font-size: 14px; }
.metric-card strong { display: block; margin: 14px 0 8px; color: var(--ink); font-size: 34px; line-height: 1; }
.metric-card em { margin-left: 4px; color: var(--muted); font-size: 13px; font-style: normal; font-weight: 500; }
.metric-card small { color: var(--muted); line-height: 1.45; }
.accent-blue { color: var(--blue); }
.accent-green { color: var(--green); }
.accent-amber { color: var(--amber); }
.accent-purple { color: var(--violet); }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(320px, 0.88fr);
  gap: 12px;
  margin-bottom: 12px;
}
.lower-grid { grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr); }
.panel { min-width: 0; padding: 22px; }
.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.unit { font-size: 12px; white-space: nowrap; }

.bar-list { display: grid; gap: 16px; }
.bar-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 14px; }
.bar-meta strong { font-size: 15px; }
.bar-track,
.level-track,
.timeline-track {
  overflow: hidden;
  border-radius: 8px;
  background: #ebe5da;
}
.bar-track { height: 10px; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--primary); }

.distribution { display: grid; gap: 12px; }
.level-row {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) 2fr auto;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.level-track { height: 8px; }
.level-fill { height: 100%; border-radius: inherit; background: var(--green); }
.level-count { min-width: 2em; text-align: right; font-weight: 800; }

.timeline { display: grid; gap: 11px; }
.timeline-row {
  display: grid;
  grid-template-columns: 48px 1fr 32px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.timeline-row strong { color: var(--ink); text-align: right; }
.timeline-track { height: 9px; }
.timeline-fill { height: 100%; border-radius: inherit; background: var(--blue); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  padding: 0 12px 10px;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
td {
  padding: 12px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}
td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}
.compact-table table { font-size: 13px; }
.status-pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.status-open { color: #8a5600; background: #f8e9c8; }
.status-closed { color: #17694f; background: #d9eee5; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.empty-state,
.empty-cell {
  padding: 30px 0;
  color: var(--muted);
  text-align: center;
}
.dashboard-message { min-height: 20px; margin: 12px 2px 0; font-size: 13px; }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid,
  .lower-grid,
  .login-card { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 24px, 1220px); padding-top: 22px; }
  .topbar,
  .control-row { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .top-actions .button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr; }
  .login-card { margin-top: 30px; padding: 22px 18px; gap: 24px; }
  .scope-toggle { width: 100%; }
  .scope-button { flex: 1; }
  .panel { padding: 18px; }
}
