:root {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand h1 { margin: 4px 0 0; font-size: 1.15rem; }
.badge-isolated {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.auth-box { display: flex; align-items: center; gap: 10px; }
.container { max-width: 1200px; margin: 20px auto; padding: 0 16px 40px; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 1.05rem; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar-right { display: flex; flex-wrap: wrap; gap: 8px; }
.field-group { display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.stats-card { display: flex; flex-direction: column; gap: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; }
.stat-label { font-size: 0.82rem; color: var(--muted); }
.stat-box strong { font-size: 1.15rem; }
.text-accent { color: #34d399; }
.text-warn { color: #fbbf24; }
.text-muted { color: var(--muted); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #052e16; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-sm { padding: 4px 8px; font-size: 0.76rem; }
.btn-danger { background: var(--danger); color: #fff; }

input, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.88rem;
}

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 12px; }
.subcard { background: var(--surface-2); padding: 14px; border-radius: 10px; border: 1px solid var(--border); }
.subcard h3 { margin: 0 0 10px; font-size: 0.95rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.row label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); flex: 1; min-width: 110px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pill-muted { color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.slot-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slot-card.slot-current {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5), 0 4px 14px rgba(59, 130, 246, 0.18);
}
.slot-card.slot-past {
  opacity: 0.48;
  filter: grayscale(0.55);
}
.slot-locked-note {
  font-size: 0.72rem;
  color: var(--muted);
}
.live-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  font-weight: 700;
  margin-left: 4px;
}
.warn-badge {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.field-hint { font-size: 0.76rem; color: var(--muted); line-height: 1.35; }
.field-hint.hint-locked { color: #60a5fa; font-weight: 600; }

.slot-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; }
.slot-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.status-tag { font-size: 0.72rem; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
.st-OPEN { background: rgba(148, 163, 184, 0.15); color: var(--muted); }
.st-PENDING { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.st-APPROVED { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.st-REJECTED { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.slot-body { font-size: 0.85rem; min-height: 22px; }
.slot-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.modal {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 400px;
  width: 92%;
}
.modal::backdrop { background: rgba(0, 0, 0, 0.65); }
.modal.modal-wide { max-width: 720px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; padding: 20px; }
.modal-body h3 { margin: 0; }
.modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.error-text { color: #f87171; font-size: 0.82rem; min-height: 18px; }

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.batch-left, .batch-right { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.batch-right button:disabled { opacity: 0.45; cursor: not-allowed; }
.slot-select { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; margin: 0; }
.slot-head-left { display: flex; align-items: center; gap: 6px; }

.audit-list {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.audit-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.audit-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 0.76rem; }
.audit-action { font-weight: 700; color: #60a5fa; }
.audit-detail { color: var(--text); word-break: break-word; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid var(--primary);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  z-index: 999;
}
