:root {
  --blue: #2f6fbf;
  --blue-deep: #245a9c;
  --blue-soft: #eef3fa;
  --orange: #c9843a;
  --orange-soft: #f7f1e8;
  --ink: #3a404a;
  --sub: #8b929c;
  --line: #e5e9ef;
  --bg: #f5f6f8;
  --card: #fff;
  --r-card: 12px;
  --r-btn: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; }
.btn {
  border: none;
  border-radius: var(--r-btn);
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  background: var(--blue);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-line {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-orange { background: var(--orange); color: #fff; }
.link { background: none; border: none; color: var(--blue); font-size: 12px; font-family: inherit; cursor: pointer; }

.admin {
  display: grid;
  grid-template-columns: 188px 1fr;
  min-height: 100vh;
}
.side {
  background: #fafbfc;
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.side-brand img { height: 30px; }
.side-brand strong { display: block; font-size: 13px; }
.side-brand span { font-size: 11px; color: var(--sub); }
.side a {
  display: block;
  text-decoration: none;
  color: var(--sub);
  font-size: 13px;
  padding: 9px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
}
.side a.on {
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-weight: 500;
}
.side .logout {
  margin-top: 24px;
  font-size: 12px;
}
.main { padding: 22px 24px; background: #fff; }
.main-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.main-top h2 { font-size: 18px; font-weight: 600; }
.main-top p { font-size: 12px; color: var(--sub); margin-top: 4px; }
.ops { display: flex; gap: 8px; flex-wrap: wrap; }
.ops .btn { font-size: 12px; padding: 7px 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stat {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 14px 16px;
  background: #fff;
}
.stat .l { font-size: 12px; color: var(--sub); }
.stat .v {
  font-size: 26px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat .v.blue { color: var(--blue-deep); }
.stat .v.orange { color: var(--orange); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-weight: 500;
  color: var(--sub);
  font-size: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
td { padding: 12px 8px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }

.tag { font-size: 11px; padding: 2px 7px; border-radius: 4px; }
.tag-blue { background: var(--blue-soft); color: var(--blue-deep); }
.tag-orange { background: var(--orange-soft); color: var(--orange); }
.tag-muted { background: #eef0f3; color: var(--sub); }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--sub);
}
.pager-links { display: flex; gap: 8px; }
.deadline-preview {
  grid-column: 1 / -1;
  font-size: 12px;
  line-height: 1.55;
  color: var(--blue-deep);
  background: var(--blue-soft);
  padding: 8px 10px;
  border-radius: 6px;
}
.ops-cell { white-space: nowrap; }
.ops-cell .link { margin-right: 8px; }
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filters .fi { min-width: 120px; }
.filters .fi.grow { flex: 1; min-width: 160px; }
.filters label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.filters input, .filters select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  padding: 8px 10px;
  font-size: 13px;
}

.dot-on, .dot-off { display: inline-flex; align-items: center; gap: 6px; }
.dot-on::before, .dot-off::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
}
.dot-on { color: var(--blue); }
.dot-on::before { background: var(--blue); }
.dot-off { color: var(--sub); }
.dot-off::before { background: var(--sub); }

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  max-width: 520px;
}
.form.wide { max-width: none; }
.form.stack { grid-template-columns: 1fr; max-width: 360px; }
.flash-err { color: #c45c5c; font-size: 13px; margin-bottom: 14px; }
.flash-ok { color: #2f8a5a; font-size: 13px; margin-bottom: 14px; }
.form label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.form input, .form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
}
.form-actions { margin-top: 18px; display: flex; gap: 8px; }
.rule-blocks {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: none;
}
.rule-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.rule-block {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 18px 20px 20px;
  background: #fafbfc;
}
.rule-block.rule-in { border-left: 3px solid var(--blue); }
.rule-block.rule-out { border-left: 3px solid var(--orange); }
.rule-block h3 {
  font-size: 15px;
  font-weight: 600;
}
.rule-block .muted { margin: 6px 0 14px; }
.rule-block .form {
  max-width: none;
  gap: 14px 20px;
}
.rule-block .form.form-4 { grid-template-columns: repeat(4, 1fr); }
.rule-block .form label { margin-bottom: 6px; }
.rule-blocks + .form-actions { margin-top: 18px; }
.hint {
  background: var(--blue-soft);
  border-radius: var(--r-btn);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 14px;
  line-height: 1.6;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #fafbfc;
}
.filters .fi { display: flex; flex-direction: column; gap: 6px; min-width: 118px; }
.filters .fi.grow { flex: 1; min-width: 130px; }
.filters label { font-size: 12px; color: var(--sub); }
.filters input, .filters select {
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.filters input:not(.date-input):focus,
.filters select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 191, 0.12);
}
.fi-date-range {
  flex: 0 0 auto;
  min-width: 0;
}
.date-range-unified {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  height: 36px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.date-range-unified:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 191, 0.12);
}
.date-range-sep {
  font-size: 12px;
  color: var(--sub);
  flex-shrink: 0;
  user-select: none;
  padding: 0 6px;
  line-height: 1;
}
.date-range-unified .date-range-sep {
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0 8px;
  height: 20px;
  line-height: 20px;
}
.date-input-wrap {
  position: relative;
  display: block;
  flex: 1;
  min-width: 132px;
}
.date-range-unified .date-input-wrap {
  flex: 0 1 128px;
  min-width: 108px;
  width: 128px;
}
.date-input-wrap .date-input {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.date-range-unified .date-input-wrap .date-input {
  height: 34px;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
.date-range-unified .date-input-wrap:first-child .date-input {
  border-radius: var(--r-btn) 0 0 var(--r-btn);
}
.date-range-unified .date-input-wrap:last-child .date-input {
  border-radius: 0 var(--r-btn) var(--r-btn) 0;
}
.date-input-wrap .date-input:hover {
  border-color: #c5d0e0;
}
.date-range-unified .date-input-wrap .date-input:hover {
  border-color: transparent;
}
.date-input-wrap .date-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 191, 0.12);
}
.date-range-unified .date-input-wrap .date-input:focus {
  border-color: transparent;
  box-shadow: none;
}
.date-input-wrap .date-input::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 0;
  top: 0;
  width: 36px;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}
.date-input-wrap::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  pointer-events: none;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b929c' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='3' y='4.5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v3M16 3v3M3 10h18'/%3E%3C/svg%3E");
}
.batch-time-row .date-input-wrap { max-width: 200px; }
.switch {
  width: 40px; height: 22px;
  background: #d5dae2;
  border-radius: 11px;
  position: relative;
  display: inline-block;
  border: none;
  cursor: pointer;
  vertical-align: middle;
}
.switch.on { background: var(--blue); }
.switch::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
}
.switch.on::after { left: 21px; }
.logo-box {
  display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap;
  margin-bottom: 18px; padding: 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fafbfc;
}
.logo-preview {
  width: 96px; height: 96px; border: 1px dashed var(--line);
  border-radius: 12px; background: #fff; display: grid; place-items: center;
  overflow: hidden; flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.muted { font-size: 12px; color: var(--sub); line-height: 1.6; }
td select {
  min-width: 88px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
.entry-panel {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px;
  margin-bottom: 16px;
  background: #fafbfc;
}
.entry-panel.show { display: block; }
.entry-panel h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

body.batch-modal-open { overflow: hidden; }
.batch-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.batch-modal[hidden] { display: none; }
.batch-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.batch-modal-card {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px 18px;
  box-shadow: 0 16px 40px rgba(36, 90, 156, 0.12);
}
.batch-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.batch-modal-head h3 { font-size: 16px; font-weight: 600; }
.batch-modal-x {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--sub);
  cursor: pointer;
  padding: 4px 8px;
}
.batch-modal-card.batch-modal-sm {
  width: min(560px, 100%);
}
.batch-modal-body .form-actions {
  margin-top: 8px;
  padding-top: 4px;
}
.batch-time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 14px;
  align-items: flex-end;
}
.batch-meals .chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
  font-size: 13px;
  color: var(--text);
}
.batch-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}
.batch-col {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #fafbfc;
  padding: 12px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
}
.batch-col-head { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.batch-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.batch-filters select,
.batch-filters input[type=search] {
  flex: 1;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: var(--r-btn);
  padding: 7px 10px;
  font-size: 13px;
}
.btn-sm { padding: 7px 12px; font-size: 12px; }
.batch-list-tools { margin-bottom: 8px; display: flex; gap: 12px; }
.batch-user-list {
  flex: 1;
  overflow: auto;
  max-height: 320px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
}
.batch-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.batch-user-item:hover { background: var(--blue-soft); }
.batch-user-item.selected {
  justify-content: space-between;
  cursor: default;
}
.batch-user-item.selected:hover { background: #fff; }
.batch-empty { padding: 16px; text-align: center; font-size: 13px; }
.batch-hint { font-size: 12px; margin-bottom: 4px; }
.batch-actions { margin-top: 8px; }
@media (max-width: 768px) {
  .batch-picker { grid-template-columns: 1fr; }
}
.file-btn { position: relative; overflow: hidden; display: inline-block; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px 32px;
}
.login-card img { height: 40px; display: block; margin: 0 auto 16px; }
.login-card h1 { text-align: center; font-size: 18px; font-weight: 600; }
.login-card .sub { text-align: center; font-size: 12px; color: var(--sub); margin: 8px 0 24px; }
.login-card label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 14px;
  font-family: inherit;
}
.login-card .err { color: #c45c5c; font-size: 12px; margin-bottom: 12px; }
.login-card .hint { text-align: center; margin-top: 14px; background: none; padding: 0; }

.page-loading {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.page-loading[hidden] { display: none; }
.page-loading-card {
  width: 320px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: 0 10px 30px rgba(36, 90, 156, 0.08);
}
.page-loading-card strong { display: block; font-size: 15px; margin: 14px 0 6px; }
.page-loading-card p { font-size: 12px; color: var(--sub); line-height: 1.6; }
.page-loading-spin {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 3px solid var(--blue-soft);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: page-spin 0.8s linear infinite;
}
@keyframes page-spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: 0.7; cursor: wait; }
.guard-danger.is-countdown,
.guard-danger-link.is-countdown {
  opacity: 0.85;
  cursor: not-allowed;
  pointer-events: none;
}
.guard-danger.is-armed,
.guard-danger-link.is-armed {
  box-shadow: 0 0 0 2px rgba(196, 92, 92, 0.35);
}
.link.guard-danger.is-armed { color: #c45c5c; font-weight: 600; }

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 20px;
}
.admin-modal[hidden] { display: none; }
.admin-modal-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 22px 18px;
  box-shadow: 0 12px 40px rgba(36, 90, 156, 0.12);
}
.admin-modal-card strong { display: block; font-size: 16px; margin-bottom: 10px; }
.admin-modal-card p { font-size: 14px; color: var(--text); line-height: 1.65; margin: 0 0 18px; white-space: pre-wrap; }
.admin-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.admin-modal.is-error .admin-modal-card strong { color: #c45c5c; }
.admin-modal.is-ok .admin-modal-card strong { color: #2f8a5a; }
.flash-ok.flash-in-modal,
.flash-err.flash-in-modal { display: none; }

@media (max-width: 1100px) {
  .rule-row { grid-template-columns: 1fr; }
  .rule-block .form.form-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .side { display: none; }
  .stats, .stats.three, .form { grid-template-columns: 1fr 1fr; }
}
