:root {
  color-scheme: light;
  --bg: #f7f2ea;
  --surface: #fffaf1;
  --ink: #22201d;
  --muted: #71685d;
  --line: #ded3c4;
  --accent: #21735a;
  --accent-strong: #175944;
  --warn: #b24b2d;
  --blue: #2b5c8a;
  --shadow: 0 16px 40px rgba(48, 37, 24, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  background:
    linear-gradient(145deg, rgba(33, 115, 90, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(43, 92, 138, 0.12), transparent 32%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.gate {
  min-height: calc(100vh - 48px);
  display: grid;
  align-content: center;
  gap: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: white;
  font-size: 34px;
  font-weight: 800;
  border-radius: 18px;
  background: var(--accent);
  box-shadow: var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.gate p,
.panel-title p,
.status-line,
.eyebrow {
  color: var(--muted);
}

.access-form,
.panel,
.summary-strip,
.history-lite,
.admin-stats,
.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.92);
  box-shadow: var(--shadow);
}

.access-form {
  display: grid;
  gap: 10px;
  padding: 16px;
}

label {
  font-weight: 700;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffdf8;
}

input,
select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

button {
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  cursor: pointer;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.access-row button,
.primary-action {
  min-height: 46px;
  padding: 0 18px;
  font-weight: 800;
}

.form-error,
.status-line.error,
.missing {
  color: var(--warn);
}

.screen {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-top: 6px;
}

.eyebrow {
  font-size: 13px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 26px;
  background: rgba(255, 250, 241, 0.9);
  border: 1px solid var(--line);
}

.summary-strip {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.summary-strip > div:first-child {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.summary-strip strong {
  font-size: 28px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7dccd;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 180ms ease;
}

.checkin-form {
  display: grid;
  gap: 14px;
}

.panel {
  display: grid;
  gap: 14px;
  padding: 15px;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.panel-title p {
  font-size: 13px;
  text-align: right;
}

.check-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  padding: 11px 0;
  border-top: 1px solid rgba(222, 211, 196, 0.75);
  font-weight: 600;
}

.check-row input {
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.stepper {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  gap: 10px;
  align-items: center;
}

.stepper button {
  height: 48px;
  font-size: 26px;
  font-weight: 800;
}

.stepper output {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  font-size: 22px;
  font-weight: 900;
}

input[type="range"] {
  accent-color: var(--accent);
}

.primary-action {
  width: 100%;
  min-height: 54px;
  background: var(--accent-strong);
}

.danger-action {
  min-height: 38px;
  padding: 0 12px;
  color: white;
  font-size: 14px;
  font-weight: 800;
  background: var(--warn);
}

.history-lite {
  display: grid;
  gap: 10px;
  padding: 15px;
}

.mini-record,
.record-card {
  display: grid;
  gap: 8px;
}

.mini-record {
  padding: 10px 0;
  border-top: 1px solid rgba(222, 211, 196, 0.8);
}

.detail-record summary {
  display: grid;
  gap: 4px;
  cursor: pointer;
  list-style: none;
}

.detail-record summary::-webkit-details-marker {
  display: none;
}

.detail-record summary::after {
  content: "查看详情";
  width: fit-content;
  margin-top: 2px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #d8eee3;
  font-size: 12px;
  font-weight: 800;
}

.detail-record[open] summary::after {
  content: "收起详情";
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
}

.admin-stats div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px 10px;
  background: rgba(255, 253, 248, 0.88);
}

.admin-stats span {
  color: var(--muted);
  font-size: 12px;
}

.admin-stats strong {
  font-size: 18px;
  line-height: 1.2;
}

.records-list {
  display: grid;
  gap: 12px;
}

.record-card {
  padding: 14px;
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  color: #2f2b25;
  background: #ece2d4;
  font-size: 12px;
  font-weight: 800;
}

.pill.done {
  color: #103d2f;
  background: #d8eee3;
}

.pill.warn {
  color: #713019;
  background: #f4d8cc;
}

.record-note {
  white-space: pre-wrap;
  color: var(--muted);
}

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

@media (min-width: 760px) {
  .app-shell {
    padding-top: 34px;
  }
}
