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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f3f4f6;
  color: #111827;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: #111827;
  color: #f9fafb;
}

.topbar-nav a {
  margin-left: 16px;
  font-size: 13px;
  text-decoration: none;
  color: #e5e7eb;
}

.topbar-nav a:hover {
  color: #ffffff;
}

.app-title {
  font-weight: 600;
  font-size: 15px;
}

.btn-logout {
  padding: 6px 14px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff !important;
}

.btn-logout:hover {
  background: #dc2626;
}

.main-container {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 12px 40px;
}

/* Cards */
.card {
  background: #ffffff;
  border-radius: 18px;
  padding: 18px 20px 20px;
  margin-bottom: 18px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: #6b7280;
}

/* Summary cards */
.summary-wrapper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-top: 4px;
}

.summary-card {
  position: relative;
  background: #f9fafb;
  border-radius: 18px;
  padding: 12px 14px 10px 14px;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(15,23,42,0.06);
}

.summary-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  border-radius: 999px;
}

.summary-card.total::before { background: #3b82f6; }
.summary-card.not-start::before { background: #f97316; }
.summary-card.in-progress::before { background: #6366f1; }
.summary-card.avg-progress::before { background: #22c55e; }

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

.summary-value {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
}

.summary-footer {
  font-size: 11px;
  color: #9ca3af;
}

/* Search row */
.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  margin-top: 4px;
}

.search-row input[type="text"] {
  flex: 1;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 7px 12px;
  font-size: 13px;
}

.btn-main {
  padding: 7px 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg,#3b82f6,#6366f1);
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}

.btn-main:hover {
  background: linear-gradient(135deg,#2563eb,#4f46e5);
}

.btn-clear-search {
  padding: 6px 12px;
  border-radius: 999px;
  background: #e5e7eb;
  font-size: 12px;
  text-decoration: none;
  color: #374151;
}

.btn-clear-search:hover {
  background: #d1d5db;
}

/* Gantt container */
.card-gantt {
  padding-top: 16px;
}

.gantt-container {
  width: 100%;
  height: 360px;
}

/* Forms */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.form-group {
  flex: 1;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  font-size: 13px;
}

.form-group label {
  margin-bottom: 4px;
  color: #374151;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 7px 10px;
  font-size: 13px;
}

.form-group textarea {
  min-height: 80px;
}

/* Table */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: #f3f4f6;
}

.table th,
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

.table th {
  font-weight: 600;
  color: #4b5563;
}

/* Badges */
.badge-level {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #fff;
}

.badge-status {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
}

.badge-pending {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-in-progress {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-completed {
  background: #dcfce7;
  color: #166534;
}

/* Action buttons */
.action-btn {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  text-decoration: none;
  margin-right: 4px;
}

.action-edit {
  background: #dbeafe;
  color: #1d4ed8;
}

.action-delete {
  background: #fee2e2;
  color: #b91c1c;
}

/* Task cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px,1fr));
  gap: 12px;
}

.task-card {
  background: #f9fafb;
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 6px 14px rgba(15,23,42,0.06);
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.task-title {
  font-size: 13px;
  font-weight: 600;
}

.task-meta {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 6px;
}

.progress-bar-bg {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #22c55e;
}

/* Responsive */
@media (max-width: 900px) {
  .summary-wrapper {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .gantt-container {
    height: 320px;
  }
}

@media (max-width: 640px) {
  .summary-wrapper {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}
/* การ์ดงานที่เกินกำหนดเวลา */
.task-card-overdue {
    border: 2px solid #ef4444 !important;      /* กรอบแดง */
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); /* เงาแดงจาง ๆ */
    border-radius: 10px;
}

.task-card-overdue .task-title {
    color: #b91c1c !important;                 /* ชื่อเรื่องสีแดงเข้ม */
    font-weight: bold;
}
/* ป้าย "เกินกำหนด" */
.overdue-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    background: #dc2626;
    color: white;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ให้ task-card รองรับตำแหน่ง absolute ของ badge */
.task-card {
    position: relative;
    padding-top: 20px;
}


