/* Actus Designer — identidad Actus energy (Behind, 2025).
   Tipografía corporativa RF Dewi Extended si está instalada; si no, Archivo expandida. */
:root {
  --eco: #021E1C;
  --eco-soft: #053331;
  --eco-line: #0d4a46;
  --orange: #FF3600;
  --yellow: #D9FF40;
  --gray: #D1D0C3;
  --white: #EAEAEA;
  --black: #1E1E1E;
  --muted: #8fa39f;
  --font: "RF Dewi Extended", "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --side: 380px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-stretch: 115%;
  font-size: 14px;
  line-height: 1.45;
  background: var(--eco);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---------- estructura ---------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; height: 100%; }
.side {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--eco); border-right: 1px solid var(--eco-line);
}
.side-scroll { flex: 1; overflow-y: auto; padding: 0 20px 24px; }
.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0a1413; }

/* ---------- cabecera ---------- */
.brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--eco-line);
}
.wordmark { display: flex; align-items: baseline; gap: 8px; text-decoration: none; }
.wordmark b { color: var(--orange); font-weight: 650; font-size: 19px; letter-spacing: -0.01em; font-stretch: 125%; }
.wordmark span { color: var(--white); font-weight: 300; font-size: 19px; font-stretch: 125%; }
.wordmark i { font-style: normal; color: var(--gray); font-size: 12px; font-weight: 400; margin-left: 4px; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--gray); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 12px; }
.link-btn:hover { color: var(--white); }

/* ---------- secciones ---------- */
.section { padding: 18px 0 4px; border-bottom: 1px solid var(--eco-line); }
.section:last-child { border-bottom: 0; }
.section h2 {
  margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--gray);
  display: flex; justify-content: space-between; align-items: center;
}
.section h2 small { font-weight: 400; color: var(--muted); font-size: 12px; }

.edit-field {
  display: flex; align-items: center; gap: 8px; cursor: text;
  border: 1px solid var(--eco-line); border-radius: 6px; padding: 6px 10px; margin-bottom: 8px;
  background: var(--eco-soft);
}
.edit-field:hover { border-color: var(--muted); }
.edit-field:focus-within { border-color: var(--yellow); }
.edit-field input { flex: 1; min-width: 0; background: transparent; border: 0; padding: 0; outline: none; }
.edit-field svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.edit-field:focus-within svg { color: var(--yellow); }
.project-name { font-size: 18px; font-weight: 600; font-stretch: 120%; color: var(--white); }
.project-name::placeholder, .project-client::placeholder { color: var(--muted); font-weight: 400; }
.project-client { color: var(--gray); }
.project-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 12px; }
.save-state { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.save-state.dirty { color: var(--orange); }

/* ---------- campos ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .loc input {
  width: 100%; background: var(--eco-soft); border: 1px solid var(--eco-line);
  border-radius: 6px; padding: 8px 10px; color: var(--white);
}
.field input:focus, .field select:focus, .loc input:focus { border-color: var(--gray); outline: none; }
.with-unit { position: relative; }
.with-unit em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 12px; pointer-events: none; }
.with-unit input { padding-right: 34px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }
.loc { display: flex; gap: 8px; margin-bottom: 8px; }
.loc input { flex: 1; min-width: 0; }
.loc-msg { font-size: 12px; color: var(--muted); margin: 0 0 12px; min-height: 1em; }
.loc-msg.err { color: var(--orange); }

.seg { display: flex; border: 1px solid var(--eco-line); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; background: var(--eco-soft); border: 0; padding: 8px 6px; cursor: pointer; color: var(--gray); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--eco-line); }
.seg button[aria-pressed="true"] { background: var(--gray); color: var(--eco); font-weight: 600; }

/* ---------- botones ---------- */
.btn {
  border: 1px solid var(--gray); background: transparent; color: var(--white);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--eco-soft); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn.danger { border-color: transparent; color: var(--orange); padding-left: 0; padding-right: 0; }
.btn.danger:hover { background: none; text-decoration: underline; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- listas ---------- */
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list li {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.list li:hover { background: var(--eco-soft); }
.list li.on { border-color: var(--yellow); background: var(--eco-soft); }
.list li .k { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list li .k span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .v { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.swatch { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.swatch.zone { border: 2px solid var(--yellow); }
.swatch.obstaculo { background: var(--orange); }
.swatch.sombra { background: #000; border: 1px dashed var(--gray); }
.empty { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.detail { background: var(--eco-soft); border-radius: 8px; padding: 14px; margin: 0 0 16px; }
.detail-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.detail-head input { flex: 1; background: transparent; border: 0; border-bottom: 1px solid var(--eco-line); padding: 4px 0; font-weight: 600; font-size: 15px; color: var(--white); }
.detail-head input:focus { outline: none; border-color: var(--gray); }
.detail .field input, .detail .field select { background: var(--eco); }
.detail .seg button { background: var(--eco); }
.detail .seg button[aria-pressed="true"] { background: var(--gray); }
.stats { border-top: 1px solid var(--eco-line); margin-top: 6px; padding-top: 10px; font-size: 13px; }
.stats div { display: flex; justify-content: space-between; padding: 2px 0; font-variant-numeric: tabular-nums; }
.stats div span:first-child { color: var(--muted); }

/* ---------- total ---------- */
.total { border-top: 1px solid var(--eco-line); padding: 16px 20px 18px; background: var(--eco); }
.total .big { font-size: 46px; line-height: 1; font-weight: 600; font-stretch: 125%; color: var(--yellow); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.total .big small { font-size: 18px; font-weight: 400; margin-left: 6px; color: var(--yellow); letter-spacing: 0; }
.total .sub { margin-top: 6px; color: var(--gray); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- barra del mapa ---------- */
.toolbar {
  position: absolute; z-index: 1000; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 5px; border-radius: 10px;
  background: rgba(2, 30, 28, .92); border: 1px solid var(--eco-line);
  backdrop-filter: blur(6px); max-width: calc(100% - 24px); overflow-x: auto;
}
.toolbar .sep { width: 1px; background: var(--eco-line); margin: 4px 4px; flex: none; }
.tool {
  background: none; border: 0; border-radius: 7px; padding: 7px 11px; cursor: pointer;
  color: var(--white); font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 7px;
}
.tool:hover { background: var(--eco-soft); }
.tool[aria-pressed="true"] { background: var(--white); color: var(--eco); }
.tool .dot { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.tool .dot.zone { border: 2px solid var(--yellow); }
.tool .dot.obstaculo { background: var(--orange); }
.tool .dot.sombra { background: #000; border: 1px dashed var(--gray); }
.tool .dot.ridge { height: 0; border-top: 2px dashed var(--white); border-radius: 0; width: 14px; }
.tool[aria-pressed="true"] .dot.ridge { border-top-color: var(--eco); }
.tool .dot.quitar { border: 2px solid var(--white); position: relative; }
.tool[aria-pressed="true"] .dot.quitar { border-color: var(--eco); }

.layers {
  position: absolute; z-index: 1000; right: 12px; bottom: 28px;
  background: rgba(2, 30, 28, .92); border: 1px solid var(--eco-line); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; display: grid; gap: 6px;
}
.layers label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.layers input { accent-color: var(--yellow); }

.map-hint {
  position: absolute; z-index: 1000; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--white); color: var(--eco); padding: 8px 14px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); display: none; white-space: nowrap;
}
.map-hint.show { display: block; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.55); display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px; }
.modal.open { display: flex; }
.modal-box { background: var(--eco); border: 1px solid var(--eco-line); border-radius: 12px; width: min(760px, 100%); max-height: 80vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--eco-line); gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 600; font-stretch: 120%; }
.modal-head input { flex: 1; max-width: 260px; background: var(--eco-soft); border: 1px solid var(--eco-line); border-radius: 6px; padding: 7px 10px; }
.modal-body { overflow-y: auto; padding: 6px 8px 12px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ptable th { text-align: left; font-weight: 400; color: var(--muted); padding: 8px 12px; font-size: 12px; }
.ptable td { padding: 10px 12px; border-top: 1px solid var(--eco-line); font-variant-numeric: tabular-nums; }
.ptable tbody tr { cursor: pointer; }
.ptable tbody tr:hover td { background: var(--eco-soft); }
.ptable td.num, .ptable th.num { text-align: right; }

.toast { position: fixed; z-index: 3000; left: 50%; top: 16px; transform: translateX(-50%); background: var(--white); color: var(--eco); padding: 9px 16px; border-radius: 999px; font-size: 13px; display: none; }
.toast.show { display: block; }
.toast.err { background: var(--orange); color: #fff; }

/* ---------- Leaflet ---------- */
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; background: rgba(2,30,28,.7) !important; color: var(--gray); }
.leaflet-control-attribution a { color: var(--gray); }
.leaflet-control-scale-line { background: rgba(2,30,28,.75); color: var(--white); border-color: var(--white); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { padding: 48px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--eco-line); }
.login-art h1 { font-size: clamp(40px, 6vw, 84px); line-height: .95; font-weight: 600; font-stretch: 125%; letter-spacing: -0.03em; margin: 0; color: var(--white); }
.login-art p { color: var(--gray); max-width: 42ch; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.login-form form { width: min(340px, 100%); }
.login-form h2 { font-size: 18px; font-weight: 600; margin: 0 0 20px; font-stretch: 120%; }
.login-form .btn { width: 100%; padding: 10px; margin-top: 6px; }
.login-err { color: var(--orange); font-size: 13px; min-height: 1.2em; margin: 4px 0 0; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 58vh auto; }
  .map-wrap { grid-row: 1; }
  .side { grid-row: 2; border-right: 0; border-top: 1px solid var(--eco-line); }
  .login { grid-template-columns: 1fr; }
  .login-art { border-right: 0; border-bottom: 1px solid var(--eco-line); padding: 32px 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
