:root {
  color-scheme: light;
  --bg: #f4f1e9;
  --card: rgba(255, 253, 248, .9);
  --surface: #fffdf8;
  --field: #f1ede4;
  --line: rgba(92, 82, 68, .18);
  --text: #292724;
  --muted: #68635c;
  --primary: #285e8b;
  --primary-strong: #214f75;
  --primary-soft: #eaf0f4;
  --blue: #285e8b;
  --gold: #c69a2f;
  --orange: #a66b1f;
  --danger: #c94037;
  --danger-soft: #f8e9e5;
  --success: #3f735f;
  --success-soft: #e7f0ea;
  --shadow: 0 22px 62px rgba(48, 42, 34, .12);
  --soft-shadow: 0 10px 28px rgba(48, 42, 34, .07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -24px -24px 22px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 241, 233, .88);
  backdrop-filter: blur(24px);
}

.header-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.header-brand > div {
  min-width: 0;
}

.brand-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid #e8dfce;
  border-radius: 11px;
  background-color: var(--surface);
  background-image: url("./xinyuan-mark.png");
  background-repeat: no-repeat;
  background-position: 50% 30%;
  background-size: 102px auto;
  box-shadow: 0 4px 14px rgba(48, 42, 34, .07);
}

.header-actions,
.section-head,
.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-actions {
  flex-wrap: wrap;
}

.header-actions .muted {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

header p,
h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

header p {
  color: var(--muted);
  font-size: 13px;
}

h1 {
  font-size: 28px;
  line-height: 1.12;
}

h2 {
  font-size: 21px;
  line-height: 1.2;
}

h1,
h2,
.summary strong {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, SimSun, serif;
  font-weight: 600;
}

h3 {
  font-size: 16px;
}

.card,
.summary > div,
.module-card,
.manage-form,
.export-tips div {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--soft-shadow);
}

.card {
  padding: 20px;
}

.login {
  max-width: 430px;
  margin-top: 34px;
  border-top: 3px solid var(--primary);
}

label {
  display: block;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.permission-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--field);
  color: var(--text);
}

.permission-toggle input {
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

input,
button,
select,
textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 11px 13px;
  font: inherit;
  background: var(--field);
  color: var(--text);
}

textarea {
  resize: vertical;
}

button {
  width: auto;
  cursor: pointer;
  font-weight: 700;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .08s ease, opacity .15s ease;
}

.primary {
  width: 100%;
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

button:hover:not(:disabled) {
  border-color: rgba(40, 94, 139, .36);
  box-shadow: 0 8px 22px rgba(40, 94, 139, .13);
}

button:active:not(:disabled) {
  transform: scale(.985);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 4px solid rgba(40, 94, 139, .14);
  outline-offset: 1px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .58;
}

button.is-loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  vertical-align: -2px;
  animation: spin .72s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.compact {
  align-self: end;
  width: auto;
  min-width: 96px;
}

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

.summary > div {
  padding: 20px;
}

.summary > div:first-child {
  border-top: 3px solid var(--primary);
}

.summary > div:nth-child(2) {
  border-top: 3px solid var(--danger);
}

.summary > div:nth-child(3) {
  border-top: 3px solid var(--success);
}

.summary strong {
  display: block;
  font-size: 36px;
  line-height: 1;
}

.summary span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

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

.module-card {
  min-height: 176px;
  width: 100%;
  padding: 20px;
  text-align: left;
}

.module-card span {
  display: inline-grid;
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--blue);
  font-weight: 900;
}

.module-card:nth-child(1) span {
  background: var(--primary-soft);
  color: var(--primary);
}

.module-card:nth-child(2) span {
  background: #fbf1dc;
  color: var(--orange);
}

.module-card:nth-child(3) span {
  background: var(--danger-soft);
  color: var(--danger);
}

.module-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.module-card em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.45;
}

.module-card.disabled {
  color: #9a9aa0;
  background: rgba(255, 255, 255, .48);
}

.module-card.disabled span {
  background: #ececf0;
  color: #9a9aa0;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) 150px 170px 170px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(241, 237, 228, .7);
}

.filters label {
  margin: 0;
}

.export-tips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.export-tips div {
  padding: 16px;
}

.export-tips strong,
.export-tips span {
  display: block;
}

.export-tips span {
  margin-top: 6px;
  color: var(--muted);
}

.help-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

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

.management-grid {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: 16px;
  align-items: start;
}

.manage-form {
  padding: 16px;
}

.manage-form h3,
.management-list h3 {
  margin: 0 0 10px;
}

.management-list {
  margin-top: 20px;
}

.compact-table table {
  min-width: 760px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 18px;
  background: rgba(255, 253, 248, .7);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

tbody tr:hover {
  background: rgba(40, 94, 139, .045);
}

.status {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  background: var(--danger-soft);
  color: #9a352f;
}

.status.disabled {
  background: #ececf0;
  color: var(--muted);
}

.link-button {
  margin: 0;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--blue);
}

.link-button:hover:not(:disabled) {
  background: rgba(40, 94, 139, .08);
  box-shadow: none;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  width: min(960px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  overflow: auto;
  border: 1px solid rgba(255, 253, 248, .72);
  border-radius: 24px;
  padding: 22px;
  background: rgba(255, 253, 248, .97);
  box-shadow: var(--shadow);
}

.small-modal {
  width: min(520px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head p {
  margin: 0 0 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.detail-grid div {
  min-height: 74px;
  border-radius: 18px;
  padding: 12px;
  background: #f8f5ee;
}

.detail-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid strong {
  font-weight: 700;
  word-break: break-word;
}

.detail-section {
  margin-top: 20px;
}

.detail-section h3,
.rectify h3 {
  margin: 0 0 10px;
}

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

.tag-list span,
.tag-list p {
  margin: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--field);
  color: var(--muted);
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.record-photo-card {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  background: #f8f5ee;
  color: var(--text);
  text-align: left;
}

.record-photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e6e0d6;
}

.record-photo-card span {
  display: block;
  overflow: hidden;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.photo-viewer-open {
  overflow: hidden;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
}

.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(18px);
}

.photo-viewer-panel {
  position: relative;
  z-index: 1;
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(88vw, 1080px);
  height: min(84vh, 760px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 20px;
  background: #101012;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .45);
  color: #fff;
}

.photo-viewer-panel header,
.photo-viewer-panel footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px 24px;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(20px);
}

.photo-viewer-panel header {
  position: static;
  z-index: auto;
  margin: 0;
  border-bottom: 0;
}

.photo-viewer-panel header strong,
.photo-viewer-panel header span {
  display: block;
}

.photo-viewer-panel header span,
.photo-viewer-panel footer {
  color: rgba(255, 255, 255, .7);
  font-size: 13px;
}

.photo-viewer-panel header button {
  margin: 0;
  border-color: rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.photo-viewer-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 20px 88px;
}

.photo-viewer-stage img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 8px;
  object-fit: contain;
  object-position: center;
}

.photo-viewer-nav {
  position: absolute;
  top: 50%;
  margin: 0;
  border-color: rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: rgba(0, 0, 0, .5);
  color: #fff;
  transform: translateY(-50%);
}

.photo-viewer-nav.previous {
  left: 24px;
}

.photo-viewer-nav.next {
  right: 24px;
}

.photo-viewer-nav:disabled {
  display: none;
}

.pagination {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 16px 4px 2px;
}

.pagination p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.pagination-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pagination-actions label {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.pagination-actions select {
  width: auto;
  min-width: 82px;
  padding: 8px 30px 8px 10px;
}

.pagination-actions button {
  min-width: 68px;
  padding: 9px 12px;
}

.pagination-actions span {
  min-width: 96px;
  color: var(--text);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

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

.toast {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: 540px;
  margin: auto;
  padding: 13px;
  border-radius: 16px;
  background: rgba(28, 28, 30, .92);
  color: #fff;
  text-align: center;
  backdrop-filter: blur(16px);
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .layout {
    padding: 16px;
  }

  header {
    margin: -16px -16px 18px;
    padding: 14px 16px;
  }

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

  .filters,
  .management-grid {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 760px) {
  header,
  .modal-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .section-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .header-actions button,
  .section-actions button {
    flex: 1;
  }

  .summary,
  .module-grid,
  .export-tips,
  .filters,
  .detail-grid,
  .management-grid {
    grid-template-columns: 1fr;
  }

  .compact {
    width: 100%;
  }

  .modal-panel {
    width: calc(100vw - 20px);
    margin: 10px auto;
    max-height: calc(100vh - 20px);
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-actions {
    flex-wrap: wrap;
  }

  .photo-viewer-panel {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .photo-viewer-stage {
    padding: 16px 60px;
  }

  .photo-viewer-nav.previous {
    left: 10px;
  }

  .photo-viewer-nav.next {
    right: 10px;
  }
}
