:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --panel: #151816;
  --panel2: #1b201c;
  --line: #364033;
  --green: #24b85a;
  --gold: #ffd34d;
  --text: #f2f2e9;
  --muted: #9fa699;
  --red: #ef5b5b;
}

body.theme-light {
  color-scheme: light;
  --bg: #f4f6f2;
  --panel: #ffffff;
  --panel2: #eef3ec;
  --line: #c8d2c4;
  --green: #168a3f;
  --gold: #9b6d10;
  --text: #20251f;
  --muted: #667060;
  --red: #c54040;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 50% 10%, rgba(70, 18, 40, .22), transparent 38%), var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

body.theme-light {
  background: linear-gradient(180deg, #fafbf8, var(--bg));
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 1px solid #8f6a24;
  background: #211d10;
  color: var(--text);
  min-height: 38px;
  padding: 0 18px;
  cursor: pointer;
}

body.theme-light button {
  background: #fff8e4;
  color: var(--text);
}

button:hover {
  border-color: var(--gold);
}

input, textarea, select {
  border: 1px solid var(--line);
  background: #10130f;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

body.theme-light input,
body.theme-light textarea,
body.theme-light select {
  background: #ffffff;
}

textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  font-family: Consolas, "Microsoft YaHei", monospace;
  line-height: 1.55;
}

textarea.small {
  min-height: 140px;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: rgba(18, 21, 18, .96);
  padding: 28px;
}

body.theme-light .login-panel {
  background: rgba(255, 255, 255, .96);
}

.brand {
  color: var(--gold);
  font-size: 30px;
  letter-spacing: 0;
}

.sub {
  color: var(--muted);
  margin: 8px 0 24px;
}

.login-panel input, .login-panel button {
  width: 100%;
  margin-top: 12px;
}

.app {
  display: flex;
  min-height: 100vh;
}

.side {
  width: 220px;
  border-right: 1px solid var(--line);
  background: rgba(12, 14, 12, .96);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

body.theme-light .side {
  background: rgba(247, 249, 245, .96);
}

.side-title {
  color: var(--gold);
  font-size: 22px;
  margin: 8px 10px 20px;
}

.nav, .logout, .theme-toggle {
  width: 100%;
  margin-bottom: 8px;
  border-color: #30382e;
  text-align: left;
}

.nav.active {
  background: #14351d;
  border-color: var(--green);
  color: #dcffe5;
}

body.theme-light .nav,
body.theme-light .logout,
body.theme-light .theme-toggle {
  border-color: var(--line);
}

body.theme-light .nav.active {
  background: #dff2e4;
  color: #0f5e2b;
}

.logout {
  margin-top: 24px;
  color: #ffb6b6;
}

.theme-toggle {
  margin-top: 16px;
}

.main {
  flex: 1;
  padding: 24px;
  min-width: 0;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  color: var(--gold);
  font-size: 28px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.card, .panel {
  border: 1px solid var(--line);
  background: rgba(18, 21, 18, .9);
  padding: 16px;
}

body.theme-light .card,
body.theme-light .panel {
  background: rgba(255, 255, 255, .92);
}

.card-title, .panel-title {
  color: var(--gold);
  margin-bottom: 12px;
}

.big {
  color: var(--green);
  font-size: 30px;
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.toolbar {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.split {
  display: grid;
  grid-template-columns: minmax(260px, 35%) minmax(420px, 1fr);
  gap: 14px;
}

.list {
  max-height: 560px;
  overflow: auto;
  scrollbar-width: thin;
}

.row {
  border: 1px solid #273025;
  background: #11150f;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
}

body.theme-light .row,
body.theme-light .audit-item {
  background: #ffffff;
  border-color: var(--line);
}

.row:hover, .row.active {
  border-color: var(--green);
}

.row-title {
  color: var(--gold);
  margin-bottom: 4px;
}

.row-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.4fr .8fr 1fr 1.2fr;
  gap: 10px;
  margin-bottom: 10px;
}

.form-grid.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.toolbar.two {
  grid-template-columns: minmax(180px, 1fr) auto;
}

.announcement-toolbar {
  grid-template-columns: minmax(160px, 1fr) auto;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.msg {
  min-height: 22px;
  color: var(--red);
  margin-top: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  max-width: min(680px, calc(100vw - 32px));
  background: rgba(16, 19, 15, .98);
  border: 1px solid var(--green);
  color: var(--text);
  padding: 12px 18px;
  z-index: 20;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.mt16 {
  margin-top: 16px;
}

.audit-item {
  border: 1px solid var(--line);
  background: #11150f;
  padding: 12px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.rank {
  color: var(--gold);
}

body.theme-light .toast {
  background: rgba(255, 255, 255, .98);
}

@media (max-width: 820px) {
  .app {
    display: block;
  }
  .side {
    position: static;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .side-title {
    grid-column: 1 / -1;
  }
  .main {
    padding: 14px;
  }
  .toolbar, .split, .form-grid {
    grid-template-columns: 1fr;
  }
  textarea {
    min-height: 300px;
  }
}
