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

body {
  font-family: 'Segoe UI', sans-serif;
  background: #f4f5f7;
  display: flex;
  min-height: 100vh;
  color: #2c2c2a;
}

/* ─── Sidebar ────────────────────────────────────────────────── */

.sidebar {
  width: 180px;
  min-width: 180px;
  background: #1a2332;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

.logo { color: #fff; font-size: 16px; font-weight: 600; padding: 0 8px; }

#user-info {
  padding: 0 8px 12px;
  font-size: 12px;
  color: #9ca3af;
  border-bottom: 0.5px solid #2d3f55;
}

nav { display: flex; flex-direction: column; gap: 4px; }

.nav-group {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  padding: 16px 12px 6px;
  border-top: 0.5px solid #2d3f55;
  margin-top: 8px;
}

.nav-group:first-child { border-top: none; margin-top: 0; padding-top: 8px; }

.nav-item {
  color: #9ca3af;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  transition: all .2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover, .nav-item.active { background: #2d3f55; color: #fff; }

/* ─── Main ───────────────────────────────────────────────────── */

.main {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  overflow-x: hidden;
}

.topbar { display: flex; justify-content: space-between; align-items: center; }
.topbar h1 { font-size: 22px; font-weight: 600; }
.date { font-size: 13px; color: #6b7280; }

/* ─── KPI ────────────────────────────────────────────────────── */

.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

.kpi {
  background: #fff;
  border-radius: 10px;
  padding: 16px 20px;
  border: 0.5px solid #e5e7eb;
}

.kpi-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.kpi-val { font-size: 26px; font-weight: 600; color: #2c2c2a; }
.kpi-val.green { color: #0F6E56; }
.kpi-val.orange { color: #BA7517; }
.kpi-val.red { color: #993C1D; }

/* ─── Cards & Charts ─────────────────────────────────────────── */

.charts-row { display: flex; gap: 16px; min-width: 0; }

.card {
  background: #fff;
  border-radius: 12px;
  border: 0.5px solid #e5e7eb;
  padding: 20px 24px;
}

.card-title { font-size: 13px; font-weight: 600; color: #6b7280; margin-bottom: 16px; }

/* Gantt legend dot */
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ─── Table ──────────────────────────────────────────────────── */

.table-wrap {
  background: #fff;
  border-radius: 12px;
  border: 0.5px solid #e5e7eb;
  overflow-x: auto;
}

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

th {
  background: #f9fafb;
  padding: 8px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  border-bottom: 0.5px solid #e5e7eb;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 0.5px solid #f3f4f6;
  color: #2c2c2a;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }
.warn-row td { background: #fff8f6; }

/* ─── Badges ─────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.b-done  { background: #E1F5EE; color: #085041; }
.b-ok    { background: #EAF3DE; color: #27500A; }
.b-slow  { background: #FAEEDA; color: #633806; }
.b-stuck { background: #FAECE7; color: #712B13; }
.b-dash  { background: #F1EFE8; color: #5F5E5A; }

/* ─── Buttons ────────────────────────────────────────────────── */

.btn-sm {
  padding: 3px 8px;
  border-radius: 6px;
  border: 0.5px solid #e5e7eb;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  color: #6b7280;
  transition: background .15s;
}

.btn-sm:hover { background: #f3f4f6; }

.btn-sm.btn-danger {
  border: none;
  background: #FAECE7;
  color: #993C1D;
}

.btn-sm.btn-danger:hover { background: #F5C4B3; }

.btn-ghost {
  padding: 8px 20px;
  border-radius: 8px;
  border: 0.5px solid #e5e7eb;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: #6b7280;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 0.5px solid #e5e7eb;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: #6b7280;
  transition: all .2s;
}

.filter-btn.active { background: #1a2332; color: #fff; border-color: #1a2332; }

/* ─── Project table column widths ────────────────────────────── */

#project-table { table-layout: fixed; min-width: 1360px; }

#project-table th:nth-child(1),  #project-table td:nth-child(1)  { width: 60px; }
#project-table th:nth-child(2),  #project-table td:nth-child(2)  { width: 160px; }
#project-table th:nth-child(3),  #project-table td:nth-child(3)  { width: 100px; }
#project-table th:nth-child(4),  #project-table td:nth-child(4)  { width: 110px; }
#project-table th:nth-child(5),  #project-table td:nth-child(5)  { width: 110px; }
#project-table th:nth-child(6),  #project-table td:nth-child(6)  { width: 100px; }
#project-table th:nth-child(7),  #project-table td:nth-child(7)  { width: 105px; }
#project-table th:nth-child(8),  #project-table td:nth-child(8)  { width: 105px; }
#project-table th:nth-child(9),  #project-table td:nth-child(9)  { width: 190px; }
#project-table th:nth-child(10), #project-table td:nth-child(10) { width: 180px; }
#project-table th:last-child,    #project-table td:last-child    { width: 70px; white-space: nowrap; overflow: visible; }

#project-table td { white-space: normal; overflow: hidden; word-break: break-word; }

/* Cột ghi chú: clamp text, không để tràn vô tận */
#project-table td:nth-child(10) {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Responsive Mobile ──────────────────────────────────────── */
@media (max-width: 768px) {

  body { flex-direction: column; }

  .sidebar {
    width: 100%;
    min-width: unset;
    min-height: unset;
    padding: 12px 16px;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }

  .logo { font-size: 14px; flex: 1; }

  #user-info {
    border-bottom: none;
    border-left: 0.5px solid #2d3f55;
    padding: 0 0 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  #user-info div { margin: 0 !important; }

  nav {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    border-top: 0.5px solid #2d3f55;
    padding-top: 8px;
  }

  .nav-group { display: none; }

  .nav-item {
    padding: 6px 10px;
    font-size: 12px;
  }

  .main { padding: 12px; gap: 12px; }

  .kpi-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .kpi { padding: 10px 12px; }
  .kpi-val { font-size: 20px; }

  .charts-row { flex-direction: column; }

  #project-table { min-width: 800px; }

  /* Milestone banner */
  #milestone-banner > div {
    flex-wrap: wrap;
    gap: 4px;
  }

  /* Panels */
  #duan-panel, #nhatky-panel {
    width: 100% !important;
    height: 85vh !important;
    top: auto !important;
    bottom: 0 !important;
    border-left: none !important;
    border-top: 0.5px solid #e5e7eb;
    border-radius: 16px 16px 0 0;
  }
}

.nav-soon {
  opacity: 0.4;
  cursor: not-allowed !important;
  pointer-events: none;
}