:root {
  --paper: #fffdf8;
  --ink: #211b17;
  --muted: #756a60;
  --line: #d7c8b8;
  --red: #b51f2b;
  --red-deep: #8f1520;
  --gold: #b8893d;
  --green: #2f765a;
  --amber: #a9651a;
  --bg: #f4efe6;
  --panel: #fffaf1;
  --shadow: 0 18px 55px rgba(92, 66, 35, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(181, 31, 43, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(181, 31, 43, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 8% 0%, rgba(184, 137, 61, 0.2), transparent 28rem),
    radial-gradient(circle at 100% 18%, rgba(181, 31, 43, 0.12), transparent 24rem),
    var(--bg);
  background-size: 24px 24px, 24px 24px, auto, auto, auto;
  font-family: "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0 18px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-family: "FangSong", "STFangsong", serif;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-nav a,
.primary,
.ghost,
.link-button {
  min-height: 40px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  font-weight: 700;
}

.top-nav a {
  color: var(--muted);
  background: rgba(255, 250, 241, 0.76);
  border: 1px solid rgba(215, 200, 184, 0.9);
}

.top-nav a.active {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.primary {
  color: #fff;
  background: var(--red);
  box-shadow: 0 10px 24px rgba(181, 31, 43, 0.22);
}

.primary:hover {
  background: var(--red-deep);
}

.ghost {
  color: var(--red-deep);
  background: #fff;
  border: 1px solid var(--line);
}

.ghost.danger {
  color: #8a1a1a;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 38px;
}

.hero-band,
.panel,
.metric-card {
  border: 1px solid rgba(160, 122, 82, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.94);
  box-shadow: var(--shadow);
}

.hero-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 24px;
  margin-bottom: 16px;
}

.hero-band h2 {
  font-family: "FangSong", "STFangsong", serif;
  font-size: clamp(24px, 2.7vw, 34px);
}

.hero-copy {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.quick-actions,
.panel-actions,
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid.compact {
  grid-template-columns: repeat(3, minmax(130px, 1fr));
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--red-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(620px, 1fr);
  gap: 18px;
  align-items: start;
}

.workspace.single {
  grid-template-columns: 1fr;
}

.panel {
  padding: 18px;
}

.editor-panel,
.export-panel {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
}

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

.panel-head.stacked {
  display: block;
}

[data-save-state] {
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(181, 31, 43, 0.1);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.row-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 20px 0 10px;
}

.row-title button,
.mini-btn {
  min-height: 34px;
  border-radius: 5px;
  padding: 0 11px;
  color: var(--red-deep);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}

.topic-list,
.member-list {
  display: grid;
  gap: 9px;
}

.topic-item,
.member-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.topic-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 9px;
}

.remove-btn {
  width: 34px;
  height: 34px;
  border-radius: 5px;
  color: var(--muted);
  background: #f8f1e7;
}

.remove-btn:hover {
  color: #fff;
  background: var(--red);
}

.member-delete-btn {
  min-width: 58px;
  min-height: 40px;
  border-radius: 6px;
  color: #fff;
  background: var(--red);
  font-weight: 700;
}

.member-delete-btn:hover {
  background: var(--red-deep);
}

.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px auto auto;
  gap: 8px;
  margin-bottom: 10px;
}

.insert-index {
  text-align: center;
}

[data-member-search] {
  margin-bottom: 10px;
}

.member-card {
  padding: 10px;
}

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

.status-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 9px 0;
}

.status-btn {
  min-height: 31px;
  border-radius: 5px;
  color: var(--muted);
  background: #f8f1e7;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
}

.status-btn.active[data-status="signed"] {
  color: #fff;
  background: var(--green);
}

.status-btn.active[data-status="leave"] {
  color: #fff;
  background: var(--amber);
}

.status-btn.active[data-status="pending"] {
  color: var(--red-deep);
  background: #fff5f3;
  border-color: rgba(181, 31, 43, 0.25);
}

.leave-row {
  display: grid;
  grid-template-columns: 94px 1fr;
  gap: 8px;
}

.signature-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 9px 0;
}

.signature-toolbar .ghost {
  min-height: 34px;
  padding: 0 10px;
}

.signature-thumb {
  display: grid;
  place-items: center;
  min-height: 58px;
  margin-bottom: 9px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fffdf9;
  color: var(--muted);
  font-size: 13px;
}

.signature-thumb img {
  max-width: 100%;
  max-height: 54px;
  object-fit: contain;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.check-list p {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-list strong {
  min-width: 44px;
  color: var(--red-deep);
  font-size: 28px;
}

.check-list span,
.note {
  color: var(--muted);
}

.note {
  margin: 14px 0 0;
  line-height: 1.65;
  font-size: 13px;
}

.export-actions {
  display: grid;
}

.paper-wrap {
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(148, 90, 31, 0.12), rgba(181, 31, 43, 0.08));
}

.paper {
  width: 900px;
  min-height: 1160px;
  margin: 0 auto;
  padding: 52px 58px 46px;
  background: var(--paper);
  color: #000;
  box-shadow: 0 18px 42px rgba(60, 43, 24, 0.2);
}

.sheet-title {
  margin-bottom: 18px;
  text-align: center;
  font-family: "SimSun", "FangSong", serif;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.35;
}

.title-blank {
  display: inline-block;
  min-width: auto;
  margin: 0;
  padding: 0;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: "FangSong", "STFangsong", serif;
  font-size: 18px;
}

.sheet-table th,
.sheet-table td {
  height: 42px;
  border: 1.5px solid #000;
  padding: 7px 9px;
  text-align: center;
  vertical-align: middle;
  word-break: break-word;
}

.sheet-table .label {
  width: 88px;
  font-weight: 700;
}

.sheet-table .topic {
  text-align: center;
  line-height: 1.55;
  font-weight: 700;
}

.sheet-table .section {
  height: 48px;
  font-weight: 700;
  font-size: 19px;
}

.signature-sheet th,
.signature-sheet td {
  height: 50px;
}

.index-cell {
  width: 7%;
}

.person-cell {
  width: 15%;
}

.signature-cell {
  width: 31%;
}

.leave-cell {
  width: 15%;
}

.reason-cell {
  width: 32%;
}

.signature-image {
  display: block;
  max-width: 180px;
  max-height: 46px;
  margin: 0 auto;
  object-fit: contain;
}

.summary-row td {
  text-align: left;
  line-height: 1.5;
  font-size: 15px;
}

.signature-dialog[hidden] {
  display: none;
}

.signature-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.signature-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 18, 12, 0.42);
}

.signature-box {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 24px));
  border: 1px solid rgba(160, 122, 82, 0.38);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(24, 18, 12, 0.28);
  padding: 18px;
}

.signature-canvas {
  width: 100%;
  height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

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

@media (max-width: 1080px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-nav {
    justify-content: flex-start;
  }

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

  .editor-panel,
  .export-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 680px) {
  .site-header,
  .app-shell {
    width: min(100vw - 18px, 1480px);
  }

  .site-header {
    padding-top: 14px;
  }

  .top-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

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

  .quick-actions,
  .quick-actions a,
  .panel-actions,
  .panel-actions button {
    width: 100%;
  }

  .summary-grid,
  .summary-grid.compact {
    grid-template-columns: 1fr 1fr;
  }

  .two-col,
  .leave-row,
  .add-row {
    grid-template-columns: 1fr;
  }

  .paper-wrap {
    padding: 8px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .hero-band,
  .summary-grid,
  .editor-panel,
  .export-panel,
  .preview-panel > .panel-head {
    display: none;
  }

  .app-shell,
  .workspace,
  .preview-panel,
  .paper-wrap {
    display: block;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .paper {
    width: auto;
    min-height: auto;
    padding: 18mm 14mm;
    box-shadow: none;
  }
}
