:root {
  --navy: #0c3d6e;
  --bg: #f4f6f8;
  --card: #fff;
  --line: #e2e6ee;
  --text: #1c2430;
  --muted: #5c6b7a;
  --green: #157a45;
  --green-bg: #e8f6ee;
  --orange: #b86a12;
  --orange-bg: #fff4e8;
  --red: #b42318;
  --red-bg: #fdecea;
  --gray: #667085;
  --gray-bg: #eef1f4;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 16px 12px; }
.brand { font-weight: 700; padding: 8px 8px 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar button[data-page] { text-align: left; background: transparent; color: #fff; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.sidebar button[data-page].active, .sidebar button[data-page]:hover { background: rgba(255,255,255,.14); }
#logout { margin-top: auto; }
main { flex: 1; padding: 20px 24px 48px; min-width: 0; }
h2 { margin: 0 0 14px; font-size: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.group-card { cursor: pointer; border-top: 4px solid var(--gray); }
.group-card.green { border-top-color: var(--green); }
.group-card.orange { border-top-color: var(--orange); }
.group-card.red { border-top-color: var(--red); }
.group-card.gray { border-top-color: var(--gray); }
.group-card h3 { margin: 0 0 8px; display: flex; justify-content: space-between; font-size: 16px; }
.pill { border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.orange { background: var(--orange-bg); color: var(--orange); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.gray { background: var(--gray-bg); color: var(--gray); }
.muted { color: var(--muted); }
.metrics { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.summary { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.summary div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-width: 120px; }
.summary strong { display: block; font-size: 18px; }
.toolbar, .period, .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
textarea { min-height: 64px; }
.btn { border: 0; border-radius: 8px; min-height: 36px; padding: 6px 12px; cursor: pointer; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { min-height: 30px; padding: 4px 8px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
th { background: #f8fafc; }
.table-wrap, .matrix-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.matrix td, .matrix th { min-width: 52px; text-align: right; white-space: nowrap; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.error { color: var(--red); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; color: var(--navy); font-size: 22px; }
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; }
.modal[hidden], #login-view[hidden], #app-view[hidden] { display: none !important; }
.modal-card { width: min(860px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 14px; padding: 16px 18px 20px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.section { margin-top: 22px; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
@media (max-width: 1100px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar nav { flex-direction: row; overflow: auto; }
  #logout { margin: 8px 0 0; }
  .cards, .grid-2 { grid-template-columns: 1fr; }
  main { padding: 14px; }
}
