/* ---------- 页面头 ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--ink);
}

.page-head h1::before {
  content: "";
  width: 4px;
  height: 24px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--gold), var(--brand));
}

.page-sub {
  margin-top: 4px;
  font-size: 12px;
  letter-spacing: 0.6px;
  color: var(--muted);
}

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

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

.section-title h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--ink);
}

.section-title h2::before {
  content: "";
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--gold);
}

.section-title .section-note {
  font-size: 11.5px;
  color: var(--faint);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.4px;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  color: #fff6ea;
  background: linear-gradient(180deg, #8a3623, var(--brand));
  border-color: var(--brand-dark);
  box-shadow: 0 2px 6px rgba(122, 46, 29, 0.22);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #99402a, #8a3623);
}

.btn-gold {
  color: #4a3410;
  background: linear-gradient(180deg, #f3dfa4, var(--gold));
  border-color: #b08c1c;
  box-shadow: 0 2px 6px rgba(176, 140, 28, 0.2);
}

.btn-gold:hover {
  background: linear-gradient(180deg, #f8e8b6, #d4ae35);
}

.btn-ghost {
  color: var(--ink-2);
  background: #fffdf8;
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--gold);
  color: var(--brand);
}

.btn-subtle {
  color: var(--muted);
  background: transparent;
}

.btn-subtle:hover {
  color: var(--brand);
  background: var(--brand-soft);
}

.btn-danger {
  color: var(--warn);
  background: #fff;
  border-color: #e8c7c1;
}

.btn-danger:hover {
  background: var(--warn-soft);
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

.btn-xs {
  height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  border-radius: var(--r-xs);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--muted);
  background: transparent;
  transition: background 0.16s ease, color 0.16s ease;
}

.icon-btn:hover {
  color: var(--brand);
  background: var(--brand-soft);
}

/* ---------- 卡片 ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}

.card-pad {
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 1px;
}

.card-head .card-hint {
  font-size: 11.5px;
  color: var(--faint);
}

.card-body {
  padding: 18px 20px;
}

.card-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line-soft);
  background: #fdfbf5;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.card-accent::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.6;
}

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  line-height: 1;
  white-space: nowrap;
  background: var(--paper-deep);
  color: var(--ink-2);
}

.tag-brand {
  background: var(--brand-soft);
  color: var(--brand);
}

.tag-gold {
  background: var(--gold-soft);
  color: var(--gold-deep);
}

.tag-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.tag-info {
  background: var(--info-soft);
  color: var(--info);
}

.tag-violet {
  background: var(--violet-soft);
  color: var(--violet);
}

.tag-line {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tag-sm {
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
}

/* ---------- 统计块 ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-k {
  font-size: 11.5px;
  color: var(--muted);
}

.stat-v {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-v small {
  margin-left: 2px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.stat-d {
  font-size: 11.5px;
  color: var(--faint);
}

.delta-up {
  color: var(--ok);
}

.delta-down {
  color: var(--warn);
}

/* ---------- 进度 ---------- */
.bar {
  position: relative;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--paper-deep);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9c4429, var(--brand));
  transition: width 0.4s ease;
}

.bar-fill.is-gold {
  background: linear-gradient(90deg, #ddc069, var(--gold));
}

.bar-fill.is-ok {
  background: linear-gradient(90deg, #6a9c80, var(--ok));
}

.bar-sm {
  height: 5px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-row .bar {
  flex: 1;
}

.bar-row .bar-val {
  min-width: 44px;
  text-align: right;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 环形图 ---------- */
.ring-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ring-wrap svg {
  transform: rotate(-90deg);
}

.ring-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
}

.ring-value {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.ring-label {
  margin-top: 2px;
  font-size: 10px;
  color: var(--faint);
}

/* ---------- 表单 ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.field-label .req {
  color: var(--warn);
}

.field-hint {
  font-size: 11px;
  line-height: 1.5;
  color: var(--faint);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0 12px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fffdf9;
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  line-height: 1.6;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.16);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--faint);
}

.select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
}

.check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-box {
  position: relative;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: #fff;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.check input:checked + .check-box {
  background: var(--brand);
  border-color: var(--brand);
}

.check input:checked + .check-box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(40deg);
}

.check input:focus-visible + .check-box {
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.24);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper-warm);
}

.segmented button {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-xs);
  font-size: 12px;
  color: var(--muted);
  transition: background 0.16s ease, color 0.16s ease;
}

.segmented button.is-active {
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  box-shadow: var(--sh-1);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 21px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  width: 100%;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--line);
  transition: background 0.2s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-1);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--ok);
}

.switch input:checked + .switch-track::after {
  transform: translateX(17px);
}

/* ---------- 表格 ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fdfaf3;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table td input {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xs);
  background: #fff;
  width: 100%;
  outline: none;
}

.table td input:focus {
  border-color: var(--gold);
}

.table-scroll {
  overflow-x: auto;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(32, 18, 12, 0.45);
  backdrop-filter: blur(3px);
  animation: mask-in 0.18s ease;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  background: var(--card);
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  animation: modal-in 0.2s ease;
}

.modal.is-wide {
  max-width: 820px;
}

.modal.is-narrow {
  max-width: 420px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.modal-body {
  flex: 1;
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid var(--line-soft);
  background: #fdfbf5;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.modal-foot .foot-left {
  margin-right: auto;
  font-size: 11.5px;
  color: var(--faint);
}

@keyframes mask-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ---------- 提示 ---------- */
.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 340px;
  padding: 10px 15px;
  border: 1px solid rgba(201, 162, 39, 0.36);
  border-radius: var(--r-sm);
  background: rgba(43, 20, 20, 0.94);
  color: #f4e7cf;
  font-size: 12.5px;
  box-shadow: var(--sh-3);
  animation: toast-in 0.22s ease;
}

.toast.is-ok {
  border-color: rgba(120, 190, 150, 0.4);
}

.toast.is-warn {
  border-color: rgba(240, 140, 120, 0.5);
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.toast.is-ok .toast-dot {
  background: #8fd0a8;
}

.toast.is-warn .toast-dot {
  background: #f0a08c;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 空状态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 16px;
  text-align: center;
  color: var(--faint);
}

.empty svg {
  width: 34px;
  height: 34px;
  opacity: 0.6;
}

.empty p {
  font-size: 12.5px;
}

/* ---------- 分隔 ---------- */
.divider {
  height: 1px;
  margin: 14px 0;
  background: var(--line-soft);
}

.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 12.5px;
}

.kv:last-child {
  border-bottom: 0;
}

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

.kv dd {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- 引用与印章 ---------- */
.quote {
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 1.6px;
  color: var(--faint);
}

.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: var(--r-xs);
  font-family: var(--font-serif);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--brand);
  opacity: 0.85;
  transform: rotate(-4deg);
}

/* ---------- 列表 ---------- */
.row-list {
  display: flex;
  flex-direction: column;
}

.row-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line-soft);
}

.row-item:last-child {
  border-bottom: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-desc {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-side {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

/* ---------- 日历 ---------- */
.cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.cal-head {
  padding: 3px 0;
  text-align: center;
  font-size: 11px;
  color: var(--faint);
}

.cal-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: var(--r-xs);
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.cal-cell.is-blank {
  visibility: hidden;
}

.cal-cell.is-today {
  outline: 1px solid var(--brand);
  color: var(--brand);
  font-weight: 700;
}

.cal-cell.is-marked {
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-weight: 600;
}

.cal-cell.s1 { background: rgba(201, 162, 39, 0.16); }
.cal-cell.s2 { background: rgba(201, 162, 39, 0.32); }
.cal-cell.s3 { background: rgba(201, 162, 39, 0.5); }
.cal-cell.s4 { background: rgba(122, 46, 29, 0.72); color: #fff4e4; }

.cal-dot {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--warn);
  transform: translateX(-50%);
}

.cal-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 10.5px;
  color: var(--faint);
}

.cal-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 2px;
  background: var(--gold-soft);
  vertical-align: -1px;
}

/* ---------- 时间轴 ---------- */
.timeline {
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: linear-gradient(180deg, var(--gold), transparent);
}

.timeline-item {
  position: relative;
  padding-bottom: 14px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--brand);
}

.timeline-item.is-done::before {
  background: var(--gold);
  border-color: var(--gold);
}

.timeline-date {
  font-size: 10.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.timeline-text {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ---------- 抽屉 ---------- */
.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(32, 18, 12, 0.32);
  backdrop-filter: blur(1px);
  animation: mask-in 0.18s ease;
}

@media (max-width: 720px) {
  .modal-mask {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none;
    max-height: 88vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation: sheet-in 0.24s ease;
  }

  .modal-foot {
    border-radius: 0;
    padding-bottom: calc(13px + env(safe-area-inset-bottom));
  }

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

  .form-grid .span-2 {
    grid-column: span 1;
  }

  .toast-root {
    left: 14px;
    right: 14px;
    bottom: 72px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .page-head h1 {
    font-size: 23px;
  }

  @keyframes sheet-in {
    from { transform: translateY(30px); opacity: 0.6; }
    to { transform: none; opacity: 1; }
  }
}