:root {
  --navy-950: #06172a;
  --navy-900: #071c33;
  --navy-800: #0d2d4e;
  --blue-700: #075fba;
  --blue-600: #0878d1;
  --blue-100: #dbeeff;
  --cyan-500: #21c4dd;
  --green-500: #12b76a;
  --green-100: #dff7e9;
  --amber-500: #f59e0b;
  --red-500: #ef4444;
  --gray-950: #101828;
  --gray-700: #344054;
  --gray-600: #475467;
  --gray-500: #667085;
  --gray-400: #98a2b3;
  --gray-300: #d0d5dd;
  --gray-200: #e4e7ec;
  --gray-100: #f2f4f7;
  --gray-50: #f8fafc;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 12px 32px rgba(16, 24, 40, 0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--gray-950);
  background: var(--gray-50);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1200;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  color: var(--white);
  background:
    radial-gradient(circle at 38% -80%, rgba(33, 196, 221, 0.42), transparent 42%),
    linear-gradient(110deg, var(--navy-950), var(--navy-800));
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 30px rgba(6, 23, 42, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--navy-950);
  background: linear-gradient(145deg, #63e6f5, #22b5ef);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  font-size: 20px;
  font-weight: 900;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.05em;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 2px;
  color: #bdd2e7;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.phase-chip,
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ce294;
  box-shadow: 0 0 0 4px rgba(60, 226, 148, 0.14);
}

.main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 34px 30px 48px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--navy-900);
  font-size: clamp(27px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.page-description {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--gray-500);
  font-size: 14px;
  line-height: 1.6;
}

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 750;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: var(--white);
  background: linear-gradient(135deg, var(--blue-700), var(--blue-600));
  box-shadow: 0 8px 18px rgba(7, 95, 186, 0.24);
}

.btn-primary:hover {
  box-shadow: 0 11px 23px rgba(7, 95, 186, 0.3);
}

.btn-secondary {
  color: var(--gray-700);
  background: var(--white);
  border-color: var(--gray-300);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  min-height: 38px;
  color: var(--gray-600);
  background: transparent;
  border-color: var(--gray-200);
}

.btn-danger {
  color: #b42318;
  background: #fff5f4;
  border-color: #fecdca;
}

.icon-plus {
  font-size: 19px;
  line-height: 1;
}

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

.summary-card {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.summary-card::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -28px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--summary-glow, var(--blue-100));
  opacity: 0.72;
}

.summary-label {
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 650;
}

.summary-number {
  margin-top: 8px;
  color: var(--navy-900);
  font-size: 29px;
  line-height: 1;
  font-weight: 850;
}

.summary-detail {
  margin-top: 9px;
  color: var(--gray-400);
  font-size: 11px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 520px;
}

.search-wrap span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.search-input,
.field-control {
  width: 100%;
  min-height: 44px;
  color: var(--gray-950);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: 9px;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

.search-input {
  padding: 0 14px 0 42px;
}

.field-control {
  padding: 10px 12px;
}

.search-input:focus,
.field-control:focus {
  border-color: #49a4ee;
  box-shadow: 0 0 0 4px rgba(8, 120, 209, 0.12);
}

textarea.field-control {
  min-height: 92px;
  resize: vertical;
}

.toolbar-info {
  color: var(--gray-500);
  font-size: 12px;
  white-space: nowrap;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.project-card {
  overflow: hidden;
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  background: var(--white);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border 0.18s ease;
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: #b7d9f6;
  box-shadow: 0 14px 30px rgba(7, 28, 51, 0.11);
}

.project-map-preview {
  position: relative;
  height: 128px;
  overflow: hidden;
  background:
    linear-gradient(rgba(7, 28, 51, 0.12), rgba(7, 28, 51, 0.16)),
    repeating-linear-gradient(35deg, #cfdae2 0 2px, transparent 2px 34px),
    repeating-linear-gradient(125deg, #d8e5da 0 4px, #edf2eb 4px 38px);
}

.project-map-preview::before,
.project-map-preview::after {
  content: "";
  position: absolute;
  height: 5px;
  border-radius: 999px;
  background: var(--cyan-500);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.project-map-preview::before {
  width: 46%;
  left: 13%;
  top: 54%;
  transform: rotate(-7deg);
}

.project-map-preview::after {
  width: 29%;
  right: 15%;
  top: 42%;
  transform: rotate(22deg);
}

.map-pin {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border: 4px solid var(--white);
  border-radius: 50%;
  background: var(--blue-700);
  box-shadow: 0 3px 10px rgba(7, 28, 51, 0.35);
}

.project-status {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  padding: 6px 9px;
  border-radius: 999px;
  color: #067647;
  background: rgba(236, 253, 243, 0.94);
  border: 1px solid #abefc6;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.project-status.planificacion {
  color: #175cd3;
  background: #eff8ff;
  border-color: #b2ddff;
}

.project-status.archivado {
  color: var(--gray-600);
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.project-card-body {
  padding: 16px;
}

.project-code {
  color: var(--blue-700);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.project-name {
  min-height: 44px;
  margin: 6px 0 4px;
  color: var(--navy-900);
  font-size: 17px;
  line-height: 1.3;
  font-weight: 800;
}

.project-place {
  color: var(--gray-500);
  font-size: 12px;
}

.project-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 15px;
}

.meta-box {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--gray-50);
}

.meta-label {
  color: var(--gray-400);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-value {
  overflow: hidden;
  margin-top: 3px;
  color: var(--gray-700);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.project-actions {
  display: flex;
  gap: 8px;
  margin-top: 15px;
}

.project-actions .btn-primary {
  flex: 1;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 380px;
  padding: 55px 24px;
  text-align: center;
}

.empty-illustration {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid #b2ddff;
  border-radius: 28px;
  color: var(--blue-700);
  background: linear-gradient(145deg, #eff8ff, #dbeeff);
  font-size: 39px;
  transform: rotate(-3deg);
}

.empty-state h2 {
  margin: 0;
  color: var(--navy-900);
  font-size: 20px;
}

.empty-state p {
  max-width: 460px;
  margin: 9px 0 20px;
  color: var(--gray-500);
  font-size: 13px;
  line-height: 1.55;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 15, 28, 0.68);
  backdrop-filter: blur(5px);
}

.modal {
  width: min(1080px, 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  background: var(--white);
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(2, 12, 27, 0.42);
  animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 22px;
  color: var(--white);
  background: linear-gradient(110deg, var(--navy-950), var(--navy-800));
}

.modal-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.modal-subtitle {
  margin-top: 4px;
  color: #bfd3e7;
  font-size: 11px;
}

.modal-close {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
  font-size: 19px;
}

.modal-content {
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  padding: 22px;
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(420px, 1.05fr);
  gap: 22px;
}

.form-section {
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 850;
}

.section-number {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--white);
  background: var(--blue-700);
  font-size: 11px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.field {
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--gray-600);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.required {
  color: var(--red-500);
}

.field-help {
  margin: 5px 0 0;
  color: var(--gray-400);
  font-size: 10px;
  line-height: 1.4;
}

.location-box {
  padding: 14px;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  background: var(--gray-50);
}

.coordinates-row {
  display: grid;
  grid-template-columns: 1fr 1fr 90px;
  gap: 9px;
  margin-bottom: 10px;
}

#locationMap {
  width: 100%;
  height: 335px;
  overflow: hidden;
  border: 1px solid var(--gray-300);
  border-radius: 11px;
  background: #dfe8ed;
}

.map-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 9px;
  color: var(--gray-500);
  font-size: 10px;
}

.coordinate-badge {
  padding: 5px 8px;
  border-radius: 7px;
  color: #175cd3;
  background: #eff8ff;
  font-weight: 750;
  white-space: nowrap;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 22px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.footer-note {
  color: var(--gray-500);
  font-size: 10px;
}

.footer-actions {
  display: flex;
  gap: 10px;
}

.toast-stack {
  position: fixed;
  z-index: 4000;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 290px;
  max-width: 380px;
  padding: 13px 15px;
  color: var(--white);
  background: var(--navy-900);
  border-left: 4px solid var(--green-500);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  animation: toast-in 0.2s ease-out;
}

.toast.error {
  border-left-color: var(--red-500);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

.workspace-screen {
  min-height: calc(100vh - 72px);
  background: #e8eef2;
}

.workspace-toolbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.workspace-title {
  flex: 1;
  min-width: 0;
}

.workspace-title strong,
.workspace-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-title strong {
  color: var(--navy-900);
  font-size: 14px;
}

.workspace-title span {
  margin-top: 2px;
  color: var(--gray-500);
  font-size: 10px;
}

.workspace-body {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: calc(100vh - 136px);
}

.layers-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
}

.layers-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 16px 14px;
  border-bottom: 1px solid var(--gray-200);
}

.layers-heading h3 {
  margin: 0;
  color: var(--navy-900);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.layers-heading span {
  display: block;
  margin-top: 4px;
  color: var(--gray-500);
  font-size: 10px;
}

.layer-add-shortcut {
  width: 34px;
  height: 34px;
  border: 1px solid #b2ddff;
  border-radius: 9px;
  color: #026aa2;
  background: #eff8ff;
  font-size: 19px;
  cursor: pointer;
}

.layers-panel {
  flex: 1;
  overflow: auto;
  padding: 12px;
}

.layers-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 12px;
  color: var(--gray-500);
  text-align: center;
}

.layers-empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 14px;
  color: #0874c9;
  background: #eaf4ff;
  font-size: 23px;
}

.layers-empty strong {
  color: var(--navy-900);
  font-size: 13px;
}

.layers-empty span {
  margin: 7px 0 14px;
  font-size: 10px;
  line-height: 1.45;
}

.btn-small {
  min-height: 34px;
  padding: 8px 12px;
  font-size: 10px;
}

.layer-group + .layer-group {
  margin-top: 16px;
}

.layer-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px 7px;
  color: var(--gray-600);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.layer-group-title b {
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  color: #175cd3;
  background: #eff8ff;
  font-size: 9px;
}

.layer-row {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 56px;
  margin-bottom: 7px;
  padding: 8px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: var(--white);
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.layer-row:hover {
  border-color: #b2ddff;
}

.layer-row.is-hidden {
  opacity: 0.48;
}

.layer-swatch {
  width: 8px;
  height: 34px;
  border-radius: 6px;
}

.layer-main {
  min-width: 0;
}

.layer-main strong,
.layer-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-main strong {
  color: var(--navy-900);
  font-size: 11px;
}

.layer-main span {
  margin-top: 4px;
  color: var(--gray-500);
  font-size: 8px;
}

.layer-buttons {
  display: grid;
  grid-template-columns: repeat(2, 24px);
  gap: 3px;
}

.layer-buttons button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--gray-600);
  background: var(--gray-50);
  cursor: pointer;
  font-size: 11px;
}

.layer-buttons button:hover {
  color: #0874c9;
  background: #eaf4ff;
}

.phase-note {
  margin: 0 12px 12px;
  padding: 10px;
  border: 1px dashed #b2ddff;
  border-radius: 9px;
  color: #175cd3;
  background: #f5faff;
  font-size: 9px;
  line-height: 1.45;
}

.modal-compact {
  max-width: 720px;
}

.layer-modal-content {
  max-height: calc(100vh - 220px);
}

.color-control {
  height: 44px;
  padding: 4px;
  cursor: pointer;
}

#projectMap {
  width: 100%;
  height: calc(100vh - 136px);
  min-height: 520px;
  background: #dfe8ed;
}

@media (max-width: 1050px) {
  .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-layout {
    grid-template-columns: 1fr;
  }

  #locationMap {
    height: 300px;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: 64px;
    padding: 0 16px;
  }

  .phase-chip,
  .user-chip {
    display: none;
  }

  .main {
    padding: 24px 14px 38px;
  }

  .page-heading,
  .panel-toolbar,
  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

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

  .projects-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .form-grid,
  .coordinates-row {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 0;
  }

  .modal {
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
  }

  .modal-content {
    max-height: calc(100vh - 162px);
    padding: 16px;
  }

  .footer-actions,
  .footer-actions .btn {
    width: 100%;
  }

  .workspace-body {
    grid-template-columns: 1fr;
  }

  .layers-sidebar {
    display: none;
  }
}
