:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1a1d26;
  --text-secondary: #667085;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, 0.1);
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
}

.brand p {
  font-size: 13px;
  color: var(--text-secondary);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 4px 8px;
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-edit {
  background: transparent;
  color: var(--primary);
  border: none;
  padding: 4px 8px;
}

.btn-edit:hover {
  background: var(--primary-light);
}

.import-label {
  cursor: pointer;
}

/* Tabs */
.tabs {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px 0;
  display: flex;
  gap: 4px;
}

.tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.tab.active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Main */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.panel {
  display: none;
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel.active {
  display: block;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
}

.search-box input,
.filters select {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

.search-box input:focus,
.filters select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

.filters select {
  width: auto;
  min-width: 120px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: #f9fafb;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f9fafb;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.task-name-cell {
  max-width: 220px;
}

.task-name-cell .name {
  font-weight: 500;
  display: block;
}

.task-name-cell .desc {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-pending { background: #f3f4f6; color: #4b5563; }
.badge-progress { background: #dbeafe; color: #1d4ed8; }
.badge-done { background: #dcfce7; color: #15803d; }
.badge-paused { background: #fef3c7; color: #b45309; }

.badge-high { background: #fee2e2; color: #b91c1c; }
.badge-medium { background: #fef3c7; color: #b45309; }
.badge-low { background: #f0fdf4; color: #15803d; }

/* Progress bar */
.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}

.progress-bar.large {
  height: 16px;
  border-radius: 8px;
  flex: 1;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.progress-cell .progress-bar {
  flex: 1;
}

.progress-cell span {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 36px;
}

.overdue {
  color: var(--danger);
  font-weight: 500;
}

.days-left {
  font-size: 13px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state p {
  margin-bottom: 16px;
  font-size: 16px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 32px;
  font-weight: 700;
}

.stat-card.total .value { color: var(--primary); }
.stat-card.done .value { color: var(--success); }
.stat-card.progress .value { color: var(--info); }
.stat-card.overdue .value { color: var(--danger); }

/* Progress section */
.progress-section {
  margin-bottom: 28px;
}

.progress-section h2,
.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.overall-progress {
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  min-width: 60px;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

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

.card-wide {
  grid-column: 1 / -1;
}

.chart-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-label {
  min-width: 80px;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-item .progress-bar {
  flex: 1;
}

.chart-value {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 70px;
  text-align: right;
}

.status-bar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: var(--radius-sm);
}

.status-bar-item .count {
  font-weight: 600;
}

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, 92vw);
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #f9fafb;
  border-radius: 0 0 var(--radius) var(--radius);
}

.form-row {
  margin-bottom: 16px;
}

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.required {
  color: var(--danger);
}

.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row input[type="range"] {
  padding: 0;
  accent-color: var(--primary);
}

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

.form-row-full {
  grid-column: 1 / -1;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Actions cell */
.actions {
  display: flex;
  gap: 4px;
}

/* Sync badge */
.sync-badge {
  font-size: 12px;
  padding: 4px 10px;
  background: #dcfce7;
  color: #15803d;
  border-radius: 20px;
  font-weight: 500;
}

/* FAB */
.fab {
  display: none;
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 28px;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  z-index: 90;
}

/* Mobile bottom nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 100;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
}

.mobile-nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 20px;
}

/* Install banner */
.install-banner {
  position: fixed;
  bottom: 72px;
  left: 16px;
  right: 16px;
  background: var(--text);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 95;
  box-shadow: var(--shadow-lg);
}

.install-banner p {
  flex: 1;
  font-size: 13px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-close-sm {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .header-inner,
  .tabs,
  .main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand p {
    display: none;
  }

  .btn-desktop-only {
    display: none !important;
  }

  .tabs {
    display: none;
  }

  .mobile-nav {
    display: flex;
  }

  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .panel {
    border-radius: var(--radius);
    margin-top: 12px;
  }

  .progress-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    width: 100%;
  }

  .filters select {
    flex: 1;
    min-width: 0;
  }

  .toolbar {
    flex-direction: column;
  }

  /* Mobile card-style table */
  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 0;
    background: var(--surface);
  }

  .data-table tbody tr:hover {
    background: var(--surface);
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid #f3f4f6;
    text-align: right;
  }

  .data-table td:last-child {
    border-bottom: none;
  }

  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: left;
    flex-shrink: 0;
  }

  .data-table td[data-label="任务"] {
    flex-direction: column;
    text-align: left;
  }

  .data-table td[data-label="任务"]::before {
    margin-bottom: 4px;
  }

  .task-name-cell {
    max-width: none;
  }

  .modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .toast {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}
