/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}
.btn svg { flex-shrink: 0; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-lg { padding: 14px 24px; font-size: 15px; border-radius: var(--radius-md); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--duration) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--duration) var(--ease);
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.card-actions { display: flex; gap: 6px; }

/* Progress */
.progress-card { padding: 24px; }
.progress-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 14px; }
.progress-title { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.progress-sub { font-size: 13px; color: var(--text); margin-top: 2px; }
.progress-percent { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.progress-bar {
  height: 6px;
  background: var(--bg-muted);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #3b82f6);
  border-radius: 999px;
  transition: width 500ms var(--ease);
}
.progress-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 15px; font-weight: 600; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.tl-item {
  display: grid;
  grid-template-columns: 64px 14px 1fr;
  gap: 14px;
  align-items: center;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
  position: relative;
}
.tl-item:hover { background: var(--bg-hover); }
.tl-time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
  position: relative;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: 38px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  z-index: -1;
}
.tl-item:first-child::before { top: 50%; }
.tl-item:last-child::before { bottom: 50%; }
.tl-item.event .tl-dot { background: var(--event-color, var(--accent)); }
.tl-item.task .tl-dot { background: var(--accent); }
.tl-item.current .tl-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(16,185,129,0.18);
}
.tl-title { font-size: 13.5px; font-weight: 500; }
.tl-meta { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.tl-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-muted);
  margin-left: 6px;
}

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 4px; }
.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
}
.task-item:hover { background: var(--bg-hover); }
.task-item.completed { opacity: 0.5; }
.task-item.completed .task-name { text-decoration: line-through; }

.checkbox {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
}
.checkbox:hover { border-color: var(--accent); }
.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.task-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.task-name { font-size: 14px; font-weight: 500; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11.5px; color: var(--text-muted); }
.task-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-muted);
  font-weight: 500;
}
.task-tag.priority-high { background: rgba(239,68,68,0.1); color: var(--danger); }
.task-tag.priority-medium { background: rgba(245,158,11,0.1); color: var(--warning); }
.task-tag.priority-low { background: rgba(107,114,128,0.12); color: var(--text-muted); }

.task-actions { display: flex; gap: 2px; opacity: 0; transition: opacity var(--duration) var(--ease); }
.task-item:hover .task-actions { opacity: 1; }
.task-actions .icon-btn { width: 28px; height: 28px; }

/* Completed list */
.completed-list { display: flex; flex-direction: column; gap: 2px; }
.completed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.completed-item .check {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.completed-item .ci-name { flex: 1; font-weight: 500; }
.completed-item .ci-time { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.completed-list-full { display: flex; flex-direction: column; gap: 4px; }
.completed-full-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.completed-full-item:hover { background: var(--bg-hover); }
.cf-name { font-weight: 500; }
.cf-time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cf-duration { font-size: 12px; color: var(--text-muted); }

/* Event list */
.event-list { display: flex; flex-direction: column; gap: 4px; }
.event-item {
  display: grid;
  grid-template-columns: 4px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--duration) var(--ease);
}
.event-item:hover { background: var(--bg-hover); }
.event-bar {
  width: 4px; height: 28px;
  border-radius: 2px;
  background: var(--event-color, var(--accent));
}
.event-name { font-size: 13.5px; font-weight: 500; }
.event-time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.routine-name { font-size: 14px; font-weight: 500; color: var(--text); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--bg-muted);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  padding: 32px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.empty-state-sm { padding: 16px; }
.empty-icon { font-size: 28px; margin-bottom: 4px; }
.empty-title { font-size: 14px; font-weight: 600; }
.empty-sub { font-size: 13px; color: var(--text-muted); }
.empty-sub strong { color: var(--text); font-weight: 600; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  animation: fadeIn 200ms var(--ease);
}
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 101;
  display: flex;
  flex-direction: column;
  animation: modalIn 260ms var(--ease);
}
.modal-sm { width: min(400px, calc(100vw - 32px)); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Fields */
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.field .optional { color: var(--text-subtle); font-weight: 400; }
.field input[type="text"],
.field input[type="number"],
.field input[type="time"],
.field textarea,
.search-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color var(--duration) var(--ease);
}
.field input:focus, .field textarea:focus, .search-input:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 72px; font-family: inherit; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Chips */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: all var(--duration) var(--ease);
}
.chip:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.chip.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* Quick grid */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  padding: 2px;
}
.quick-item {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: all var(--duration) var(--ease);
}
.quick-item:hover { background: var(--bg-hover); border-color: var(--border-strong); transform: translateY(-1px); }

/* Color group */
.color-group { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all var(--duration) var(--ease);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg-elevated); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 260ms var(--ease);
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
