:root {
  --primary: #ff6b35;
  --primary-dark: #e85a24;
  --bg: #f5f6fa;
  --sidebar: #1f2430;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #888;
  --border: #e8eaf0;
  --danger: #ff3b30;
  --success: #19be6b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: #fff;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  padding: 24px 20px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar nav { padding: 12px 0; display: flex; flex-direction: column; }
.sidebar a {
  color: rgba(255,255,255,.72);
  padding: 12px 24px;
  display: block;
}
.sidebar a:hover, .sidebar a.on {
  background: rgba(255,107,53,.15);
  color: #fff;
}
.sidebar a.on { border-right: 3px solid var(--primary); }
.main { flex: 1; min-width: 0; }
.topbar {
  background: #fff;
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { margin: 0; font-size: 20px; }
.top-right { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.mp-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 4px;
}
.mp-switch label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.mp-switch select {
  min-width: 160px;
  max-width: 240px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}
.content { padding: 24px 28px 40px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card-stat {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,.03);
}
.card-stat .label { color: var(--muted); font-size: 13px; }
.card-stat .num { font-size: 28px; font-weight: 700; margin-top: 8px; color: var(--primary); }
.panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,.03);
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  background: var(--primary);
  color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-danger { background: var(--danger); }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #fafbfc; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  background: #fff3ee;
  color: var(--primary);
}
.tag.gray { background: #f0f0f0; color: #666; }
.tag.green { background: #e8f8ef; color: var(--success); }
.tag.blue { background: #e8f3ff; color: #2979ff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form {
  max-width: 720px;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
}
.form-row {
  margin-bottom: 16px;
}
.form-row label {
  display: block;
  margin-bottom: 6px;
  color: #555;
  font-size: 13px;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}
.form-row textarea {
  height: 120px;
  padding: 10px 12px;
  resize: vertical;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--primary);
}
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.alert {
  margin: 16px 28px 0;
  padding: 12px 16px;
  border-radius: 8px;
}
.alert.success { background: #e8f8ef; color: var(--success); }
.alert.error { background: #ffecec; color: var(--danger); }
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff7a45, #ff6b35);
}
.login-box {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.login-box h2 {
  margin: 0 0 8px;
  text-align: center;
}
.login-box p {
  margin: 0 0 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  padding: 6px 12px;
  border-radius: 16px;
  background: #f0f0f0;
  color: #666;
  font-size: 13px;
}
.tabs a.on { background: var(--primary); color: #fff; }
.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px 16px;
  margin-bottom: 24px;
}
.detail-grid .k { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px; }
.muted { color: var(--muted); font-size: 13px; }

/* 开关 */
.rotate-cell { display: flex; align-items: center; gap: 10px; }
.rotate-summary {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 360px;
}
.rotate-summary-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  padding: 6px 8px;
  background: #fff7f2;
  border: 1px solid #ffe0d0;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
}
.rotate-summary-item.is-off {
  background: #f5f5f5;
  border-color: #e8e8e8;
  opacity: .75;
}
.rotate-summary-time {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.rotate-summary-arrow { color: #bbb; }
.rotate-summary-name { font-weight: 600; color: #333; }
.rotate-summary-tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #ffd0ba;
  color: #c75a2e;
  font-size: 11px;
}
.rotate-summary-tag.off {
  border-color: #ddd;
  color: #888;
  background: #fafafa;
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  cursor: pointer;
  transition: .2s;
}
.slider:before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.btn-config:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask[hidden] { display: none !important; }
.modal {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: #999;
  cursor: pointer;
}
.modal-body { padding: 16px 20px 24px; }
.rule-list { display: flex; flex-direction: column; gap: 10px; }
.rule-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
}
.rule-time { font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.rule-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.rule-meta { font-size: 12px; color: #666; margin-top: 2px; word-break: break-all; }
.rule-form {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed #ffd0b8;
  border-radius: 12px;
  background: #fff8f4;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.form-row-full { grid-column: 1 / -1; }
.upload-box {
  border: 1px dashed #ffd0b8;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}
.upload-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.upload-preview img {
  max-width: 220px;
  max-height: 140px;
  border-radius: 8px;
  object-fit: contain;
  background: #f5f6fa;
  border: 1px solid var(--border);
}
.upload-preview-sm img {
  max-width: 72px;
  max-height: 72px;
}
.upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.upload-btn { cursor: pointer; margin: 0; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .rule-item { flex-direction: column; }
}

@media (max-width: 800px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
}
