.projects-page {
  width: 100%;
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

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

.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.project-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
}

.project-toolbar input,
.project-toolbar select {
  max-width: 320px;
}

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

.project-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.project-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.progress-block {
  margin: 18px 0;
}

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

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

.progress-bar div {
  height: 100%;
  background: var(--blue);
  border-radius: 999px;
}

.project-details {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.project-card.hidden {
  display: none;
}

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

  .page-title-row {
    flex-direction: column;
  }
}

@media (max-width: 700px) {
  .project-summary-grid,
  .project-grid,
  .project-toolbar {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .project-toolbar input,
  .project-toolbar select {
    max-width: 100%;
  }
}



.project-actions {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.secondary-btn {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

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

.upload-plan-btn.uploaded {
  background: #16a34a;
  border-color: #16a34a;
  color: white;
}

.upload-plan-btn.uploaded:hover {
  background: #15803d;
  border-color: #15803d;
}

.plan-file-name {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.plan-file-name.attached {
  color: var(--blue);
  font-weight: 700;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 2000;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal-body {
  padding: 22px;
}

.modal-body label {
  display: block;
  margin-bottom: 8px;
}

.modal-help {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 22px;
  border-top: 1px solid var(--border);
}






.project-plan-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.view-plan-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.view-plan-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.plan-viewer-overlay {
  align-items: stretch;
}

.plan-viewer-card {
  width: 95vw;
  height: 90vh;
  background: #ffffff;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.plan-status-toolbar {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.marker-type-btn {
  border: 1px solid var(--border);
  background: white;
  padding: 9px 13px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.marker-type-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.plan-viewer-body {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background: #f1f5f9;
}

.plan-image-wrap {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.plan-image-wrap img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.marker-layer {
  position: absolute;
  inset: 0;
}

.plan-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 3px solid white;
  transform: translate(-50%, -50%);
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.3);
}

.plan-marker.complete { background: #16a34a; }
.plan-marker.in-progress { background: #2563eb; }
.plan-marker.delayed { background: #f59e0b; }
.plan-marker.blocked { background: #dc2626; }

.plan-marker:hover::after {
  content: attr(data-comment);
  position: absolute;
  left: 28px;
  top: -6px;
  width: 240px;
  background: #111827;
  color: white;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 0.8rem;
  z-index: 10;
}


.project-grid {
  align-items: stretch;
}

.project-card {
  display: flex;
  flex-direction: column;
  min-height: 345px;
}

.project-actions {
  margin-top: auto;
}






.marker-type-btn.start-pin-mode {
  border-color: #dc2626;
  color: #dc2626;
}

.marker-type-btn.end-pin-mode {
  border-color: #16a34a;
  color: #16a34a;
}

.marker-type-btn.start-pin-mode.active {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.marker-type-btn.end-pin-mode.active {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.plan-marker.start,
.plan-marker.end {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -100%) rotate(-45deg);
  border: 3px solid #ffffff;
}

.plan-marker.start {
  background: #dc2626;
}

.plan-marker.end {
  background: #16a34a;
}

.plan-marker.end::before {
  content: "⚑";
  position: absolute;
  transform: rotate(45deg);
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  left: 6px;
  top: 3px;
}

.plan-marker.start::before {
  content: "";
  position: absolute;
  transform: rotate(45deg);
  width: 8px;
  height: 8px;
  background: #ffffff;
  border-radius: 50%;
  left: 7px;
  top: 7px;
}








.marker-type-btn.linear-mode {
  border-color: #7c3aed;
  color: #7c3aed;
}

.marker-type-btn.linear-mode.active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #ffffff;
}

.linear-type-options {
  display: flex;
  gap: 14px;
}

.plan-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.linear-point {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid white;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.linear-point.pipe {
  background: #7c3aed;
}

.linear-point.wire {
  background: #f59e0b;
}

.plan-line {
  fill: none;
  stroke-width: .8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plan-line.pipe {
  stroke: #7c3aed;
}

.plan-line.wire {
  stroke: #f59e0b;
}


.plan-marker.delayed::before,
.plan-marker.blocked::before {
  position: absolute;
  color: white;
  font-size: 13px;
  font-weight: 900;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -52%);
}

.plan-marker.delayed::before {
  content: "!";
}

.plan-marker.blocked::before {
  content: "×";
}

.plan-marker.delayed,
.plan-marker.blocked {
  width: 26px;
  height: 26px;
}






.project-log-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 9px 13px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}

.project-log-btn:hover {
  background: #f3f4f6;
}

.project-log-btn span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 0.75rem;
}

.project-log-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 92vw;
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 50px rgba(15, 23, 42, 0.22);
  z-index: 3000;
  transition: right 0.25s ease;
  display: flex;
  flex-direction: column;
}

.project-log-drawer.active {
  right: 0;
}

.project-log-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.project-log-header h3 {
  margin: 0;
}

.project-log-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.project-log-list {
  padding: 16px;
  overflow-y: auto;
  display: grid;
  gap: 12px;
}

.log-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #f9fafb;
}

.log-item strong {
  display: block;
  margin-bottom: 5px;
}

.log-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-log {
  color: var(--muted);
}





.project-title-btn {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.project-title-btn:hover {
  color: var(--blue);
  text-decoration: underline;
}

.project-details-modal {
  max-width: 720px;
}

.project-details-body {
  display: grid;
  gap: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fafb;
}

.detail-row span {
  color: var(--muted);
}

.detail-row strong {
  text-align: right;
}