:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

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

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.top h1 {
  margin: 0 0 4px;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #9ca3af;
}
.status-dot.on { background: var(--ok); }
.status-dot.off { background: var(--danger); }
.status-dot.warn { background: var(--warn); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #f9fafb; }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.icon {
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 10px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.main #calendar {
  min-height: 640px;
}

/* FullCalendar tweaks */
.fc {
  --fc-border-color: var(--line);
  --fc-button-bg-color: #fff;
  --fc-button-border-color: var(--line);
  --fc-button-text-color: var(--text);
  --fc-button-hover-bg-color: #f9fafb;
  --fc-button-hover-border-color: #d1d5db;
  --fc-button-active-bg-color: #eff6ff;
  --fc-button-active-border-color: #bfdbfe;
  --fc-today-bg-color: #eff6ff;
  --fc-event-border-color: transparent;
  font-family: var(--font);
}
.fc .fc-toolbar-title { font-size: 1.15rem; }
.fc .fc-button {
  border-radius: 8px !important;
  box-shadow: none !important;
  text-transform: none;
  font-weight: 500;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
}
.fc-event {
  border-radius: 6px;
  border: none;
  padding: 1px 4px;
  font-size: 0.82rem;
  cursor: pointer;
}

/* 完成态：灰底 + 标题删除线（覆盖 FC 默认浅蓝色块） */
.fc-event.todo-done,
.fc-event.todo-done:hover {
  background-color: #9ca3af !important;
  border-color: #6b7280 !important;
  color: #f3f4f6 !important;
  opacity: 1;
  filter: none;
}
.fc-event.todo-done .fc-event-title,
.fc-event.todo-done .fc-event-time,
.fc-event.todo-done .fc-list-event-title,
.fc-list-event.todo-done .fc-list-event-title a,
.fc-list-event.todo-done .fc-list-event-title {
  text-decoration: line-through !important;
  color: #f3f4f6 !important;
}
.fc-daygrid-event.todo-done,
.fc-timegrid-event.todo-done {
  background-color: #9ca3af !important;
  border-color: #6b7280 !important;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  background: #fff;
  z-index: 50;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
}
.drawer[hidden], .backdrop[hidden] { display: none !important; }

.drawer-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-h h2 { margin: 0; font-size: 1.15rem; }

.drawer-b {
  padding: 16px 18px 24px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: #93c5fd;
}

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

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  user-select: none;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.drawer-actions .spacer { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.err { background: #991b1b; }
.toast[hidden] { display: none !important; }

@media (max-width: 720px) {
  .app { padding: 12px 10px 28px; }
  .top { flex-direction: column; }
  .main #calendar { min-height: 520px; }
  .fc .fc-toolbar {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
}
