/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #0f172a;
  --accent-hover: #1e293b;
  --accent-light: #3b82f6;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
}

html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.page { min-height: 100vh; display: flex; flex-direction: column; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

/* ── Nav ── */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1rem; color: var(--text); letter-spacing: -0.02em; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 6px 14px; border-radius: var(--radius); font-size: 0.875rem;
  color: var(--text-muted); text-decoration: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface-alt); color: var(--text); }
.nav-link.active { background: var(--surface-alt); color: var(--text); font-weight: 500; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; font-size: 0.875rem; font-weight: 500; font-family: inherit;
  border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-alt); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-ghost-icon {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 4px 8px; border-radius: var(--radius); font-size: 1.1rem;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost-icon:hover { background: var(--surface-alt); color: var(--text); }

/* ── Stats ── */
.stats-row {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px;
  padding: 28px 0 8px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  text-align: center; transition: border-color 0.15s;
}
.stat-value { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card--todo { border-left: 3px solid var(--accent-light); }
.stat-card--todo .stat-value { color: var(--accent-light); }
.stat-card--progress { border-left: 3px solid var(--warning); }
.stat-card--progress .stat-value { color: var(--warning); }
.stat-card--done { border-left: 3px solid var(--success); }
.stat-card--done .stat-value { color: var(--success); }
.stat-card--overdue { border-left: 3px solid var(--danger); }
.stat-card--overdue .stat-value { color: var(--danger); }

/* ── Filters ── */
.filters-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 0 16px; flex-wrap: wrap;
}
.search-box {
 display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0 14px; flex: 1; min-width: 200px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.search-box i { color: var(--text-subtle); font-size: 0.85rem; }
.search-box input {
  border: none; background: none; padding: 10px 0;
  font-size: 0.875rem; font-family: inherit;
  outline: none; color: var(--text);
}
.search-box input::placeholder { color: var(--text-subtle); }
.filter-group { display: flex; gap: 8px; }
.filter-group select {
  padding: 9px 14px; font-size: 0.825rem; min-width: 140px;
}

/* ── Board View ── */
.board {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  padding-bottom: 48px;
}
.board-column {
  background: var(--surface-alt); border-radius: var(--radius);
  padding: 16px; min-height: 300px;
}
.board-column-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding: 0 4px;
}
.board-column-header h3 { font-size: 0.9rem; font-weight: 600; flex: 1; }
.board-count {
  background: var(--surface); color: var(--text-muted);
  font-size: 0.75rem; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
}
.board-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.board-dot--todo { background: var(--accent-light); }
.board-dot--progress { background: var(--warning); }
.board-dot--done { background: var(--success); }
.board-cards { display: flex; flex-direction: column; gap: 10px; }

/* ── Task Card ── */
.task-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
  position: relative;
}
.task-card:hover {
  box-shadow: var(--shadow-md); border-color: var(--accent-light);
}
.task-card-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; line-height: 1.4; }
.task-card-desc {
  font-size: 0.8rem; color: var(--text-muted); line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-card-overdue { border-left: 3px solid var(--danger); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 99px; font-size: 0.7rem; font-weight: 500;
}
.badge-priority-high { background: #fee2e2; color: #b91c1c; }
.badge-priority-medium { background: #fef3c7; color: #b45309; }
.badge-priority-low { background: #f0fdf4; color: #15803d; }
.badge-status-todo { background: #dbeafe; color: #1d4ed8; }
.badge-status-in-progress { background: #fef3c7; color: #b45309; }
.badge-status-done { background: #dcfce7; color: #15803d; }
.badge-category { background: var(--surface-alt); color: var(--text-muted); }
.badge-due { background: var(--surface-alt); color: var(--text-muted); font-size: 0.7rem; }
.badge-due--overdue { background: #fee2e2; color: #b91c1c; }
.badge-due--soon { background: #fef3c7; color: #b45309; }

/* ── List View ── */
.list-view { padding-bottom: 48px; }
.task-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.task-table th {
  text-align: left; padding: 10px 16px; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.task-table td {
  padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text);
  vertical-align: middle;
}
.task-table tr:last-child td { border-bottom: none; }
.task-table tr:hover td { background: var(--bg); }
.task-table .task-title-cell { font-weight: 500; max-width: 300px; }
.task-table .task-title-cell .task-desc-inline {
  font-size: 0.8rem; color: var(--text-muted); font-weight: 400;
  margin-top: 2px;
}
.task-table .actions-cell { text-align: right; white-space: nowrap; }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 64px 32px; color: var(--text-subtle);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 10px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal-sm { max-width: 400px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 600; }
.modal-body { padding: 20px 24px 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.85rem; font-weight: 500; color: var(--text); }
input, select, textarea {
  width: 100%; padding: 10px 14px;
  font-size: 0.9rem; font-family: inherit;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
textarea { resize: vertical; min-height: 60px; }

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 20px;
  box-shadow: var(--shadow-md); font-size: 0.875rem;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.25s ease-out;
  min-width: 240px;
}
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-out { animation: toast-out 0.2s ease-in forwards; }

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

/* ── Responsive ── */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .board { grid-template-columns: 1fr; }
  .nav { padding: 0 16px; }
  .container { padding: 0 16px; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filter-group { flex-wrap: wrap; }
  .filter-group select { flex: 1; min-width: 0; }
}
@media (max-width: 600px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .task-table { font-size: 0.8rem; }
  .task-table th, .task-table td { padding: 10px 8px; }
  .nav-links { display: none; }
}