:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --ink: #202124;
  --muted: #6d6f76;
  --line: #dedbd2;
  --line-strong: #c9c5ba;
  --green: #1d7f5f;
  --green-strong: #126349;
  --green-soft: #e5f4ee;
  --coral: #d95d39;
  --gold: #b98221;
  --blue: #326ebd;
  --danger: #b23636;
  --shadow: 0 10px 30px rgba(32, 33, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 245, 239, 0.94)),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.page {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(18px, env(safe-area-inset-left)) 12px max(18px, env(safe-area-inset-left));
  background: rgba(247, 245, 239, 0.9);
  border-bottom: 1px solid rgba(222, 219, 210, 0.8);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--green);
  border-radius: 8px;
  font-weight: 800;
}

.brand h1,
.project-heading h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.brand p,
.project-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 390px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 18px 44px;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: start center;
  padding: 48px 18px;
}

.login-panel {
  width: min(420px, 100%);
}

.stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 17px;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.panel-body {
  padding: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.hint-box {
  display: grid;
  gap: 6px;
  padding: 11px 12px;
  color: var(--muted);
  background: #f4efe4;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.hint-box b {
  color: var(--ink);
}

.hint-box p {
  margin: 0;
}

.hint-box a {
  color: var(--green-strong);
  font-weight: 700;
}

.hint-box.danger {
  color: var(--danger);
  background: rgba(178, 54, 54, 0.08);
  border-color: rgba(178, 54, 54, 0.25);
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.text-input,
.textarea,
.file-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
}

.text-input,
.file-input {
  min-height: 44px;
  padding: 10px 12px;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.5;
}

.text-input:focus,
.textarea:focus,
.file-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29, 127, 95, 0.14);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.button:hover {
  border-color: var(--green);
}

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

.button.primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.button.primary:hover {
  background: var(--green-strong);
}

.button.danger {
  color: var(--danger);
  border-color: rgba(178, 54, 54, 0.32);
}

.button.small {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
}

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

.project-list {
  display: grid;
  gap: 10px;
}

.project-row {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.project-row.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.row-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.metric {
  min-width: 0;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric b {
  display: block;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.metric span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
}

.claim-page {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 0 92px;
}

.claim-hero {
  padding: 20px 18px 14px;
}

.project-heading {
  display: grid;
  gap: 12px;
}

.language-switch {
  justify-self: end;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(54px, 1fr));
  gap: 4px;
  padding: 4px;
  background: #e8e2d6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.language-switch button {
  min-height: 30px;
  padding: 5px 8px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
}

.language-switch button.active {
  color: #fff;
  background: var(--green);
}

.progress {
  height: 9px;
  overflow: hidden;
  background: #e8e2d6;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  border-radius: inherit;
  transition: width 0.25s ease;
}

.mobile-section {
  margin: 12px 12px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mobile-section-header {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.mobile-section-header h2 {
  margin: 0;
  font-size: 16px;
}

.mobile-section-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.mobile-section-body {
  padding: 14px;
}

.name-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
}

.chip.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

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

.tab {
  min-height: 38px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  cursor: pointer;
}

.tab.active {
  color: var(--green-strong);
  background: var(--green-soft);
  border-color: rgba(29, 127, 95, 0.34);
  font-weight: 700;
}

.item-list {
  display: grid;
  gap: 9px;
}

.claim-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.claim-item.mine {
  border-color: rgba(29, 127, 95, 0.46);
  background: var(--green-soft);
}

.claim-item.locked {
  cursor: not-allowed;
  opacity: 0.72;
}

.claim-item input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.item-main {
  min-width: 0;
}

.item-name {
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.item-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.item-price {
  color: var(--green-strong);
  font-weight: 800;
  white-space: nowrap;
}

.item-actions {
  grid-column: 2 / -1;
  display: flex;
  justify-content: flex-end;
}

.item-action-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #efe9dc;
  color: var(--muted);
  font-size: 12px;
}

.badge.mine {
  color: var(--green-strong);
  background: rgba(29, 127, 95, 0.13);
}

.badge.shared {
  color: var(--blue);
  background: rgba(50, 110, 189, 0.12);
}

.split-names {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-person,
.unclaimed-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

.summary-person summary,
.unclaimed-box summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  font-weight: 800;
}

.summary-person summary::-webkit-details-marker,
.unclaimed-box summary::-webkit-details-marker {
  display: none;
}

.summary-items {
  display: grid;
  gap: 1px;
  padding: 0 12px 12px;
}

.summary-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.summary-line span:first-child {
  overflow-wrap: anywhere;
}

.summary-line small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.items-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

.items-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.items-table td {
  font-size: 14px;
}

.items-table .right {
  text-align: right;
}

.sticky-save {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: min(780px, 100%);
  padding: 12px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.save-total {
  min-width: 0;
  font-weight: 800;
}

.save-total span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 14px;
  color: #fff;
  background: rgba(32, 33, 36, 0.92);
  border-radius: 8px;
  transform: translateX(-50%);
  box-shadow: var(--shadow);
}

.toast.error {
  background: rgba(178, 54, 54, 0.94);
}

.loading {
  min-height: 50vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 33, 36, 0.36);
}

.split-modal {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
}

.split-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.split-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.split-choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.split-choice span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.small-textarea {
  min-height: 70px;
}

.empty.compact {
  padding: 12px;
}

@media (max-width: 860px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar .actions {
    justify-content: flex-end;
  }

  .brand h1,
  .project-heading h1 {
    font-size: 18px;
  }

  .claim-item {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .item-price {
    grid-column: 2;
  }

  .sticky-save {
    grid-template-columns: 1fr;
  }

  .sticky-save .button {
    width: 100%;
  }
}
