:root {
  --primary: #2563EB;
  --primary-light: #3B82F6;
  --primary-lighter: #DBEAFE;
  --primary-dark: #1E40AF;
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --purple: #8B5CF6;
  --purple-light: #EDE9FE;
  --bg-main: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-hover: #F8FAFC;
  --border: #E2E8F0;
  --border-focus: #93C5FD;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
  background: var(--bg-main);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  background: var(--bg-card);
  min-height: 100vh;
  box-shadow: var(--shadow-lg);
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  color: white;
  padding: 28px 40px;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(37,99,235,0.3) 0%, transparent 70%);
  pointer-events: none;
}

header::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 30%;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(139,92,246,0.2) 0%, transparent 70%);
  pointer-events: none;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  z-index: 1;
}

.header-text h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #FFFFFF 0%, #93C5FD 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-text p {
  color: #94A3B8;
  font-size: 0.875rem;
  margin-top: 4px;
}

.header-stats {
  display: flex;
  gap: 20px;
  margin-left: auto;
}

.stat-badge {
  text-align: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 10px 18px;
  min-width: 80px;
}

.stat-badge .stat-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: #60A5FA;
  line-height: 1;
}

.stat-badge .stat-label {
  font-size: 0.7rem;
  color: #94A3B8;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Main ── */
main {
  padding: 32px 40px;
}

/* ── Controls ── */
.controls {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,0.45);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: #CBD5E1;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: var(--bg-card);
  color: var(--danger);
  border: 1.5px solid #FECACA;
}
.btn-danger:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  transform: translateY(-1px);
}

.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

.filter-select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lighter);
}

/* ── Task Form ── */
.task-form {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.25s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.task-form h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--border);
}

.form-group {
  margin-bottom: 20px;
}

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

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="date"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: var(--transition);
}
.form-group input[type="text"]:focus,
.form-group input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lighter);
}

.form-group input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  -webkit-appearance: none;
}
.form-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--primary-lighter);
  transition: var(--transition);
}
.form-group input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.form-group input[type="color"] {
  width: 56px; height: 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ── Task List ── */
.task-list { margin-bottom: 40px; }

.task-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.task-list-header h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}

.task-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 3px 10px;
  border-radius: 20px;
}

#tasks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
  cursor: default;
}
.task-item:hover {
  border-color: #CBD5E1;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.task-item.dragging {
  opacity: 0.45;
  border-style: dashed;
  transform: scale(0.98);
}
.task-item.drag-over {
  border-color: var(--primary);
  background: var(--primary-lighter);
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }

.task-info { flex: 1; min-width: 0; }

.task-name {
  font-weight: 500;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.task-color-indicator {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.8), 0 0 0 3px currentColor;
}

.task-dates {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  flex-shrink: 0;
}
.status-todo { background: #F1F5F9; color: #64748B; }
.status-in_progress { background: #DBEAFE; color: #1D4ED8; }
.status-done { background: #D1FAE5; color: #065F46; }

.task-progress {
  min-width: 100px;
  flex-shrink: 0;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--purple) 100%);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
}

.task-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-small {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: var(--transition);
}
.btn-edit:hover {
  background: var(--primary-lighter);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.btn-delete:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Gantt Container ── */
.gantt-container { margin-top: 40px; }

.gantt-container-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.gantt-container-header h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}

.gantt-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.gantt-controls label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.time-scale-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}
.time-scale-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-lighter);
}

.btn-icon {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: var(--transition);
}
.btn-icon:hover {
  background: var(--bg-hover);
  border-color: #CBD5E1;
  transform: translateY(-1px);
}

.gantt-chart {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  overflow-x: auto;
  min-height: 300px;
  box-shadow: var(--shadow-sm);
  --gantt-unit-width: 80px;
  --gantt-units: 1;
}

.gantt-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}
.gantt-empty-icon {
  font-size: 3rem;
  opacity: 0.4;
}

.gantt-grid { display: grid; gap: 12px; }

.gantt-header {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

.gantt-header-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.gantt-timeline-header {
  display: flex;
  min-width: calc(var(--gantt-units) * var(--gantt-unit-width));
}

.gantt-time-cell {
  flex: 1;
  min-width: var(--gantt-unit-width);
  padding: 4px 6px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-right: 1px solid #F1F5F9;
}
.gantt-time-cell:last-child { border-right: none; }

.gantt-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  margin-bottom: 8px;
  align-items: center;
}

.gantt-task-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-timeline-container {
  position: relative;
  height: 40px;
  background: #F8FAFC;
  border-radius: var(--radius-sm);
  min-width: calc(var(--gantt-units) * var(--gantt-unit-width));
}

.gantt-bar {
  position: absolute;
  height: 28px;
  top: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  min-width: 30px;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.gantt-bar:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.gantt-today-line {
  position: absolute;
  width: 2px;
  height: 100%;
  background: var(--danger);
  z-index: 10;
  opacity: 0.8;
}
.gantt-today-line::before {
  content: '今日';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: white;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: #1E293B;
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 240px;
  pointer-events: auto;
}
.toast.success { background: #065F46; border-left: 4px solid var(--success); }
.toast.error   { background: #7F1D1D; border-left: 4px solid var(--danger); }
.toast.info    { background: #1E3A5F; border-left: 4px solid var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
.toast.hiding {
  animation: toastOut 0.25s ease forwards;
}

/* ── Loading Spinner ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ── */
footer {
  padding: 20px 40px;
  border-top: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-main);
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  main { padding: 20px; }
  header { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .gantt-row { grid-template-columns: 1fr; }
  .gantt-header { grid-template-columns: 1fr; }
  .task-item { flex-wrap: wrap; }
  .header-stats { display: none; }
  .filter-bar { margin-left: 0; }
}
