:root {
  --teal: #0b6973;
  --teal-deep: #123f45;
  --ivory: #fff8ea;
  --wine: #a8212e;
  --gold: #9a8062;
  --ink: #2f3735;
  --muted: #786f65;
  --line: rgba(93, 75, 54, 0.18);
  --paper: #f6efdf;
}

* { box-sizing: border-box; }

html { background: var(--teal-deep); }

body {
  margin: 0;
  color: var(--ink);
  background: #eee7d8;
  font-family: "QZW HuiwenMincho", "Noto Serif SC", "Songti SC", STSong, serif;
}

button,
input,
select { font: inherit; }

button { cursor: pointer; }

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 38px 26px 28px;
  overflow: hidden;
  background: var(--teal-deep);
  color: var(--ivory);
}

.rail::after {
  content: "";
  position: absolute;
  right: -90px;
  bottom: 80px;
  width: 220px;
  height: 360px;
  border: 1px solid rgba(255, 248, 234, 0.12);
  border-radius: 50%;
  transform: rotate(22deg);
}

.brand {
  position: relative;
  z-index: 1;
  font-family: "Bodoni 72", Didot, "Times New Roman", serif;
  font-size: 18px;
  letter-spacing: 6px;
}

.brand-sub {
  display: block;
  margin-top: 12px;
  color: rgba(255, 248, 234, 0.58);
  font-size: 12px;
  letter-spacing: 2px;
}

.nav {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  margin-top: 70px;
}

.nav button {
  padding: 14px 15px;
  border: 1px solid transparent;
  border-radius: 3px 14px 3px 14px;
  color: rgba(255, 248, 234, 0.72);
  background: transparent;
  text-align: left;
}

.nav button[aria-current="page"] {
  border-color: rgba(255, 248, 234, 0.32);
  color: var(--ivory);
  background: rgba(255, 248, 234, 0.08);
}

.rail-user {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 248, 234, 0.16);
  font-size: 13px;
  line-height: 1.7;
}

.rail-user span { display: block; color: rgba(255, 248, 234, 0.54); }

.workspace { min-width: 0; padding: 42px clamp(30px, 5vw, 78px) 72px; }

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: radial-gradient(ellipse at 78% 15%, rgba(255, 248, 234, .12), transparent 36%), var(--teal-deep);
}
.login-card {
  width: min(100%, 480px);
  padding: clamp(28px, 6vw, 52px);
  border-radius: 4px 26px 4px 26px;
  background: var(--ivory);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .22);
}
.login-card h1 { margin: 14px 0 8px; color: var(--teal-deep); font-size: 38px; font-weight: 500; }
.login-card > p, .login-card > small { color: var(--muted); line-height: 1.8; }
.login-form { display: grid; gap: 17px; margin: 26px 0 16px; }
.login-form label { display: grid; gap: 8px; color: var(--teal-deep); font-size: 14px; }
.login-form .primary { width: 100%; margin-top: 4px; }
.login-form .primary:disabled { cursor: not-allowed; opacity: .48; }
.logout-action { display: block; margin-top: 10px; padding: 0; border: 0; color: rgba(255, 248, 234, .72); background: transparent; text-decoration: underline; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.page-head h1 {
  margin: 0;
  color: var(--teal-deep);
  font-family: "QZW LaoBaoSong", "Songti SC", STSong, serif;
  font-size: clamp(34px, 4vw, 56px);
  font-weight: 500;
  letter-spacing: -0.02em;
}

.page-head p { max-width: 560px; margin: 10px 0 0; color: var(--muted); line-height: 1.75; }

.eyeline {
  color: var(--wine);
  font-family: "Bodoni 72", Didot, serif;
  font-size: 12px;
  letter-spacing: 4px;
}

.badge {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 3px 10px 3px 10px;
  background: #dcece8;
  color: var(--teal);
  font-size: 12px;
}

.flow {
  display: grid;
  grid-template-columns: minmax(260px, .82fr) minmax(360px, 1.35fr);
  gap: 30px;
  margin-top: 36px;
}

.paper {
  position: relative;
  padding: 30px;
  border-radius: 4px 22px 4px 22px;
  background: var(--ivory);
  box-shadow: 0 20px 50px rgba(44, 54, 51, 0.09);
}

.paper h2 { margin: 0; color: var(--teal-deep); font-size: 23px; font-weight: 500; }
.paper p { color: var(--muted); line-height: 1.7; }

.lookup {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 24px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid #cfc2ad;
  border-radius: 3px 11px 3px 11px;
  outline: none;
  background: #fffdf7;
  color: var(--teal-deep);
}

input:focus,
select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11, 105, 115, 0.12); }

.primary,
.secondary,
.danger {
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 3px 13px 3px 13px;
}

.primary { color: var(--ivory); background: var(--wine); }
.secondary { border: 1px solid var(--teal); color: var(--teal); background: transparent; }
.danger { color: var(--wine); background: #f3dfe0; }
.primary:disabled { cursor: not-allowed; opacity: .44; }

.record-head,
.member-line,
.confirm-row,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.record-head { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.code { color: var(--gold); font-family: "Bodoni 72", Didot, serif; letter-spacing: 2px; }
.member-line { align-items: flex-start; padding: 22px 0; border-bottom: 1px solid var(--line); }
.member-line strong { display: block; color: var(--teal-deep); font-size: 25px; }
.member-line span { display: block; margin-top: 6px; color: var(--muted); }

.project-options { display: grid; gap: 10px; margin-top: 20px; }
.project-option { display: flex; align-items: center; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 3px 12px 3px 12px; }
.project-option input { width: auto; min-height: 0; accent-color: var(--wine); }
.confirm-row { margin-top: 24px; }
.notice { margin-top: 16px; padding: 12px 14px; color: var(--wine); background: #f3dfe0; }
.success { color: var(--teal); background: #dcece8; }

.toolbar { margin-top: 30px; }
.toolbar input { max-width: 420px; }
.member-search { justify-content: flex-start; }
.member-search span { margin-left: auto; white-space: nowrap; }

.table-wrap { margin-top: 18px; overflow: auto; background: var(--ivory); box-shadow: 0 18px 48px rgba(44, 54, 51, 0.08); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 16px 18px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--gold); font-size: 12px; font-weight: 500; letter-spacing: 1px; }
td { font-size: 14px; }
tbody tr:hover { background: #fbf4e6; }
.text-action { border: 0; color: var(--wine); background: transparent; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .65fr); gap: 26px; margin-top: 30px; }
.side-sheet { position: sticky; top: 32px; align-self: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 22px; }
.form-grid label { color: var(--muted); font-size: 12px; }
.form-grid label span { display: block; margin-bottom: 7px; }
.form-grid .full { grid-column: 1 / -1; }
.editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.editor-heading h2 { margin-top: 8px; }
.member-editor { max-height: calc(100vh - 64px); overflow: auto; }
.standalone-form-page { margin-top: 30px; }
.member-editor--standalone { width: min(100%, 880px); max-height: none; margin: 0; }
.checkbox-label { display: flex !important; align-items: center; gap: 10px; min-height: 44px; padding-top: 18px; }
.checkbox-label input { width: 18px; min-height: 18px; accent-color: var(--wine); }
.checkbox-label span { margin: 0 !important; }
.before-after { margin-top: 20px; padding: 14px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.7; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.tabs button { padding: 10px 14px; border: 1px solid var(--line); color: var(--muted); background: transparent; }
.tabs button[aria-selected="true"] { color: var(--ivory); background: var(--teal); }

.upload-zone { margin-top: 22px; padding: 38px 22px; border: 1px dashed #b9a88f; text-align: center; }
.conflict { margin-top: 16px; padding: 18px; border: 1px solid var(--line); }
.conflict-actions { display: flex; gap: 10px; margin-top: 14px; }

dialog { width: min(520px, calc(100% - 32px)); border: 0; border-radius: 4px 22px 4px 22px; background: var(--ivory); color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(18, 63, 69, .68); }
dialog h3 { color: var(--teal-deep); font-size: 25px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; padding: 24px; }
  .nav { display: flex; margin-top: 24px; overflow-x: auto; }
  .rail-user { display: none; }
  .workspace { padding: 30px 20px 56px; }
  .flow, .admin-grid { grid-template-columns: 1fr; }
  .side-sheet { position: static; }
}

@media (max-width: 560px) {
  .page-head, .toolbar, .record-head, .member-line, .confirm-row { align-items: stretch; flex-direction: column; }
  .lookup, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .friend-card__body { flex-direction: column; }
}
