.projects-page {
  width: 100%;
  min-height: 100%;
  padding: 6px;
  background: var(--surface);
  color: var(--text);
}

.projects-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.projects-page-eyebrow,
.project-dialog-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.projects-page-header h1 {
  margin: 0;
  color: var(--text);
  font-size: 30px;
  line-height: 1.2;
}

.projects-page-header p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.project-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.project-button:focus-visible,
.project-card-action:focus-visible,
.project-dialog-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.project-button-primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 6px 18px var(--primary-muted);
}

.project-button-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}

.project-button-secondary {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.project-button-secondary:hover {
  background: var(--surface-muted);
  border-color: var(--text-muted);
}

.projects-new-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.projects-new-button span {
  font-size: 20px;
  line-height: 1;
}

.projects-header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.projects-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

.projects-hierarchy-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 300px));
  gap: 14px;
  margin-bottom: 18px;
}

.projects-hierarchy-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.projects-hierarchy-filters label > span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.projects-hierarchy-filters select {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
  color: var(--text);
  font: inherit;
}

.projects-hierarchy-filters select:disabled {
  background: var(--surface-muted);
  color: var(--text-subtle);
}

.projects-view-toggle {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-muted);
  padding: 4px;
}

.projects-view-toggle button {
  border-radius: 6px;
  background: transparent;
  padding: 8px 14px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.projects-view-toggle button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.location-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 118px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 18px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
}

.location-card:hover { border-color: var(--primary-muted); box-shadow: var(--shadow-md); }
.location-card-icon { display:grid; width:42px; height:42px; place-items:center; border-radius:10px; background:var(--primary-subtle); color:var(--primary); }
.location-card-icon svg { width:20px; }
.location-card-content { display:flex; min-width:0; flex-direction:column; }
.location-card-content strong { font-size:15px; }
.location-card-content > span { margin-top:5px; color:var(--text-muted); font-size:11px; }
.location-card-content small { margin-top:10px; color:var(--text-subtle); font-size:10px; }
.location-card-arrow { color:var(--text-subtle); font-size:24px; }

.location-dialog-overlay { position:fixed; inset:0; z-index:1200; display:grid; place-items:center; background:rgba(17,19,24,.5); padding:24px; }
.location-dialog { width:min(620px,100%); overflow:hidden; border-radius:14px; background:var(--surface); box-shadow:var(--shadow-shell); }
.location-dialog-header { display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); padding:20px 22px; }
.location-dialog-header span,.location-dialog-detail span,.location-representatives > span { color:var(--text-muted); font-size:9px; font-weight:800; text-transform:uppercase; }
.location-dialog-header h2 { margin-top:4px; font-size:20px; }
.location-dialog-header button { background:transparent; color:var(--text-muted); cursor:pointer; font-size:26px; }
.location-dialog-body { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; padding:22px; }
.location-dialog-detail { display:flex; flex-direction:column; gap:6px; }
.location-representatives { grid-column:1/-1; border-top:1px solid var(--border); padding-top:18px; }
.location-representatives div { display:flex; flex-direction:column; gap:4px; margin-top:10px; }
.location-representatives small { color:var(--text-muted); font-size:10px; }
.location-dialog-actions { display:flex; justify-content:flex-end; gap:10px; border-top:1px solid var(--border); padding:16px 22px; }

.location-form { padding:22px 22px 0; }
.location-form-representatives { margin-top:22px; border-top:1px solid var(--border); padding-top:18px; }
.location-form-representatives select[multiple] { min-height:110px; padding:7px; }
.location-form-representatives small { display:block; margin-top:7px; color:var(--text-muted); font-size:10px; }

.projects-search {
  position: relative;
  display: block;
  width: min(420px, 100%);
}

.projects-search svg {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.projects-search input {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 0 16px 0 44px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.projects-search input::placeholder {
  color: var(--textMuted);
}

.projects-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.projects-count {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.projects-section-header {
  margin-bottom: 18px;
}

.projects-section-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 19px;
}

.projects-section-header p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 20px;
}

.project-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.project-card:hover {
  border-color: var(--primary-muted);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
}

.project-card-title-group {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 12px;
}

.project-card-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  color: var(--primary);
  background: var(--primary-subtle);
  border-radius: 10px;
}

.project-card-icon svg {
  width: 20px;
  height: 20px;
}

.project-card-title-group h3 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
}

.project-card-title-group p {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
}

.project-status {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.project-status-dot {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
}

.project-status-active {
  color: #557347;
  background: #eef4ea;
}

.project-status-planning {
  color: #8b6c2b;
  background: #f7f2e8;
}

.project-status-on-hold {
  color: #a46a2a;
  background: #fbf3e7;
}

.project-status-completed {
  color: #66655f;
  background: #f2f1ed;
}

.project-status-cancelled {
  color: #9f4d49;
  background: #f9eceb;
}

.project-card-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0 22px 20px;
}

.project-detail {
  min-width: 0;
}

.project-detail-label,
.project-card-expanded span,
.project-card-dates span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.project-detail strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 22px 20px;
}

.project-metric {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.project-metric:hover {
  border-color: var(--primary-muted);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.project-metric-wide {
  grid-column: 1 / -1;
}

.project-metric-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  color: var(--primary);
  background: var(--primary-subtle);
  border-radius: 8px;
}

.project-metric-icon svg {
  width: 18px;
  height: 18px;
}

.project-metric strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.project-metric span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.project-card-expanded {
  margin: 0 22px 20px;
  padding: 20px 0 0;
  border-top: 1px solid var(--border);
}

.project-card-expanded p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.project-card-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.project-card-dates strong {
  color: var(--text);
  font-size: 13px;
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 22px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.project-card-action {
  min-height: 36px;
  padding: 0 14px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.project-card-action:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.project-card-action-primary {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.project-card-action-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.projects-empty-state {
  grid-column: 1 / -1;
  padding: 64px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.projects-empty-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  color: var(--primary);
  background: var(--primary-subtle);
  border-radius: 12px;
}

.projects-empty-icon svg {
  width: 25px;
  height: 25px;
}

.projects-empty-state h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.projects-empty-state p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.project-dialog-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 160ms ease;
}

.project-dialog-overlay[hidden] {
  display: none;
}

.project-dialog-overlay.is-open {
  opacity: 1;
}

.project-dialog {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  transform: translateY(10px) scale(0.985);
  transition: transform 160ms ease;
}

.project-dialog-overlay.is-open .project-dialog {
  transform: translateY(0) scale(1);
}

.project-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 20px;
  border-bottom: 1px solid var(--border);
}

.project-dialog-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
}

.project-dialog-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 160ms ease;
}

.project-dialog-close:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.project-form {
  padding: 24px 26px 26px;
}

.project-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.project-form-field {
  display: block;
  min-width: 0;
}

.project-form-field-full {
  grid-column: 1 / -1;
}

.project-form-field[hidden] { display: none; }
.project-progress-field > span { display: flex; align-items: center; justify-content: space-between; }
.project-progress-field > span strong { color: var(--primary); }
.project-progress-field input[type="range"] { min-height: 28px; padding: 0; accent-color: var(--primary); }

.project-form-field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.project-form-field input,
.project-form-field select,
.project-form-field textarea {
  width: 100%;
  box-sizing: border-box;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.project-form-field input,
.project-form-field select {
  min-height: 42px;
  padding: 0 12px;
}

.project-form-field textarea {
  min-height: 105px;
  padding: 11px 12px;
  resize: vertical;
}

.project-form-field input:focus,
.project-form-field select:focus,
.project-form-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.project-form-field [aria-invalid="true"] {
  border-color: var(--danger);
}

.project-form-error {
  display: block;
  min-height: 16px;
  margin-top: 5px;
  color: var(--danger);
  font-size: 11px;
}

.project-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.project-toast {
  position: fixed;
  z-index: 1200;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(380px, calc(100vw - 48px));
  padding: 13px 16px;
  color: #ffffff;
  background: var(--secondary);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.project-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.project-toast-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #ffffff;
  background: var(--success);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.dialog-open {
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 760px) {
  .projects-page {
    padding: 20px;
  }

  .projects-page-header,
  .projects-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .projects-new-button,
  .projects-search {
    width: 100%;
  }

  .projects-new-button {
    justify-content: center;
  }

  .projects-count {
    align-self: flex-end;
  }

  .project-form-grid {
    grid-template-columns: 1fr;
  }

  .project-form-field-full {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  .projects-page {
    padding: 16px;
  }

  .project-card-header {
    flex-direction: column;
  }

  .project-card-details,
  .project-card-dates {
    grid-template-columns: 1fr;
  }

  .project-status {
    align-self: flex-start;
  }

  .project-card-actions {
    flex-wrap: wrap;
  }

  .project-card-action {
    flex: 1;
  }

  .project-dialog-overlay {
    align-items: end;
    padding: 0;
  }

  .project-dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
  }

  .project-dialog-header,
  .project-form {
    padding-left: 20px;
    padding-right: 20px;
  }

  .project-dialog-actions {
    flex-direction: column-reverse;
  }

  .project-dialog-actions .project-button {
    width: 100%;
  }
}
