:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1f6feb;
  --primary-dark: #1858bd;
  --danger: #c0392b;
  --open: #0f7b4f;
  --closed: #b45309;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 20px;
  background: #12263f;
  color: #fff;
}

.brand {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  font-size: 17px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}

.nav a { color: #d7e3f4; text-decoration: none; }
.nav a:hover { color: #fff; }
.who { color: #9fb3c8; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

.card.narrow, .login-card { max-width: 460px; margin-left: auto; margin-right: auto; }

h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 17px; margin: 20px 0 8px; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.muted { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.hint { color: var(--danger); font-size: 13px; margin-top: 4px; }

.flash {
  background: #e8f4ec;
  color: #14532d;
  border: 1px solid #b7e0c6;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

.flash.error {
  background: #fdecea;
  color: #7f1d1d;
  border-color: #f3c3bd;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  vertical-align: middle;
}

.badge.open { background: #e3f4ea; color: var(--open); }
.badge.closed { background: #fdf1dd; color: var(--closed); }

.button {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.button:hover { border-color: #c8ced6; }

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

.button.primary:hover, button.primary:hover { background: var(--primary-dark); }

button.primary {
  padding: 9px 20px;
  border-radius: 7px;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid var(--primary);
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: #d7e3f4;
  cursor: pointer;
  font-size: 14px;
}

.link-button:hover { color: #fff; }
.link-button.danger { color: var(--danger); }
.link-button.danger:hover { text-decoration: underline; }

.inline-form { display: inline; }

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

.field { display: grid; gap: 6px; }
.field > span, .field legend { font-size: 14px; font-weight: 600; }

.field input[type="text"],
.field input[type="tel"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  font: inherit;
  background: #fff;
}

.field textarea { resize: vertical; }

.radio-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.radio-group legend { padding: 0 4px; }
.radio-group label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 10px;
}

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

th { background: #f9fafb; font-weight: 600; white-space: nowrap; }
.row-actions { white-space: nowrap; }
.row-actions a { margin-right: 8px; }

.history-group { border-top: 1px solid var(--line); padding-top: 8px; }

.hidden { display: none; }

/* --- 管理端 --- */

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.admin-nav a {
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.admin-nav a:hover { border-color: var(--primary); color: var(--primary); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfd;
}

.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-label a { color: var(--primary); }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.filter-form input[type="text"],
.filter-form input[type="number"],
.filter-form select {
  padding: 7px 9px;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  font: inherit;
  background: #fff;
}

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inline-details { display: inline-block; margin-left: 6px; }
.inline-details[open] { display: block; margin-top: 8px; }
.inline-details summary { cursor: pointer; color: var(--primary); font-size: 14px; }

.row-deleted { opacity: 0.55; }
.log-json { max-width: 260px; font-size: 12px; color: var(--muted); word-break: break-all; }

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .page { padding: 14px 12px 40px; }
  .card { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .nav { gap: 10px; font-size: 13px; }
}
