:root {
  --font-main: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --bg: #fafaf8;
  --bg-card: #ffffff;
  --bg-surface: #f5f5f3;
  --text: #111111;
  --text-2: #4a4a46;
  --text-3: #7a7a76;
  --border: rgba(0, 0, 0, 0.12);
  --border-hover: rgba(0, 0, 0, 0.2);
  --accent: #1d9e75;
  --accent-bg: #e1f5ee;
  --accent-text: #085041;
  --done: #639922;
  --done-bg: #eaf3de;
  --done-text: #27500a;
  --radius: 8px;
  --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --bg-card: #242422;
    --bg-surface: #2c2c2a;
    --text: #f0f0ec;
    --text-2: #b8b8b0;
    --text-3: #878780;
    --border: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(255, 255, 255, 0.2);
  }
}

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

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2.5rem;
}

.header h1 {
  font-size: 36px;
  font-weight: 600;
  color: var(--text);
}

.header-sub {
  font-size: 18px;
  color: var(--text-2);
  margin-left: 16px;
  font-weight: 400;
}

.toolbar {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.toolbar-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 14px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  min-width: 100px;
}

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

.pill {
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 15px;
  font-family: var(--font-main);
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  transition: all 0.15s;
  white-space: nowrap;
  font-weight: 500;
}

.pill:hover {
  background: var(--bg-surface);
  border-color: var(--border-hover);
  color: var(--text);
}

.pill.active {
  background: var(--accent-bg);
  color: var(--accent-text);
  border-color: var(--accent);
}

.pill.pill-person.active {
  background: #eeedfe;
  color: #3c3489;
  border-color: #7f77dd;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 3rem;
}

.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
}

.stat-done { color: var(--done); }
.stat-open { color: var(--text-3); }

.plan-header {
  margin-bottom: 1.5rem;
  padding: 0 4px;
}

.plan-name {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

.table-container {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.goals-table {
  width: 100%;
  border-collapse: collapse;
}

.goals-table thead {
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border);
}

.goals-table th {
  padding: 18px 20px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
}

.goals-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.goals-table th.sortable:hover {
  background: var(--bg-card);
}

.sort-icon {
  margin-left: 6px;
  color: var(--text-3);
  font-size: 12px;
}

.goals-table th.sorted-asc .sort-icon::before {
  content: '↑';
}

.goals-table th.sorted-desc .sort-icon::before {
  content: '↓';
}

.goals-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s;
}

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

.goals-table tbody tr.hidden {
  display: none;
}

.goals-table td {
  padding: 20px 20px;
  vertical-align: top;
}

.goal-cell {
  min-width: 350px;
}

.goal-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.goal-desc {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.5;
  margin-top: 6px;
}

.taxo-cell {
  min-width: 140px;
}

.taxo {
  display: inline-block;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 500;
  white-space: nowrap;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: help;
  position: relative;
}

.taxo-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 400px;
  max-width: 500px;
  white-space: normal;
}

.taxo:hover .taxo-tooltip {
  display: block;
}

.taxo-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--bg-card);
}

.taxo-tooltip::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top-color: var(--border);
  margin-top: 2px;
}

.tooltip-header {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  text-transform: capitalize;
}

.tooltip-row {
  margin-bottom: 12px;
}

.tooltip-row:last-child {
  margin-bottom: 0;
}

.tooltip-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tooltip-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-line;
}

.hours-cell {
  font-size: 16px;
  color: var(--text-2);
  font-weight: 500;
  min-width: 100px;
}

.responsible-cell {
  font-size: 15px;
  color: var(--text-2);
  min-width: 200px;
}

.checks-cell {
  min-width: 200px;
}

.goal-checks {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.chk-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chk-wrap label {
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.chk-wrap input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--done);
  cursor: pointer;
  margin: 0;
}

.chk-wrap.hidden {
  display: none;
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 16px;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: #e24b4a;
  color: #e24b4a;
  background: #fff5f5;
}

@media (max-width: 1024px) {
  .container { 
    padding: 2rem 1.5rem; 
  }
  
  .goals-table th,
  .goals-table td {
    padding: 14px 12px;
  }
  
  .goal-cell {
    min-width: 250px;
  }
}

@media (max-width: 768px) {
  .container { 
    padding: 1.5rem 1rem; 
  }
  
  .header h1 {
    font-size: 28px;
  }
  
  .toolbar {
    gap: 20px;
  }
  
  .toolbar-section {
    width: 100%;
  }
  
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .table-container {
    overflow-x: auto;
  }
  
  .goals-table {
    min-width: 800px;
  }
}
