:root {
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-soft: #eef2ff;
  --bg: #f4f5fb;
  --card: #ffffff;
  --border: #e7e9f2;
  --text: #1f2430;
  --muted: #8a90a6;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ============ 登录（像素游戏风） ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0d0d1a;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.pixel-stars {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 18%, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(2px 2px at 28% 62%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(2px 2px at 45% 25%, rgba(255,215,0,.85), transparent 60%),
    radial-gradient(2px 2px at 63% 70%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(2px 2px at 78% 30%, rgba(78,205,196,.85), transparent 60%),
    radial-gradient(2px 2px at 88% 55%, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(2px 2px at 35% 82%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(2px 2px at 70% 12%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(2px 2px at 8% 70%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(2px 2px at 55% 45%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(2px 2px at 20% 88%, rgba(255,107,107,.6), transparent 60%),
    radial-gradient(2px 2px at 92% 82%, rgba(255,255,255,.6), transparent 60%);
}
.pixel-scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0, transparent 3px,
    rgba(0,0,0,.16) 3px, rgba(0,0,0,.16) 4px
  );
}
.pixel-card {
  width: 100%;
  max-width: 380px;
  background: #16162e;
  border: 4px solid #3a3a6c;
  border-radius: 0;
  box-shadow:
    0 0 0 4px #0d0d1a,
    0 0 0 8px #4a4a8c,
    0 12px 0 8px rgba(0,0,0,.5),
    0 24px 70px rgba(0,0,0,.65);
  padding: 30px 30px 24px;
  position: relative;
  z-index: 2;
}
.pixel-art {
  display: block;
  margin: 0 auto;
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
}
.pixel-title {
  font-size: 30px;
  font-weight: 900;
  text-align: center;
  color: #ffd700;
  letter-spacing: 3px;
  margin: 10px 0 4px;
  text-shadow:
    2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000,
    2px 2px 0 #000, -2px 2px 0 #000, 2px -2px 0 #000, -2px -2px 0 #000,
    4px 4px 0 #8a6d00;
}
.pixel-sub {
  text-align: center;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: #4ecdc4;
  letter-spacing: 3px;
  margin: 0 0 6px;
}
.pixel-press {
  text-align: center;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 2px;
  margin: 12px 0 18px;
  animation: pixel-blink 1.1s steps(1) infinite;
}
@keyframes pixel-blink { 50% { opacity: 0; } }
.pixel-field { display: block; margin-bottom: 16px; }
.pixel-field > span {
  display: block;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  color: #8a8ab0;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.pixel-field input {
  width: 100%;
  padding: 12px;
  background: #0d0d1a;
  border: 3px solid #4a4a8c;
  border-radius: 0;
  box-shadow: 0 4px 0 #000;
  color: #e0e0ff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 15px;
  outline: none;
  transition: none;
  caret-color: #39ff14;
}
.pixel-field input::placeholder { color: #5a5a8a; }
.pixel-field input:focus {
  border-color: #ffd700;
  box-shadow: 0 4px 0 #000, 0 0 0 3px rgba(255,215,0,.22);
}
.pixel-btn {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  background: #ffd700;
  color: #16162e;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 3px;
  border: 3px solid #fff;
  border-radius: 0;
  box-shadow: 0 6px 0 #8a6d00, 0 10px 0 rgba(0,0,0,.4);
  cursor: pointer;
  transition: none;
}
.pixel-btn:hover { background: #ffe14d; }
.pixel-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #8a6d00, 0 6px 0 rgba(0,0,0,.4);
}
.pixel-btn:disabled {
  background: #6a6a8a;
  color: #aaa;
  border-color: #555;
  box-shadow: 0 3px 0 #3a3a5c;
  cursor: default;
}
.pixel-error {
  color: #ff6b6b;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  min-height: 18px;
  margin: 14px 0 0;
  text-align: center;
}
.pixel-foot {
  text-align: center;
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  color: #5a5a8a;
  letter-spacing: 1px;
  margin-top: 16px;
}

/* ============ 布局 ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: #1e1b2e;
  color: #cfd2e3;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; }
.brand-logo { font-size: 26px; }
.brand-name { color: #fff; font-weight: 600; font-size: 16px; }
.brand-sub { color: #7a7f99; font-size: 12px; margin-top: 2px; }
.nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border: none; background: transparent;
  color: #b7bad0; font-size: 14px; cursor: pointer; border-radius: 10px;
  transition: .15s; text-align: left; width: 100%;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.35);
}
.nav-item.logout { color: #7a7f99; }
.nav-item.logout:hover { color: #ffd6d6; background: rgba(220,38,38,.12); }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: #fff; border-bottom: 1px solid var(--border);
}
.topbar h2 { margin: 0; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px;
}
.badge-mock {
  background: var(--amber-soft); color: var(--amber); font-size: 12px;
  padding: 4px 10px; border-radius: 999px; font-weight: 500;
}

.content { padding: 24px 28px; overflow: auto; }
.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============ 卡片 / 面板 ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat-card .sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.stat-card.accent { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: none; }
.stat-card.accent .label, .stat-card.accent .sub { color: rgba(255,255,255,.8); }

.panel {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-actions { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kv-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; }

.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.on { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-dot.off { background: var(--muted); }

.day-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.day-box { background: var(--bg); border-radius: 12px; padding: 16px; }
.day-box h4 { margin: 0 0 12px; font-size: 14px; }
.day-box .meals { display: flex; gap: 10px; flex-wrap: wrap; }
.meal-pill { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.meal-pill b { font-size: 18px; margin-right: 4px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 12px 14px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12px;
  text-transform: uppercase; letter-spacing: .3px;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:hover { background: var(--primary-soft); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.yes { background: var(--green-soft); color: var(--green); }
.badge.no { background: #eef0f5; color: #a0a6bd; }
.badge.admin { background: var(--primary-soft); color: var(--primary); }
.badge.role { background: #f1f2f7; color: var(--muted); }
.badge.off { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.log-info { background: var(--primary-soft); color: var(--primary); }
.badge.log-warn { background: var(--amber-soft); color: var(--amber); }
.badge.log-error { background: var(--red-soft); color: var(--red); }

/* ============ 表单 ============ */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; background: #fff; color: var(--text); outline: none; transition: .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; font-family: inherit; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.check-item { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.form-inline { display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px; align-items: end; }
.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch-row > span { margin: 0; color: var(--text); }
.switch { position: relative; width: 44px; height: 24px; display: inline-block; flex-shrink: 0; }
.switch input { display: none; }
.switch i {
  position: absolute; inset: 0; background: #d6d9e6; border-radius: 999px; transition: .2s; cursor: pointer;
}
.switch i::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(20px); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 4px 0 0; }

/* ============ 按钮 / 工具条 ============ */
.btn {
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; transition: .15s; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-title { margin: 0; font-size: 15px; }
.spacer { flex: 1; }
.quick-dates { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-dates .btn { padding: 8px 14px; }
.quick-dates .btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.date-input { width: 160px; }
.search-input { width: 260px; }
.summary-strip {
  display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 16px;
  background: var(--bg); border-radius: 12px; margin-bottom: 16px; font-size: 13px;
}
.summary-strip b { font-size: 17px; margin-left: 4px; }
.actions-bar { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; }

/* ============ 分享图上传 ============ */
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
@media (max-width: 768px) { .share-grid { grid-template-columns: 1fr; } }
.share-preview {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.share-preview img {
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
  display: none;
  margin: 0 auto 8px;
  box-shadow: 0 2px 8px rgba(20, 24, 40, 0.1);
}
.share-preview .muted { margin-top: 4px; }

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0; background: rgba(20,20,40,.45); display: grid; place-items: center;
  z-index: 50; padding: 20px;
}
.modal-card { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }

/* ============ Toast ============ */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 14px;
  z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: fade .2s ease;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

/* 表格里的操作按钮 */
.link-btn { border: none; background: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 2px 6px; }
.link-btn.danger { color: var(--red); }

/* ============ 手机端适配 ============ */
.menu-toggle {
  display: none;
  border: none;
  background: #f0f1f7;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
  .menu-toggle { display: inline-block; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .topbar h2 { font-size: 16px; }
  .topbar-right { gap: 6px; }
  #admin-name { display: none; }
  .content { padding: 16px; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .sidebar-overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 16, 30, 0.45);
    z-index: 55;
  }

  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .value { font-size: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kv-list { grid-template-columns: 1fr; }
  .day-overview { grid-template-columns: 1fr; gap: 12px; }
  .form-inline { grid-template-columns: 1fr; gap: 10px; }

  .toolbar { gap: 8px; }
  .search-input { width: 100%; }
  .date-input { width: 100%; }
  .quick-dates { width: 100%; }
  .quick-dates .btn { flex: 1; }

  .panel { padding: 14px; }
  .table th, .table td { padding: 10px 8px; font-size: 12px; white-space: nowrap; }
  .summary-strip { gap: 12px; flex-wrap: wrap; }

  .modal-card { max-width: 100%; }
  .pixel-card { padding: 22px 18px; }
}
