:root {
  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #e9f6f3;
  --blue: #1d4ed8;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #15803d;
  --ink: #17202a;
  --ink-2: #3c4858;
  --muted: #687385;
  --line: #dbe1e8;
  --line-soft: #edf0f3;
  --paper: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 8px;
}

html[data-theme="dark"] {
  --brand: #5eead4;
  --brand-strong: #99f6e4;
  --brand-soft: #153b38;
  --blue: #93c5fd;
  --amber: #fbbf24;
  --red: #fca5a5;
  --green: #86efac;
  --ink: #e7ebef;
  --ink-2: #c6ced8;
  --muted: #9ba6b4;
  --line: #303944;
  --line-soft: #252d36;
  --paper: #111820;
  --surface: #18212a;
  --surface-2: #1e2832;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 8px 24px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body[data-page] {
  overflow-x: hidden;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

button,
.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 14px;
  background: var(--brand);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

button:hover,
.button:hover {
  background: var(--brand-strong);
  text-decoration: none;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.secondary,
.button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--surface-2);
}

button.danger,
.button.danger {
  background: #fee2e2;
  color: var(--red);
  border-color: #fecaca;
}

button.danger:hover,
.button.danger:hover {
  background: #fecaca;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 60px;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  gap: 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--brand);
  font-size: 16px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.main-nav a {
  color: var(--ink-2);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 14px;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--brand);
  background: var(--brand-soft);
  text-decoration: none;
}

.topbar-spacer {
  flex: 1;
}

.topbar-actions,
.session-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-nav .user-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.portal-band {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.portal-band-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 38px 28px 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
  gap: 44px;
  align-items: center;
}

.portal-band-inner > *,
.page > *,
.split-layout > * {
  min-width: 0;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: 0;
}

h3 {
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  color: var(--ink-2);
  font-size: 16px;
}

.search-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.search-panel h2 {
  margin-bottom: 5px;
  font-size: 18px;
}

.search-panel p {
  color: var(--muted);
  font-size: 13px;
}

.search-form {
  display: flex;
  gap: 8px;
}

.search-form input {
  flex: 1;
  min-width: 0;
}

.page {
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-header h1 {
  margin-bottom: 4px;
  font-size: 30px;
}

.page-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.section {
  margin-bottom: 28px;
}

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

.section-header h2,
.section-header h3 {
  margin-bottom: 0;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 26px;
}

.stat {
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat strong {
  display: block;
  font-size: 25px;
  line-height: 1.2;
}

.stat span {
  color: var(--muted);
  font-size: 12.5px;
}

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

.resource-card {
  min-width: 0;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 190px;
}

.resource-card[data-category="实用工具"] {
  border-top-color: var(--amber);
}

.resource-card[data-category="知识模块"] {
  border-top-color: var(--brand);
}

.resource-card .category {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.resource-card h3 {
  margin: 7px 0 7px;
}

.resource-card h3 a {
  color: var(--ink);
}

.resource-card p {
  flex: 1;
  margin-bottom: 12px;
  color: var(--ink-2);
  font-size: 13.5px;
}

.resource-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  white-space: nowrap;
}

.list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.list-item {
  padding: 15px 17px;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item:hover {
  background: var(--surface-2);
}

.list-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.list-item h3 a {
  color: var(--ink);
}

.list-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.list-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 180px;
  resize: vertical;
}

.input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-color: var(--brand);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
}

.field .hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

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

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 16px;
}

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

.auth-shell {
  min-height: calc(100vh - 61px);
  display: grid;
  place-items: center;
  padding: 28px 20px;
}

.auth-card {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 28px;
}

.auth-card .switch {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.notice {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
}

.notice.warn {
  border-left-color: var(--amber);
}

.notice.danger {
  border-left-color: var(--red);
}

.hidden {
  display: none !important;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.tag-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 44px));
  padding: 11px 14px;
  border-radius: 7px;
  background: #111827;
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  font-size: 13.5px;
}

.toast.error {
  background: #991b1b;
}

.footer {
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 28px 40px;
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 980px) {
  .portal-band-inner,
  .split-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 14px;
  }

  .main-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .main-nav a {
    white-space: nowrap;
  }

  .topbar-spacer {
    display: none;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .session-nav .user-name,
  .session-nav .admin-link {
    display: none;
  }

  .portal-band-inner {
    padding: 26px 18px 24px;
    gap: 24px;
  }

  .page {
    padding: 20px 14px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .list-item {
    grid-template-columns: 1fr;
  }

  .list-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 8px 10px;
    gap: 7px 8px;
  }

  .brand {
    gap: 7px;
    font-size: 14px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .brand small {
    display: none;
  }

  .topbar-actions,
  .session-nav {
    gap: 5px;
  }

  .session-nav a,
  .session-nav .button,
  .topbar-actions > button {
    font-size: 12px;
  }

  .session-nav .button {
    padding: 5px 9px;
  }

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

  .search-form {
    flex-direction: column;
  }

  .auth-card {
    padding: 22px 18px;
  }
}
