:root {
  color-scheme: light;
  --red: #d9342b;
  --red-dark: #b92722;
  --red-soft: #ef4545;
  --gold: #ffd45a;
  --bg: #e7e7e7;
  --paper: #ffffff;
  --line: #e2e6ed;
  --line-strong: #c8d0dc;
  --text: #202734;
  --muted: #6d7584;
  --blue: #4d95ed;
  --green: #2b8c68;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button,
.button-link {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button.primary,
.button-link.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

button.primary:hover,
.button-link.primary:hover {
  background: var(--red-dark);
}

.button-link.compact {
  min-height: 30px;
  padding: 0 10px;
}

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

textarea {
  resize: vertical;
}

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

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--red), var(--red-dark));
}

.login-box {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 6px;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(80, 0, 0, 0.24);
}

.login-mark,
.site-emblem,
.org-emblem {
  background: var(--gold);
  color: var(--red);
  font-weight: 800;
  display: grid;
  place-items: center;
}

.login-mark {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  margin-bottom: 16px;
}

.login-box h1,
.login-box p {
  margin: 0;
}

.login-box h1 {
  font-size: 23px;
}

.login-box p {
  color: var(--muted);
  margin-top: 8px;
}

.form-stack,
.edit-form,
.upload-form {
  display: grid;
  gap: 14px;
}

.form-stack {
  margin-top: 22px;
}

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

.site-header {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #dc3a33, #c92b25);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 max(24px, calc((100vw - 1560px) / 2));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.site-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-title strong {
  font-size: 24px;
  line-height: 1.2;
  display: block;
}

.site-title span:last-child {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
}

.site-emblem {
  width: 46px;
  height: 46px;
  border-radius: 50%;
}

.header-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.header-button {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.sidebar {
  background: var(--red);
  color: #fff;
  padding: 22px 0 34px;
}

.org-card {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 0 18px 24px;
  text-align: center;
}

.org-card strong {
  font-size: 18px;
}

.org-card span {
  color: rgba(255, 255, 255, 0.82);
}

.org-emblem {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  font-size: 36px;
}

.nav,
.subnav {
  display: grid;
}

.nav button,
.subnav button {
  min-height: 54px;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0;
  background: transparent;
  color: #fff;
  justify-content: flex-start;
  padding: 0 28px;
  font-weight: 600;
}

.nav button:hover,
.nav button.active,
.subnav button:hover,
.subnav button.active {
  background: var(--red-soft);
}

.subnav {
  margin-top: 16px;
  background: rgba(120, 0, 0, 0.14);
}

.subnav button {
  min-height: 44px;
  padding-left: 46px;
  font-size: 14px;
  font-weight: 400;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: 48px 1fr;
}

.crumb {
  min-height: 48px;
  display: flex;
  align-items: center;
  background: #f4f4f4;
  color: var(--muted);
  border-bottom: 1px solid #d8d8d8;
  padding: 0 28px;
}

.content {
  padding: 28px;
}

.table-panel,
.document-page,
.activity-page,
.payment-page,
.downloads-page,
.mine-page,
.admin-page {
  background: var(--paper);
  border-top: 4px solid var(--red);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 24px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 10px;
}

.section-title h2,
.document-head h2,
.activity-hero h2,
.admin-toolbar h2,
.profile-card h2 {
  margin: 0;
  font-size: 24px;
}

.section-title p,
.activity-hero p,
.profile-card p,
.admin-toolbar p,
.meta {
  margin: 6px 0 0;
  color: var(--muted);
}

.row-table {
  border-top: 1px solid var(--line);
}

.list-row {
  width: 100%;
  min-height: 70px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 150px;
  align-items: center;
  gap: 18px;
  text-align: left;
  background: #fff;
  padding: 0 18px;
}

.list-row:hover {
  background: #fff8f8;
}

.row-tag {
  color: var(--blue);
  font-weight: 700;
}

.row-title {
  min-width: 0;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-date,
.row-actions {
  text-align: right;
}

.direct-row {
  grid-template-columns: 150px minmax(0, 1fr) 180px;
}

.back-button {
  margin-bottom: 20px;
}

.document-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}

.lead,
.notice-box,
.article-body {
  line-height: 1.9;
  white-space: pre-wrap;
}

.pdf-frame {
  width: 100%;
  height: 78vh;
  border: 1px solid var(--line-strong);
  background: #2f2f2f;
  display: block;
}

.download-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.activity-hero {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 20px;
}

.activity-hero img,
.cover-placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #f0f2f5;
  border: 1px solid var(--line);
}

.cover-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.article-body {
  font-size: 16px;
}

.payment-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.qr-panel {
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px;
  width: fit-content;
}

.qr-image {
  width: 320px;
  max-width: 100%;
  display: block;
}

.rules-panel {
  border: 1px solid var(--line);
  background: #fffafa;
  padding: 18px;
  margin-bottom: 18px;
}

.mine-page {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1.2fr);
  gap: 22px;
}

.profile-card,
.admin-card,
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 18px;
}

.info-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table th,
.info-table td,
.admin-table th,
.admin-table td {
  border: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
}

.info-table th,
.admin-table th {
  background: #f7f7f7;
  color: var(--muted);
  font-weight: 600;
}

.admin-table thead th {
  background: var(--red-soft);
  color: #fff;
}

.admin-home,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.admin-card {
  min-height: 118px;
  display: grid;
  gap: 8px;
  text-align: left;
  align-content: start;
}

.admin-card strong,
.stat-card strong {
  font-size: 22px;
}

.admin-card span,
.stat-card span {
  color: var(--muted);
  line-height: 1.6;
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}

.form-grid,
.settings-grid,
.inline-form {
  display: grid;
  gap: 14px;
}

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

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

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

.inline-form {
  grid-template-columns: 160px minmax(180px, 1fr) 140px auto;
  margin-bottom: 18px;
}

.file-manager {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.upload-form {
  margin-top: 16px;
  grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) minmax(260px, 1fr) auto;
  align-items: end;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.usage-bar {
  height: 14px;
  background: #f0f2f5;
  border: 1px solid var(--line);
  margin: 16px 0 8px;
}

.usage-bar span {
  height: 100%;
  display: block;
  background: var(--green);
}

.success,
.error,
.empty,
.notice-banner {
  background: #fff;
  border: 1px solid var(--line);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.success {
  border-left: 4px solid var(--green);
  color: var(--green);
}

.error,
.notice-banner,
.needs-action {
  border-left: 4px solid var(--red);
}

.error {
  color: var(--red-dark);
}

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

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

  .site-header,
  .sidebar,
  .main {
    grid-column: 1;
  }

  .site-header {
    padding: 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  .org-card {
    display: none;
  }

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

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

  .subnav button {
    padding-left: 28px;
  }

  .content {
    padding: 16px;
  }

  .list-row,
  .direct-row {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 4px 12px;
    padding: 12px;
  }

  .row-date,
  .row-actions {
    grid-column: 2;
    text-align: left;
  }

  .row-title {
    white-space: normal;
  }

  .activity-hero,
  .payment-grid,
  .mine-page,
  .form-grid.two,
  .form-grid.three,
  .settings-grid,
  .inline-form,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .pdf-frame {
    height: 72vh;
  }
}
