:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #222222;
  --muted: #747474;
  --line: #e7e1d8;
  --brand: #8a5a2b;
  --brand-dark: #68411f;
  --ok: #18794e;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(80, 55, 25, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, #f8f1e8 0%, var(--bg) 40%, #f7f7f7 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 16px 14px 72px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.userbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}

.login-wrap {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
  padding: 20px 14px;
}
.login-card {
  width: min(420px, 100%);
  padding: 24px;
}
.login-title { margin: 0 0 6px; font-size: 24px; }
.login-subtitle { margin: 0 0 20px; color: var(--muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid.one { grid-template-columns: 1fr; }
.form-section-title {
  grid-column: 1 / -1;
  margin: 12px 0 0;
  padding: 12px 0 4px;
  border-top: 1px dashed var(--line);
  font-weight: 800;
  color: var(--brand-dark);
}
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { color: #3d352d; font-size: 14px; font-weight: 650; }
.required::after { content: " *"; color: var(--danger); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(138,90,43,0.12); }
input:disabled, select:disabled, textarea:disabled {
  background: #f3f0ea;
  color: #68635d;
  -webkit-text-fill-color: #68635d;
}
textarea { min-height: 92px; resize: vertical; }

.checkbox-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #3d352d;
  font-weight: 500;
}
.check-pill input { width: auto; }
.check-pill.disabled { background: #f3f0ea; color: #68635d; }

.btn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: #ebe5dc;
  color: #2d2924;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: #fff0ee; color: var(--danger); }
.btn.success { background: #eaf7f0; color: var(--ok); }
.btn.small { min-height: 34px; padding: 7px 10px; border-radius: 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.searchbar {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}
.searchbar input { flex: 1; }

.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #faf7f2; color: #5b4635; white-space: nowrap; }
td { color: #2d2924; }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0e9df;
  color: #5b4635;
  font-size: 12px;
  font-weight: 800;
}
.badge.ok { background: #eaf7f0; color: var(--ok); }
.badge.warn { background: #fff6db; color: #8a6100; }
.badge.danger { background: #fff0ee; color: var(--danger); }

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

.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.record-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.record-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px;
}
.record-item h4 { margin: 0 0 6px; }
.record-item p { margin: 4px 0; color: #3d352d; }
.meta { color: var(--muted); font-size: 13px; }

.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: rgba(34, 34, 34, 0.92);
  color: #fff;
  padding: 11px 16px;
  border-radius: 999px;
  z-index: 100;
  max-width: calc(100vw - 30px);
  text-align: center;
  box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  .app-shell { padding: 10px 10px 72px; }
  .topbar { align-items: flex-start; }
  .brand h1 { font-size: 16px; max-width: 190px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .card { padding: 14px; border-radius: 16px; }
  .btn-row .btn, .searchbar .btn { flex: 1; }
  .searchbar { flex-direction: column; }
  .login-card { padding: 18px; }
}
