: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;
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  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: var(--sidebar-width);
  padding: 18px 14px;
  background: linear-gradient(180deg, #0f1d33, var(--sidebar));
  color: #dbeafe;
  transition: width 0.18s ease, padding 0.18s ease;
}

.sidebar-toggle {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(219, 234, 254, 0.28);
  border-radius: 8px;
  margin: 0 0 18px auto;
  color: #dbeafe;
  background: rgba(219, 234, 254, 0.08);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.toggle-collapsed {
  display: none;
  font-size: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  margin-bottom: 28px;
}

.brand img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
}

.brand h1 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  margin: 0;
  color: #9fb5d5;
  font-size: 13px;
}

.nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  color: white;
  background: var(--blue);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-btn:hover,
.sidebar-toggle:hover {
  border-color: rgba(219, 234, 254, 0.42);
  filter: brightness(1.06);
}

.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);
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main {
  margin-left: var(--sidebar-width);
  padding: 18px 22px 30px;
  transition: margin-left 0.18s ease;
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
  padding: 16px 10px;
}

body.sidebar-collapsed .main {
  margin-left: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-toggle {
  margin-right: auto;
}

body.sidebar-collapsed .toggle-collapsed {
  display: block;
}

body.sidebar-collapsed .toggle-expanded {
  display: none;
}

body.sidebar-collapsed .brand {
  justify-content: center;
  margin-bottom: 26px;
}

body.sidebar-collapsed .brand img {
  width: 44px;
  height: 44px;
}

body.sidebar-collapsed .brand div,
body.sidebar-collapsed .nav-text {
  display: none;
}

body.sidebar-collapsed .nav-btn {
  justify-content: center;
  min-height: 48px;
  padding: 0;
  text-align: center;
}

.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: 18px 22px;
}

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

.topbar h2 {
  font-size: 21px;
}

.toolbar h3,
.panel-title h3 {
  font-size: 16px;
}

.detail-head h2 {
  font-size: 19px;
}

.topbar p,
.detail-head p {
  margin: 6px 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: 28px;
  border-radius: 999px;
  padding: 3px 10px;
  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: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  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;
}

.btn.compact {
  min-height: 32px;
  padding: 0 10px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(620px, auto);
  align-items: stretch;
  gap: 18px;
  margin-top: 14px;
  padding: 18px 20px;
}

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

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

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

.toolbar-summary {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.toolbar-summary h3 {
  flex: 0 0 auto;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 8px;
  min-width: 0;
  margin-top: 0;
  overflow: visible;
  padding-bottom: 0;
  white-space: nowrap;
}

.metrics .metric {
  min-height: 30px;
  padding: 4px 12px;
}

.filters {
  display: grid;
  gap: 10px;
  justify-content: end;
  align-content: center;
  border-radius: 8px;
  padding: 10px;
  background: #f8fbff;
}

.filter-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

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

.filters label span {
  min-width: 46px;
  padding: 0 8px 0 12px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

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

.filters select {
  min-width: 112px;
  color: #172033;
  font-weight: 650;
}

.filters input {
  width: clamp(300px, 28vw, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: white;
}

.filter-actions {
  align-items: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 400px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.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 - 178px);
  padding: 14px;
}

.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;
}

.list-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fbff;
}

.segmented button {
  min-height: 32px;
  border: 0;
  padding: 0 10px;
  color: #3b5876;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}

.segmented button.active {
  color: white;
  background: var(--blue);
}

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

.batch-bar {
  display: grid;
  grid-template-columns: auto 150px minmax(120px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px;
  background: #f8fbff;
}

.batch-bar strong {
  color: #244763;
}

.material-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  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: 14px;
  line-height: 1.35;
}

.material-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.material-card-head input {
  width: auto;
  margin-top: 2px;
}

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

.completeness {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}

.completeness div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.completeness strong {
  color: #1f4268;
}

.completeness i {
  height: 7px;
  border-radius: 999px;
  background: #e8eef6;
  overflow: hidden;
}

.completeness b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #21c083, #1677ff);
}

.material-list.table-mode {
  display: block;
}

.material-table {
  display: grid;
  gap: 6px;
}

.material-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 90px 140px 90px 120px;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: #1e293b;
  background: white;
  text-align: left;
  font-size: 13px;
}

.material-row.table-head {
  color: var(--muted);
  background: #f6f9fd;
  font-size: 13px;
  font-weight: 800;
}

button.material-row {
  cursor: pointer;
}

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

.material-row strong,
.material-row small {
  display: block;
}

.material-row small {
  color: var(--muted);
}

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

.row-title input {
  width: auto;
}

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

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

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

.detail-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding: 10px 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: 12px;
}

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

.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;
}

.hint-text {
  margin: 8px 0 0;
  color: var(--muted);
}

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

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

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

.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;
}

.tag-editor {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}

.tag-editor.tall {
  min-height: 114px;
}

.tag-editor-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 30px;
  align-items: center;
}

.editable-tag {
  border: 0;
  cursor: pointer;
}

.tag-editor-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.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,
  .toolbar,
  .grid.two,
  .grid.three,
  .score-grid,
  .access-user,
  .read-grid,
  .read-grid.two-read,
  .score-summary,
  .material-row,
  .batch-bar {
    grid-template-columns: 1fr;
  }

  .filters input {
    width: min(100%, 420px);
  }

  .filters {
    justify-content: stretch;
  }

  .metrics {
    grid-template-columns: repeat(3, max-content);
  }

  .filter-row {
    justify-content: flex-start;
  }

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

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

  body.sidebar-collapsed .sidebar {
    width: auto;
    padding: 12px;
  }

  .sidebar-toggle {
    margin: 0 0 12px;
  }

  .brand,
  body.sidebar-collapsed .brand {
    justify-content: flex-start;
    margin-bottom: 12px;
  }

  body.sidebar-collapsed .brand div {
    display: block;
  }

  body.sidebar-collapsed .brand img {
    width: 42px;
    height: 42px;
  }

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

  .nav-btn,
  body.sidebar-collapsed .nav-btn {
    justify-content: center;
    min-height: 40px;
    padding: 0 10px;
    font-size: 15px;
    text-align: center;
  }

  body.sidebar-collapsed .nav-text {
    display: inline;
  }

  .nav-btn + .nav-btn {
    margin-top: 0;
  }

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

  body.sidebar-collapsed .main {
    margin-left: 0;
  }

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

  .toolbar-summary {
    gap: 10px;
  }

  .metrics {
    width: 100%;
    grid-template-columns: repeat(2, max-content);
    overflow-x: auto;
  }

  .filters input {
    width: 100%;
  }

  .filters,
  .top-actions,
  .detail-actions {
    align-items: stretch;
  }

  .filter-row,
  .filters label {
    width: 100%;
  }

  .filters select {
    min-width: 0;
    flex: 1;
  }
}
