:root {
  color: #302826;
  background: #f7f3ec;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.98), rgba(238, 245, 242, 0.95)),
    #f7f3ec;
}

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

button {
  border: 0;
  border-radius: 10px;
  padding: 11px 15px;
  color: #fff;
  background: #e86d55;
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.97);
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

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

.login-screen[hidden],
.shell[hidden] {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(440px, 100%);
  border: 1px solid #ead9cc;
  border-radius: 18px;
  padding: 28px;
  background: #fffdf9;
  box-shadow: 0 18px 46px rgba(78, 56, 40, 0.12);
}

.login-card h1 {
  margin-bottom: 0;
}

.login-card button {
  width: 100%;
}

#loginMessage {
  min-height: 20px;
  color: #d65b43;
  font-weight: 900;
}

.topbar,
.library,
.editor-panel {
  border: 1px solid #ead9cc;
  background: rgba(255, 253, 249, 0.92);
  box-shadow: 0 14px 34px rgba(78, 56, 40, 0.08);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 138px;
  border-radius: 16px;
  padding: 24px 28px;
}

.eyebrow,
.subtitle,
h1,
h2,
p {
  margin-top: 0;
}

.eyebrow {
  margin-bottom: 7px;
  color: #d65b43;
  font-size: 13px;
  font-weight: 900;
}

h1 {
  margin-bottom: 8px;
  font-size: 42px;
  line-height: 1;
}

h2 {
  margin-bottom: 6px;
  font-size: 23px;
}

.subtitle,
.library-head p,
.hint,
.section-title p {
  color: #756861;
  line-height: 1.55;
}

.status-card {
  display: grid;
  gap: 7px;
  min-width: 190px;
  border-radius: 14px;
  padding: 16px;
  color: #4d403b;
  background: #fff0d9;
}

.status-card span {
  color: #806f66;
  font-size: 13px;
}

.status-card strong {
  font-size: 22px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.admin-nav {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  border: 1px solid #ead9cc;
  border-radius: 16px;
  padding: 10px;
  background: #fffdf9;
  box-shadow: 0 10px 24px rgba(78, 56, 40, 0.06);
}

.admin-nav button {
  min-height: 44px;
  padding: 10px 8px;
  color: #5b4b45;
  background: #f8efe5;
}

.admin-nav button.active {
  color: #fff;
  background: #e86d55;
}

.view-section[hidden] {
  display: none;
}

.metric-card {
  min-height: 108px;
  border: 1px solid #ead9cc;
  border-radius: 14px;
  padding: 14px;
  background: #fffdf9;
  box-shadow: 0 10px 24px rgba(78, 56, 40, 0.06);
}

.metric-card span {
  color: #756861;
  font-size: 12px;
  font-weight: 900;
}

.metric-card strong {
  display: block;
  margin: 6px 0 4px;
  color: #d65b43;
  font-size: 28px;
  line-height: 1;
}

.metric-card p {
  margin: 0;
  color: #756861;
  font-size: 12px;
  line-height: 1.4;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.sync-panel {
  margin-top: 14px;
  border: 1px solid #ead9cc;
  border-radius: 16px;
  padding: 18px;
  background: rgba(255, 253, 249, 0.92);
  box-shadow: 0 14px 34px rgba(78, 56, 40, 0.08);
}

.suggestion-panel {
  margin-top: 14px;
  border: 1px solid #ead9cc;
  border-radius: 16px;
  padding: 18px;
  background: rgba(255, 253, 249, 0.92);
  box-shadow: 0 14px 34px rgba(78, 56, 40, 0.08);
}

.suggestion-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.suggestion-card {
  display: grid;
  gap: 7px;
  min-height: 96px;
  border: 1px solid #d8ece8;
  padding: 13px;
  color: #302826;
  background: #f4fbf9;
  text-align: left;
}

.suggestion-card strong {
  color: #2d665e;
  font-size: 17px;
}

.suggestion-card span {
  color: #756861;
  font-size: 12px;
  line-height: 1.45;
}

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

.section-title h2,
.sync-layout h3 {
  margin: 0 0 6px;
}

.sync-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sync-metric {
  border: 1px solid #d8ece8;
  border-radius: 13px;
  padding: 13px;
  background: #f4fbf9;
}

.sync-metric span,
.family-stats span,
.record-row span {
  color: #756861;
  font-size: 12px;
  font-weight: 900;
}

.sync-metric strong {
  display: block;
  margin: 5px 0 4px;
  color: #2d665e;
  font-size: 25px;
}

.sync-metric p {
  margin: 0;
  color: #756861;
  font-size: 12px;
}

.sync-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 14px;
}

.family-list,
.recent-records,
.user-list,
.audit-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.family-card,
.record-row,
.user-card,
.audit-card,
.material-card,
.backup-grid article {
  border: 1px solid #ead9cc;
  border-radius: 13px;
  padding: 13px;
  background: #fffdf9;
}

.family-head,
.record-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.family-head strong,
.record-row strong {
  display: block;
  color: #302826;
  line-height: 1.35;
}

.family-head span,
.family-head em,
.record-row time {
  display: block;
  color: #756861;
  font-size: 12px;
  font-style: normal;
}

.family-head em {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  color: #a8563e;
  background: #fff0d9;
  font-weight: 900;
}

.family-stats,
.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.family-stats span,
.member-list span {
  border-radius: 999px;
  padding: 5px 8px;
  background: #f8efe5;
}

.member-list span {
  color: #2d665e;
  background: #e2f6f1;
  font-size: 12px;
  font-weight: 900;
}

.record-row {
  align-items: flex-start;
}

.record-row time {
  flex: 0 0 auto;
  text-align: right;
}

.compact-filter {
  margin: 0 0 14px;
}

.user-head,
.audit-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.user-head strong,
.audit-card strong,
.material-card strong,
.backup-grid h3 {
  display: block;
  color: #302826;
  line-height: 1.35;
}

.user-head span,
.audit-card span,
.material-card span,
.material-card p,
.backup-grid p {
  color: #756861;
  font-size: 12px;
  line-height: 1.45;
}

.user-head em {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.status-active {
  color: #2d665e;
  background: #e2f6f1;
}

.status-disabled {
  color: #9b4e2c;
  background: #fff0d9;
}

.status-deleted {
  color: #8b3340;
  background: #ffe5ea;
}

.user-edit-grid,
.advanced-grid,
.backup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.user-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.audit-card {
  align-items: center;
}

.audit-card p {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.audit-card em {
  border-radius: 999px;
  padding: 5px 8px;
  color: #9b4e2c;
  background: #fff0d9;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.material-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.material-summary article {
  border: 1px solid #d8ece8;
  border-radius: 13px;
  padding: 13px;
  background: #f4fbf9;
}

.material-summary strong {
  display: block;
  color: #2d665e;
  font-size: 28px;
}

.material-summary span {
  color: #756861;
  font-size: 12px;
  font-weight: 900;
}

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

.material-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.material-card img,
.image-placeholder {
  width: 104px;
  height: 76px;
  border-radius: 10px;
  object-fit: cover;
  background: #f8efe5;
}

.image-placeholder {
  display: grid;
  place-items: center;
  color: #9b4e2c;
  font-size: 12px;
  font-weight: 900;
}

.advanced-box {
  border: 1px solid #ead9cc;
  border-radius: 14px;
  padding: 12px;
  background: #fff8ef;
}

.advanced-box summary {
  cursor: pointer;
  color: #5b4b45;
  font-weight: 900;
}

.library,
.editor-panel {
  border-radius: 16px;
  padding: 18px;
}

.library {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

.library-head,
.editor-head,
.preview-head,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  font-size: 26px;
  line-height: 1;
}

.filters {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border-radius: 14px;
  background: #f8efe5;
}

.bulk-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  border: 1px solid #ead9cc;
  border-radius: 14px;
  padding: 12px;
  background: #fffdf9;
}

.bulk-panel strong {
  display: block;
  color: #302826;
  margin-bottom: 3px;
}

.bulk-panel span {
  color: #756861;
  font-size: 12px;
}

.bulk-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.bulk-actions button {
  min-width: 0;
  padding: 8px 7px;
  font-size: 12px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #5b4b45;
  font-size: 13px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #e8d3c2;
  border-radius: 10px;
  padding: 12px 13px;
  color: #302826;
  background: #fffdf9;
  outline: none;
}

textarea {
  min-height: 260px;
  line-height: 1.65;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #63bdae;
  box-shadow: 0 0 0 3px rgba(99, 189, 174, 0.16);
}

.content-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 286px);
  overflow: auto;
  padding-right: 4px;
}

.content-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 48px;
  gap: 12px;
  border: 1px solid #ead9cc;
  border-radius: 13px;
  padding: 13px;
  background: #fffdf9;
  cursor: pointer;
}

.row-check {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 3px;
}

.row-check input {
  width: 17px;
  height: 17px;
  padding: 0;
}

.content-row.active {
  border-color: #e86d55;
  background: #fff3e8;
}

.content-row h3 {
  margin: 7px 0 5px;
  font-size: 16px;
  line-height: 1.35;
}

.content-row p {
  margin: 0;
  color: #766a64;
  font-size: 13px;
  line-height: 1.45;
}

.content-row strong {
  align-self: start;
  border-radius: 9px;
  padding: 5px 3px;
  color: #a8563e;
  background: #fff0d9;
  text-align: center;
  font-size: 12px;
}

.row-meta,
.preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-meta span,
.preview-tags span {
  border-radius: 999px;
  padding: 4px 8px;
  color: #2d665e;
  background: #e2f6f1;
  font-size: 12px;
  font-weight: 900;
}

.row-meta .featured-dot,
.preview-tags span:last-child {
  color: #a8563e;
  background: #fff0d9;
}

.quality-mini {
  width: fit-content;
  margin-top: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
}

.quality-mini.ok {
  color: #2d665e;
  background: #e2f6f1;
}

.quality-mini.warn {
  color: #9b4e2c;
  background: #fff0d9;
}

.editor-head {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #efdfd2;
}

.editor-actions {
  display: flex;
  gap: 9px;
}

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

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 3px;
}

.checkline input {
  width: 18px;
  height: 18px;
}

.body-editor {
  border: 1px solid #ead9cc;
  border-radius: 14px;
  padding: 12px;
  background: #fff8ef;
}

.body-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.body-toolbar span {
  color: #5b4b45;
  font-size: 13px;
  font-weight: 900;
}

.body-toolbar div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.body-toolbar button,
.ghost {
  color: #5b4b45;
  background: #fff0d9;
}

.body-toolbar button {
  min-width: auto;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
}

.quality-panel {
  border: 1px solid #ead9cc;
  border-radius: 14px;
  padding: 14px;
  background: #fffdf9;
}

.quality-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quality-chip {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.quality-chip.ok {
  color: #2d665e;
  background: #e2f6f1;
}

.quality-chip.warn {
  color: #9b4e2c;
  background: #fff0d9;
}

.preview-panel {
  border: 1px solid #d8ece8;
  border-radius: 14px;
  padding: 14px;
  background: #f4fbf9;
}

.preview-head {
  margin-bottom: 12px;
}

#saveStatus {
  border-radius: 999px;
  padding: 5px 10px;
  color: #2d665e;
  background: #dff5f0;
  font-size: 12px;
  font-weight: 900;
}

.preview-card {
  display: grid;
  gap: 10px;
  max-width: 520px;
  border: 1px solid #ead9cc;
  border-radius: 16px;
  padding: 14px;
  background: #fffdf9;
}

.preview-card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  border-radius: 12px;
  background: #f8efe5;
}

.preview-card h3 {
  margin: 0;
  font-size: 20px;
}

.preview-card p {
  margin: 0;
  color: #5f544f;
  line-height: 1.65;
}

.preview-card .summary {
  color: #3f3531;
  font-weight: 900;
}

.form-actions {
  justify-content: flex-end;
  padding-top: 4px;
}

.danger {
  background: #df5365;
}

.empty {
  border: 1px dashed #d8c7ba;
  border-radius: 12px;
  padding: 18px;
  color: #756861;
  background: #fffdf9;
  text-align: center;
}

@media (max-width: 980px) {
  .topbar,
  .dashboard,
  .sync-layout,
  .metrics-grid,
  .sync-metrics,
  .suggestion-list,
  .admin-nav,
  .material-grid,
  .material-summary,
  .user-edit-grid,
  .advanced-grid,
  .backup-grid,
  .filter-grid,
  .editor-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-title,
  .dashboard {
    display: grid;
  }

  .library {
    position: static;
    max-height: none;
  }

  .content-list {
    max-height: 420px;
  }

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

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

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .topbar,
  .library,
  .editor-panel {
    padding: 14px;
    border-radius: 13px;
  }

  .library-head,
  .editor-head,
  .preview-head,
  .form-actions,
  .family-head,
  .record-row,
  .user-head,
  .audit-card,
  .body-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 34px;
  }

  .editor-actions,
  .form-actions,
  .bulk-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  button {
    width: 100%;
  }
}
