*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f5f5f5;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.view-toggle {
  display: flex;
  gap: 0;
}

.view-toggle .btn-toggle {
  padding: 0.4rem 0.75rem;
  font-size: 13px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
}

.view-toggle .btn-toggle:first-child {
  border-radius: 6px 0 0 6px;
  border-right-width: 0;
}

.view-toggle .btn-toggle:last-child {
  border-radius: 0 6px 6px 0;
}

.view-toggle .btn-toggle.active,
.view-toggle .btn-toggle[aria-pressed="true"] {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.view-toggle .btn-toggle:not(.active):hover {
  background: #f0f0f0;
}

.period-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.period-nav button {
  padding: 0.4rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.period-nav button:hover {
  background: #f0f0f0;
  border-color: #999;
}

#periodLabel {
  min-width: 140px;
  text-align: center;
  font-weight: 600;
}

.btn {
  padding: 0.5rem 1rem;
  font-size: 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

.btn-secondary:hover {
  background: #d1d5db;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

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

.main {
  padding: 1rem 1.5rem;
  max-width: 100%;
}

.form-section {
  margin-bottom: 1.5rem;
}

.form-section.hidden {
  display: none;
}

.project-form {
  max-width: 400px;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.project-form h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.project-form label {
  display: block;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.project-form input[type="text"],
.project-form input[type="date"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.project-form input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.form-error {
  margin-top: 0.75rem;
  color: #dc2626;
  font-size: 13px;
}

.form-error.hidden {
  display: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.timeline-section {
  overflow-x: auto;
}

.timeline-wrapper {
  min-width: max-content;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

.timeline-table th,
.timeline-table td {
  border: 1px solid #e5e7eb;
  padding: 0.5rem 0.6rem;
  text-align: center;
  min-width: 36px;
}

.timeline-table thead th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 12px;
  color: #6b7280;
}

.col-project {
  min-width: 160px;
  text-align: left;
  position: sticky;
  left: 0;
  background: #f9fafb;
  z-index: 1;
}

.timeline-table tbody tr:hover .col-project {
  background: #f3f4f6;
}

.project-name-cell {
  cursor: pointer;
  font-weight: 500;
  color: #2563eb;
}

.project-name-cell:hover {
  text-decoration: underline;
}

.cell-bar {
  background: #93c5fd;
  border-radius: 0;
}

.cell-bar-start {
  border-radius: 4px 0 0 4px;
  background: #60a5fa;
}

.cell-bar-end {
  border-radius: 0 4px 4px 0;
  background: #60a5fa;
}

.cell-bar-single {
  border-radius: 4px;
  background: #60a5fa;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: #6b7280;
}

.empty-state p {
  margin: 0;
}

.th-day-num {
  display: block;
  font-size: 10px;
  color: #9ca3af;
  font-weight: 500;
  line-height: 1.2;
}

.timeline-table:not(.year-view) thead th:not(.col-project) {
  min-width: 32px;
  padding: 0.35rem 0.25rem;
}

.timeline-table.year-view th.col-month {
  min-width: 52px;
  font-size: 11px;
}

.timeline-table.year-view td.year-month-cell {
  min-width: 52px;
  min-height: 28px;
  padding: 0.4rem;
}

.timeline-table.year-view td.year-cell-bar {
  background: #60a5fa;
  border-radius: 4px;
}

/* Current day (month view) / current month (year view) highlight */
.timeline-table th.day-today,
.timeline-table td.day-today {
  background: #fef3c7;
  box-shadow: inset 0 0 0 2px #f59e0b;
}
.timeline-table td.day-today.cell-bar,
.timeline-table td.day-today.cell-bar-start,
.timeline-table td.day-today.cell-bar-end,
.timeline-table td.day-today.cell-bar-single {
  background: #93c5fd;
  box-shadow: inset 0 0 0 2px #2563eb;
}
