:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --surface: #ffffff;
  --band: #f5f7fb;
  --blue: #275dcc;
  --teal: #0f8a8a;
  --green: #16834a;
  --amber: #b7791f;
  --red: #c2413b;
  --violet: #6d55c7;
  --shadow: 0 12px 28px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f7;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 13px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 128px;
  padding: 18px 28px;
  background: #ffffff;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.9) 42%, rgba(255, 255, 255, 0.68) 68%, rgba(255, 255, 255, 0.84) 100%),
    url("./assets/cover-gia-dinh.jpg");
  background-position: center;
  background-size: cover;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  overflow: hidden;
}

.topbar::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: linear-gradient(90deg, #1279bd, #0f8a8a, #e2b040);
}

.brand-lockup {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.site-logo {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffffff;
  border: 3px solid #ffffff;
  box-shadow: 0 8px 22px rgba(23, 32, 51, 0.18);
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: #0f6e9f;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.25;
  max-width: 760px;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.status-panel {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  justify-content: flex-end;
  color: #334155;
  padding: 10px;
  border: 1px solid rgba(217, 224, 234, 0.78);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 28px rgba(23, 32, 51, 0.12);
  backdrop-filter: blur(6px);
}

button,
select,
input {
  font: inherit;
}

button {
  border: 1px solid #1b4fb6;
  background: var(--blue);
  color: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

a.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

button:hover {
  background: #1b4fb6;
}

.secondary-btn {
  background: #ffffff;
  color: var(--blue);
  border-color: #b9c8e8;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

main {
  width: min(1580px, calc(100vw - 32px));
  margin: 16px auto 24px;
}

.control-band {
  display: grid;
  grid-template-columns: 150px minmax(260px, 1fr) 230px 210px 230px;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.toggle-filter {
  justify-content: space-between;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink);
  font-weight: 800;
}

.switch-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--red);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c8d2e0;
  background: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.kpi,
.chart-panel,
.project-list-panel,
.project-detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kpi {
  padding: 14px;
  min-height: 112px;
  border-left: 4px solid var(--teal);
  overflow-wrap: anywhere;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.kpi span,
.kpi em {
  display: block;
  color: var(--muted);
  font-style: normal;
}

.kpi strong {
  display: block;
  margin: 8px 0 6px;
  font-size: clamp(18px, 1.4vw, 22px);
  line-height: 1.15;
}

.kpi-clickable {
  cursor: pointer;
}

.kpi-clickable:hover,
.kpi-clickable.active {
  background: #f3fbfb;
  border-left-color: var(--blue);
  transform: translateY(-1px);
}

.alert-kpi {
  border-left-color: var(--amber);
}

.urgent-kpi {
  border-left-color: var(--red);
  background: #fff7f5;
}

.urgent-kpi strong {
  color: var(--red);
}

.filter-state {
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid #b9d7d4;
  background: #eefafa;
  color: #0d5f5d;
  font-weight: 800;
}

.year-end-panel {
  margin-top: 14px;
  background: #fff8f6;
  border: 1px solid #f1b6ad;
  box-shadow: var(--shadow);
}

.year-end-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 16px;
}

.year-end-item {
  border: 1px solid #f0c1bc;
  border-left: 6px solid var(--red);
  background: #fff;
  color: var(--ink);
  padding: 12px;
  display: grid;
  gap: 8px;
  min-height: 132px;
  text-align: left;
  border-radius: 0;
  cursor: pointer;
}

.year-end-item.warning {
  border-left-color: var(--amber);
  background: #fffaf0;
}

.year-end-item:hover {
  background: #fff0ee;
}

.year-end-item.warning:hover {
  background: #fff3d8;
}

.year-end-item strong {
  color: var(--red);
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.year-end-item span,
.year-end-item small {
  color: var(--muted);
  line-height: 1.35;
}

.year-end-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.year-end-metrics b {
  display: block;
  color: var(--ink);
}

.bottleneck-panel {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.bottleneck-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 16px;
}

.bottleneck-card {
  border: 1px solid #e0e7ef;
  border-left: 5px solid var(--amber);
  background: #fffdf5;
  color: var(--ink);
  padding: 12px;
  min-height: 112px;
  display: grid;
  gap: 8px;
  text-align: left;
  border-radius: 0;
}

.bottleneck-card.danger {
  border-left-color: var(--red);
  background: #fff4f2;
}

.bottleneck-card.warning {
  border-left-color: var(--amber);
  background: #fffaf0;
}

.bottleneck-card.idle {
  border-left-color: #667085;
  background: #f7f9fc;
}

.bottleneck-card strong {
  font-size: 20px;
}

.bottleneck-card span,
.bottleneck-card small {
  color: var(--muted);
  line-height: 1.35;
}

.overview-layout,
.split-layout,
.detail-layout,
.gantt-layout {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.overview-layout {
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
}

.split-layout,
.gantt-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-layout {
  grid-template-columns: minmax(0, 1fr);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.panel-heading span {
  color: var(--muted);
  white-space: normal;
  text-align: right;
}

.chart-surface {
  min-height: 310px;
  padding: 14px 16px 16px;
}

.chart-surface.compact {
  min-height: 310px;
}

.chart-surface.tall {
  min-height: 390px;
}

.table-wrap {
  max-height: 680px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  border-bottom: 1px solid #e7ecf3;
  padding: 10px 9px;
  text-align: left;
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

th {
  position: sticky;
  top: 0;
  background: #eef4fb;
  color: #24364f;
  z-index: 1;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #edf7f7;
}

tbody tr.warning-row {
  background: #fffaf1;
}

tbody tr.urgent-row {
  background: #fff0ee;
}

tbody tr.warning-row:hover {
  background: #fff2d6;
}

tbody tr.urgent-row:hover {
  background: #ffe1dd;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  text-align: center;
}

.badge.done {
  color: #07512c;
  background: #d9f0df;
}

.badge.warn {
  color: #6d450b;
  background: #fff0bf;
}

.badge.danger {
  color: #7a1815;
  background: #ffd8d4;
}

.badge.idle {
  color: #3b4657;
  background: #e5e9ef;
}

.badge.prep {
  color: #123d7a;
  background: #dceaff;
}

.project-detail {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.detail-title {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-item {
  border: 1px solid #e2e8f0;
  padding: 10px;
  background: #fbfcfe;
  min-height: 70px;
  overflow-wrap: anywhere;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 5px;
}

.year-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.year-detail-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid #d9e0ea;
}

.year-detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.year-detail-table th,
.year-detail-table td {
  border-bottom: 1px solid #e7ecf3;
  border-right: 1px solid #e7ecf3;
  padding: 9px;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.year-detail-table th {
  position: sticky;
  top: 0;
  background: #eef4fb;
  z-index: 1;
}

.year-detail-table tbody tr[data-id] {
  cursor: pointer;
}

.year-detail-table tbody tr[data-id]:hover {
  background: #f3f8ff;
}

.progress-pair {
  display: grid;
  gap: 10px;
}

.progress-row {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr) 70px;
  gap: 10px;
  align-items: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.56);
  padding: 28px;
  display: grid;
  place-items: center;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(1180px, calc(100vw - 40px));
  max-height: calc(100vh - 54px);
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.26);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  font-size: 20px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.modal-body {
  overflow: auto;
  padding: 18px 20px 22px;
}

.warning-text {
  color: var(--red);
  font-weight: 800;
}

.urgent-text {
  color: var(--red);
  font-weight: 900;
}

.modal-alert {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid #f0b7b1;
  background: #fff4f2;
}

.modal-alert span {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 6px;
  background: #ffd8d4;
  color: #7a1815;
  font-weight: 800;
}

.bar.danger {
  background: var(--red);
}

.bar.warn {
  background: var(--amber);
}

.html-bars {
  display: grid;
  gap: 12px;
}

.html-bar-row {
  display: grid;
  grid-template-columns: minmax(220px, 34%) minmax(0, 1fr) minmax(90px, auto);
  gap: 14px;
  align-items: center;
  border-radius: 6px;
  padding: 2px 4px;
}

.html-bar-row.clickable {
  cursor: pointer;
}

.html-bar-row.clickable:hover,
.html-bar-row.clickable:focus {
  background: #f3f8ff;
  outline: 2px solid transparent;
}

.html-bar-row.clickable:hover .html-bar-label,
.html-bar-row.clickable:focus .html-bar-label {
  color: var(--blue);
  text-decoration: underline;
}

.html-bar-label {
  font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #344054;
  line-height: 1.45;
  text-transform: none;
  overflow-wrap: anywhere;
}

.html-bar-track {
  height: 18px;
  border-radius: 6px;
  background: #edf2f7;
  overflow: hidden;
}

.html-bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: 6px;
}

.html-bar-fill.critical {
  background: var(--red) !important;
}

.html-bar-value {
  font-family: "Segoe UI", "Noto Sans", Arial, sans-serif;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
  line-height: 1.3;
}

.track {
  height: 12px;
  background: #e8eef5;
  border-radius: 999px;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0%;
  background: var(--teal);
}

.bar.blue {
  background: var(--blue);
}

.bar.violet {
  background: var(--violet);
}

.svg-chart {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.chart-empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #cad3df;
  background: #fafcff;
}

.gantt-surface {
  min-height: 430px;
  max-height: 560px;
  overflow: auto;
  padding: 14px 16px 16px;
}

.gantt-row {
  display: grid;
  grid-template-columns: minmax(220px, 34%) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid #e7ecf3;
}

.gantt-name {
  color: #26364c;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.gantt-line {
  position: relative;
  height: 28px;
  background: linear-gradient(90deg, #e9eff7 0 1px, transparent 1px 20%);
  border-radius: 6px;
}

.gantt-block {
  position: absolute;
  top: 6px;
  height: 16px;
  min-width: 6px;
  border-radius: 5px;
  background: var(--blue);
}

.gantt-block.construction {
  background: var(--teal);
}

.gantt-block.problem {
  background: var(--red);
}

.gantt-axis {
  display: grid;
  grid-template-columns: minmax(220px, 34%) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.print-report {
  display: none;
}

.axis-years {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  text-align: center;
}

footer {
  width: min(1580px, calc(100vw - 32px));
  margin: 0 auto 20px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

@media (max-width: 1100px) {
  .topbar,
  footer {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    min-height: 0;
    background-image:
      linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86)),
      url("./assets/cover-gia-dinh.jpg");
  }

  .status-panel {
    justify-content: space-between;
    min-width: 0;
    flex-wrap: wrap;
  }

  .control-band,
  .kpi-grid,
  .overview-layout,
  .split-layout,
  .detail-layout,
  .gantt-layout {
    grid-template-columns: 1fr;
  }

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

  .bottleneck-list,
  .year-end-list,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .html-bar-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  main,
  footer {
    width: calc(100vw - 20px);
  }

  .topbar {
    padding: 14px;
  }

  .brand-lockup {
    align-items: flex-start;
    gap: 12px;
  }

  .site-logo {
    width: 64px;
    height: 64px;
  }

  h1 {
    font-size: 19px;
  }

  .status-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .status-panel span {
    grid-column: 1 / -1;
  }

  .kpi-grid,
  .detail-grid,
  .bottleneck-list,
  .year-end-list {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-heading span {
    white-space: normal;
  }

  .gantt-row,
  .gantt-axis {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal-panel {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .control-band,
  .overview-layout,
  .split-layout,
  .detail-layout,
  .gantt-layout,
  .bottleneck-panel,
  .filter-state,
  footer,
  .modal-backdrop {
    display: none !important;
  }

  .print-report {
    display: block;
    padding: 12px;
    color: #111827;
  }
}
