:root {
  --bg: #f4f8ff;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #cfe0f3;
  --blue: #1677ff;
  --blue-soft: #eaf3ff;
  --green: #ccf7e3;
  --green-text: #047857;
  --red: #e84252;
  --sidebar: #13243d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  padding: 26px 20px;
  background: linear-gradient(180deg, #0f1d33, var(--sidebar));
  color: #dbeafe;
}

.brand h1 {
  margin: 0 0 10px;
  font-size: 26px;
}

.brand p {
  margin: 0 0 28px;
  color: #9fb5d5;
}

.nav-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 16px 18px;
  color: white;
  background: var(--blue);
  text-align: left;
  font-size: 18px;
  font-weight: 700;
}

.nav-btn + .nav-btn {
  margin-top: 10px;
}

.nav-btn.subtle {
  border: 1px solid rgba(219, 234, 254, 0.25);
  background: rgba(219, 234, 254, 0.08);
}

.main {
  margin-left: 240px;
  padding: 22px 24px 34px;
}

.topbar,
.toolbar,
.workspace > div,
.auth-panel,
.access-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 26px;
}

.topbar h2,
.toolbar h3,
.panel-title h3,
.detail-head h2,
.form-section h3 {
  margin: 0;
}

.topbar p,
.detail-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.top-actions,
.detail-actions,
.filters,
.metrics,
.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill,
.publish-pill,
.metric {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--blue-soft);
  color: #264969;
  font-weight: 700;
  white-space: nowrap;
}

.publish-pill {
  background: var(--green);
  color: var(--green-text);
}

.dirty-badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 12px;
  background: #fff2d8;
  color: #9a5b00;
  font-weight: 700;
}

.btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  color: #163659;
  background: #eef6ff;
  cursor: pointer;
  font-weight: 700;
}

.btn.primary {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.btn.danger {
  color: white;
  border-color: var(--red);
  background: var(--red);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  padding: 16px;
}

.auth-panel {
  margin-top: 20px;
  padding: 22px;
}

.auth-panel h3 {
  margin: 0 0 8px;
}

.auth-panel p {
  margin: 0 0 14px;
  color: var(--muted);
}

.metrics {
  margin-top: 10px;
}

.filters label {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.filters label span {
  padding-left: 12px;
  color: #334155;
  font-weight: 700;
}

.filters select,
.filters input {
  min-height: 40px;
  border: 0;
  outline: 0;
  padding: 0 12px;
  background: transparent;
}

.filters input {
  width: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.access-panel {
  margin-top: 18px;
  padding: 18px;
}

.access-panel .panel-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.access-users {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.access-user {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 130px minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.access-user strong {
  display: block;
}

.access-user small {
  color: var(--muted);
}

.list-panel,
.detail-panel {
  min-height: calc(100vh - 210px);
  padding: 18px;
}

.panel-title,
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.material-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 305px);
  margin-top: 16px;
  overflow: auto;
}

.material-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
  text-align: left;
  cursor: pointer;
}

.material-card.active {
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.material-card h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.material-card p {
  margin: 0 0 8px;
  color: var(--muted);
}

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

.tag {
  border-radius: 8px;
  padding: 3px 8px;
  background: #e8eef6;
  color: #51657c;
}

.material-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.detail-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.tab-btn {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  color: #3b5876;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.tab-btn.active {
  border-color: var(--line);
  color: #0f4fa8;
  background: var(--blue-soft);
}

.readonly-detail {
  margin-top: 16px;
}

.read-panel {
  display: grid;
  gap: 16px;
}

.read-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.read-grid > div,
.read-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.read-grid span,
.read-block > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.read-grid strong,
.read-block p {
  margin: 0;
  color: #172033;
  line-height: 1.55;
}

.empty-value {
  color: #94a3b8;
  font-weight: 500;
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.score-summary div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
}

.score-summary span {
  margin: 0;
  color: var(--muted);
}

.file-link {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: #0f5ec7;
  background: white;
  font-weight: 700;
  text-decoration: none;
}

.file-link + .file-link {
  margin-top: 8px;
}

.sticky-save-bar {
  position: sticky;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.08);
  font-weight: 700;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfdff;
}

.form-section h3 {
  margin-bottom: 14px;
  font-size: 16px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: #111827;
  background: white;
}

textarea {
  resize: vertical;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.score-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}

.score-row input {
  padding: 0;
}

.file-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
}

.file-item a {
  color: #0f5ec7;
  font-weight: 700;
  text-decoration: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  border-radius: 8px;
  padding: 12px 16px;
  color: white;
  background: #172033;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
}

.hidden {
  display: none;
}

@media (max-width: 1180px) {
  .workspace,
  .grid.two,
  .grid.three,
  .score-grid,
  .access-user,
  .read-grid,
  .read-grid.two-read,
  .score-summary {
    grid-template-columns: 1fr;
  }

  .material-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 14px;
  }

  .topbar,
  .toolbar,
  .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .filters input {
    width: 100%;
  }
}
