* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: #f4f7fb;
  color: #1f2937;
}

.topbar {
  background: linear-gradient(135deg, #0f4c81, #2563eb);
  color: white;
  padding: 28px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 6px 0 0;
  opacity: 0.9;
}

.badge {
  background: rgba(255, 255, 255, 0.18);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 28px;
}

.summary-card {
  background: white;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
}

.summary-card p {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
}

.summary-card h2 {
  margin: 10px 0 0;
  font-size: 34px;
  color: #0f4c81;
}

.summary-card.warning h2 {
  color: #d97706;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.section-header h2 {
  margin: 0;
}

.section-header p {
  margin: 4px 0 0;
  color: #6b7280;
}

button {
  border: none;
  background: #0f4c81;
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

button:hover {
  background: #0b3d66;
}

.loading {
  background: white;
  padding: 18px;
  border-radius: 14px;
  color: #6b7280;
  box-shadow: 0 6px 18px rgba(15, 76, 129, 0.06);
}

.project-list {
  display: grid;
  gap: 18px;
}

.project-card {
  background: white;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
  border-left: 6px solid #2563eb;
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.project-title {
  margin: 0;
  font-size: 20px;
  color: #111827;
}

.project-meta {
  margin-top: 8px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.6;
}

.status-pill {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: #e0f2fe;
  color: #0369a1;
  white-space: nowrap;
}

.progress-wrap {
  margin-top: 18px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 8px;
}

.progress-bar {
  height: 12px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
}

.task-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.task-chip {
  background: #f3f4f6;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: #374151;
}

.card-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.detail-link {
  text-decoration: none;
  background: #0f4c81;
  color: white;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.detail-link:hover {
  background: #0b3d66;
}

.error-box {
  background: #fee2e2;
  color: #991b1b;
  padding: 18px;
  border-radius: 14px;
}

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .project-card-header {
    flex-direction: column;
  }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  color: white;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.18);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.28);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.detail-card {
  background: white;
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
}

.detail-card p {
  margin: 0;
  color: #6b7280;
  font-size: 14px;
}

.detail-card h2 {
  margin: 10px 0 0;
  font-size: 34px;
  color: #0f4c81;
}

.detail-card.warning h2 {
  color: #d97706;
}

.project-info-card {
  background: white;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
  margin-bottom: 24px;
}

.project-info-card h2 {
  margin: 0 0 18px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.info-item {
  background: #f9fafb;
  border-radius: 12px;
  padding: 14px;
}

.info-item span {
  display: block;
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 6px;
}

.info-item strong {
  display: block;
  color: #111827;
  font-size: 15px;
}

.phase-container {
  display: grid;
  gap: 22px;
}

.phase-card {
  background: white;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
  border-left: 6px solid #2563eb;
}

.phase-header {
  margin-bottom: 18px;
}

.phase-header h3 {
  margin: 0;
  font-size: 22px;
  color: #111827;
}

.category-block {
  margin-top: 18px;
  border-top: 1px solid #e5e7eb;
  padding-top: 18px;
}

.category-block h4 {
  margin: 0 0 12px;
  font-size: 17px;
  color: #0f4c81;
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-row {
  background: #f9fafb;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid #e5e7eb;
}

.task-title-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.task-title-line strong {
  color: #111827;
  font-size: 15px;
}

.task-status {
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.task-main p {
  color: #4b5563;
  margin: 8px 0 10px;
  line-height: 1.5;
}

.task-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: #6b7280;
  font-size: 13px;
}

.task-remark {
  margin-top: 10px;
  background: #fff7ed;
  color: #9a3412;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
}

.owner-action {
  margin-top: 10px;
  background: #fef3c7;
  color: #92400e;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
}

.internal-note {
  margin-top: 10px;
  background: #fee2e2;
  color: #991b1b;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
}

.internal-task {
  opacity: 0.72;
  border-style: dashed;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 24px;
}

.event-list,
.comment-list {
  display: grid;
  gap: 12px;
}

.event-item,
.comment-item {
  background: #f9fafb;
  border-radius: 14px;
  padding: 14px;
  border: 1px solid #e5e7eb;
}

.event-item strong,
.comment-item strong {
  color: #111827;
}

.event-item p,
.comment-item p {
  color: #4b5563;
  margin: 8px 0;
  line-height: 1.5;
}

.event-meta {
  color: #6b7280;
  font-size: 13px;
}

.empty-text {
  color: #6b7280;
  background: #f9fafb;
  padding: 14px;
  border-radius: 12px;
}

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .task-title-line {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }

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

.task-toolbar {
  background: white;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 22px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.08);
}

.task-status-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.task-summary-chip {
  padding: 9px 12px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  font-size: 13px;
}

.task-summary-chip strong {
  margin-left: 4px;
}

.task-summary-chip.done {
  background: #dcfce7;
  color: #166534;
}

.task-summary-chip.in-progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.task-summary-chip.not-started {
  background: #fee2e2;
  color: #991b1b;
}

.task-summary-chip.waiting {
  background: #fef3c7;
  color: #92400e;
}

.task-summary-chip.blocked {
  background: #ffedd5;
  color: #9a3412;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-btn {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}

.filter-btn:hover {
  background: #e5e7eb;
}

.filter-btn.active {
  background: #0f4c81;
  color: white;
  border-color: #0f4c81;
}

.task-row {
  border-left: 5px solid #d1d5db;
}

.task-row.status-done {
  border-left-color: #22c55e;
}

.task-row.status-in-progress {
  border-left-color: #3b82f6;
}

.task-row.status-not-started {
  border-left-color: #ef4444;
}

.task-row.status-waiting-owner,
.task-row.status-waiting-external {
  border-left-color: #f59e0b;
}

.task-row.status-blocked {
  border-left-color: #f97316;
}

.task-row.status-cancelled {
  border-left-color: #6b7280;
}

.task-code {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.task-badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.task-status.status-done {
  background: #dcfce7;
  color: #166534;
}

.task-status.status-in-progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.task-status.status-not-started {
  background: #fee2e2;
  color: #991b1b;
}

.task-status.status-waiting-owner,
.task-status.status-waiting-external {
  background: #fef3c7;
  color: #92400e;
}

.task-status.status-blocked {
  background: #ffedd5;
  color: #9a3412;
}

.task-status.status-cancelled {
  background: #e5e7eb;
  color: #374151;
}

.priority-pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.priority-low {
  background: #f3f4f6;
  color: #4b5563;
}

.priority-normal {
  background: #e0f2fe;
  color: #0369a1;
}

.priority-high {
  background: #fef3c7;
  color: #92400e;
}

.priority-urgent {
  background: #fee2e2;
  color: #991b1b;
}

.task-note {
  margin-top: 10px;
  background: #eef2ff;
  color: #3730a3;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
}

.calendar-note {
  margin-top: 10px;
  background: #ecfdf5;
  color: #047857;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
}

.task-update-box {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 12px;
  border-radius: 12px;
}

.task-update-box select {
  min-width: 230px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: white;
  color: #111827;
}

.small-action-btn {
  background: #0f4c81;
  color: white;
  border: none;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

.small-action-btn:hover {
  background: #0b3d66;
}

.task-comment-box {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  padding: 12px;
  border-radius: 12px;
}

.task-comment-box textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-family: inherit;
  font-size: 14px;
}

.comment-visible-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #374151;
  font-size: 13px;
}

.small-secondary-btn {
  justify-self: start;
  background: #374151;
  color: white;
  border: none;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

.small-secondary-btn:hover {
  background: #111827;
}

.owner-topbar {
  background: linear-gradient(135deg, #065f46, #10b981);
}

.owner-notice {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 24px;
}

.owner-notice strong {
  display: block;
  font-size: 18px;
  margin-bottom: 6px;
}

.owner-notice p {
  margin: 0;
  color: #047857;
}

.card-actions {
  gap: 10px;
}

.owner-link {
  background: #059669;
}

.owner-link:hover {
  background: #047857;
}

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f4c81, #2563eb);
}

.login-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.login-header h1 {
  margin: 0;
  color: #0f4c81;
}

.login-header p {
  margin: 8px 0 24px;
  color: #6b7280;
}

.login-card label {
  display: block;
  margin: 14px 0 6px;
  color: #374151;
  font-size: 14px;
}

.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  font-size: 15px;
}

.login-btn {
  width: 100%;
  margin-top: 20px;
  padding: 13px 16px;
  border-radius: 12px;
  background: #0f4c81;
  color: white;
  border: none;
  font-size: 15px;
  cursor: pointer;
}

.login-btn:hover {
  background: #0b3d66;
}

.login-error {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.login-hint {
  margin-top: 18px;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.5;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.18);
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.user-box button {
  background: white;
  color: #0f4c81;
  border: none;
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
}

.user-box button:hover {
  background: #f3f4f6;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-link-btn {
  display: inline-block;
  text-decoration: none;
  background: #059669;
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
}

.primary-link-btn:hover {
  background: #047857;
}

.project-form {
  margin-top: 8px;
}

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

.form-group {
  display: grid;
  gap: 7px;
}

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

.form-group label {
  color: #374151;
  font-size: 14px;
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  font-family: inherit;
  font-size: 14px;
  background: white;
}

.form-group textarea {
  min-height: 92px;
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.primary-btn {
  background: #0f4c81;
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
}

.primary-btn:hover {
  background: #0b3d66;
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.secondary-link {
  text-decoration: none;
  background: #f3f4f6;
  color: #374151;
  padding: 12px 18px;
  border-radius: 12px;
}

.secondary-link:hover {
  background: #e5e7eb;
}

.form-message {
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 14px;
}

.form-message.success {
  background: #dcfce7;
  color: #166534;
}

.form-message.error {
  background: #fee2e2;
  color: #991b1b;
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .primary-link-btn,
  .section-actions button {
    text-align: center;
  }
}
