* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  color: #222;
  background: #f5f6f8;
}

header {
  background: #2c3e50;
  color: #fff;
  padding: 10px 20px;
}

header h1 {
  margin: 0 0 8px;
  font-size: 20px;
}

nav button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #dfe6ee;
  padding: 6px 16px;
  margin-right: 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

nav button.active {
  background: #fff;
  color: #2c3e50;
  font-weight: bold;
}

main {
  padding: 16px 20px 40px;
  max-width: 1200px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

.panel {
  background: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar .spacer { flex: 1; }

button.btn {
  background: #2c6fbb;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 14px;
}

button.btn:hover { background: #245e9e; }
button.btn.secondary { background: #6b7a8d; }
button.btn.secondary:hover { background: #59687a; }
button.btn.danger { background: #c0392b; }
button.btn.danger:hover { background: #a93226; }
button.btn:disabled { background: #b9c0c7; cursor: not-allowed; }

button.link {
  background: none;
  border: none;
  color: #2c6fbb;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 13px;
}
button.link.danger { color: #c0392b; }

input[type="text"], input[type="number"], input[type="date"], select {
  border: 1px solid #c9d0d8;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  background: #fff;
}

input[type="number"] { width: 80px; text-align: right; }

table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
}

th, td {
  border: 1px solid #e1e4e8;
  padding: 6px 8px;
  text-align: center;
}

th { background: #eef1f5; font-weight: bold; }
td.left { text-align: left; }
th.left { text-align: left; }

tr.warn td { background: #fdecea; color: #b3261e; font-weight: bold; }
tr.warn td input { color: #b3261e; }

tr.flash td { animation: rowflash 0.9s ease-in-out 2; }
@keyframes rowflash {
  0%, 100% { background: #fff; }
  50% { background: #fff3bf; }
}

.scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scan-box {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  width: min(92vw, 480px);
  text-align: center;
}
.scan-box video, .scan-box img { max-width: 100%; border-radius: 4px; }
#scan-reader { min-height: 60px; margin: 8px 0; }

tr.total td { background: #fff8e1; font-weight: bold; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  background: #e8f0e9;
  color: #2e7d32;
}
.badge.closed { background: #e8f0e9; color: #2e7d32; }
.badge.open { background: #fff4e0; color: #e65100; }
.badge.inactive { background: #eee; color: #777; }

.muted { color: #888; font-size: 13px; }
.right { text-align: right; }

.empty-state {
  text-align: center;
  padding: 40px 0;
  color: #666;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.form-grid label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
}

.form-grid input, .form-grid select { width: 100%; }

.msg-ok { color: #2e7d32; }
.msg-err { color: #b3261e; }

.layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.layout .side {
  width: 240px;
  flex-shrink: 0;
}

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

.week-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.week-list li {
  padding: 8px 10px;
  border: 1px solid #e1e4e8;
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.week-list li:hover { background: #f0f4f8; }
.week-list li.selected { background: #dce9f7; border-color: #2c6fbb; }

footer {
  text-align: center;
  padding: 12px;
}

svg.chart { width: 100%; max-width: 720px; background: #fff; border: 1px solid #e1e4e8; border-radius: 6px; }
svg.chart text { font-size: 11px; fill: #555; }

h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 16px 0 8px; }

/* 服务器版：登录与用户 */
.login-overlay {
  position: fixed;
  inset: 0;
  background: #f5f6f8;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box { width: 320px; }
.login-label { display: block; font-size: 13px; color: #555; margin: 10px 0 4px; }
.login-box input { width: 100%; }

header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
header h1 { margin: 0; }
header nav { width: 100%; }
#user-box { color: #dfe6ee; font-size: 13px; margin-left: auto; }
#user-box .link { color: #ffd699; }

/* operator 角色隐藏管理入口（服务端仍强制拦截） */
body[data-role="operator"] .admin-only { display: none !important; }
