:root {
  --bg:     #f0f2f5;
  --card:   #ffffff;
  --border: #dde1e8;
  --acc:    #2e7d32;
  --acc2:   #1b5e20;
  --text:   #2c3e50;
  --muted:  #7a8a9e;
  --red:    #e74c3c;
  --orange: #e07a2f;
  --orange2:#c9671a;
  --r:      8px;
  --sh:     0 2px 8px rgba(0,0,0,.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

header { background: var(--acc); color: #fff; padding: 0; }
.hdr-top { display:flex; justify-content:space-between; align-items:center; padding:12px 24px 10px; gap:16px; flex-wrap:wrap; }
.hdr-brand { font-size:16px; font-weight:700; }
.hdr-actions { display:flex; align-items:center; gap:16px; flex-shrink:0; }
.hdr-info { display:flex; justify-content:space-between; align-items:center; gap:16px; }
.hdr-info-text { flex:1; }
.hdr-info .wa-link { display:flex; align-items:center; flex-shrink:0; }
.hdr-info .wa-link img { width:80px; height:27px; display:block; }
.hdr-nav { background:#fff; border-bottom:1px solid var(--border); padding:10px 24px; }
.nav-toggle { display:flex; border:1px solid var(--border); border-radius:6px; overflow:hidden; max-width:680px; }
.nav-toggle a, .nav-toggle span { flex:1; padding:9px 16px; text-align:center;
  font-size:13px; font-weight:600; line-height:1.35; text-decoration:none;
  border-right:1px solid var(--border); transition:background .15s, color .15s; }
.nav-toggle a:last-child, .nav-toggle span:last-child { border-right:none; }
.nav-toggle .active { background:var(--acc); color:#fff; cursor:default; }
/* FV: inactive = verd fluix */
.nav-toggle a { background:#dcedc8; color:#2e7d32; }
.nav-toggle a:hover { background:#c5e1a5; }
.hdr-info { background:#f4f6f9; border-bottom:1px solid var(--border); padding:8px 24px; font-size:11px; line-height:1.6; color:var(--muted); }
.hdr-info a { color:var(--acc); font-weight:700; text-decoration:underline; }
.hdr-info strong { color:var(--text); }
@media (max-width:700px) {
  .hdr-nav { padding:10px 12px; }
  .nav-toggle { flex-direction:column; max-width:none; }
  .nav-toggle a, .nav-toggle span { border-right:none; border-bottom:1px solid var(--border); }
  .nav-toggle a:last-child, .nav-toggle span:last-child { border-bottom:none; }
  .hdr-info { padding:8px 12px; }
}

main { max-width: 960px; margin: 20px auto; padding: 0 14px 40px;
       display: flex; flex-direction: column; gap: 14px; }

.card { background: var(--card); border: 1px solid var(--border);
        border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.card-hdr { background: #f4f6f9; border-bottom: 1px solid var(--border); padding: 9px 16px; }
.card-hdr h2 { font-size: 11px; font-weight: 700; text-transform: uppercase;
               letter-spacing: .6px; color: var(--muted); }
.card-body { padding: 16px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }
.f   { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 140px; }
.f.w { min-width: 280px; }
.f.n { min-width: 110px; max-width: 180px; }
.f.sm{ min-width: 82px;  max-width: 135px; }
.f.xs{ min-width: 70px;  max-width: 100px; }
.f.full { flex: 1 1 100%; }

.lbl { font-size: 10px; font-weight: 700; text-transform: uppercase;
       letter-spacing: .4px; color: var(--muted); }
.badge-auto { background: #e8f5e9; color: var(--acc); border: 1px solid #a5d6a7;
              border-radius: 3px; padding: 0 5px; font-size: 9px; font-weight: 700;
              margin-left: 4px; vertical-align: middle; }
.badge-calc { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9;
              border-radius: 3px; padding: 0 5px; font-size: 9px; font-weight: 700;
              margin-left: 4px; vertical-align: middle; }

input[type=text], input[type=number], input[type=email], input[type=tel], select {
  background: #f8f9fb; border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 9px; font-size: 13px; color: var(--text); width: 100%;
  font-family: inherit; transition: border-color .15s; }
input:focus, select:focus { outline: none; border-color: var(--acc); background: #fff; }
input::placeholder { color: #bbb; }
input.invalid { border-color: var(--red); background: #fff5f5; }
input[readonly] { background: #f0f0f0; color: #666; cursor: default; }

.toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.toggle input[type=radio] { display: none; }
.toggle label { flex: 1; padding: 7px 10px; text-align: center; cursor: pointer;
                font-size: 12px; font-weight: 500; color: var(--muted);
                border-right: 1px solid var(--border); transition: all .15s; white-space: nowrap; }
.toggle label:last-of-type { border-right: none; }
.toggle input[type=radio]:checked + label { background: var(--acc); color: #fff; }

.subsec { border: 1px solid var(--border); border-radius: 6px;
          overflow: hidden; margin-top: 12px; }
.subsec-hdr { background: #f9fafc; border-bottom: 1px solid var(--border);
              padding: 6px 12px; font-size: 10px; font-weight: 700;
              text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.subsec-body { padding: 12px; }
.str-block { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.str-block-hdr { background: #f0f7f0; border-bottom: 1px solid #c8e6c9; padding: 7px 12px; display: flex; justify-content: space-between; align-items: center; }
.str-block-hdr .str-num { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--acc); }
.str-block-body { padding: 12px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { background: #f4f6f9; border: 1px solid var(--border); padding: 5px 7px;
          font-size: 10px; font-weight: 700; color: var(--muted);
          text-transform: uppercase; letter-spacing: .3px; text-align: center; white-space: nowrap; }
.tbl td { border: 1px solid var(--border); padding: 2px 3px; vertical-align: middle; }
.tbl tr:nth-child(even) td { background: #fafbfd; }
.tbl tr:hover td { background: #f0f7ff; }
.tbl td input, .tbl td select { border: none; background: transparent;
  padding: 4px 5px; font-size: 12px; width: 100%; min-width: 0; }
.tbl td input:focus, .tbl td select:focus {
  background: #e8f4ff; outline: 1px solid var(--acc); border-radius: 3px; }
.tbl td.calc-cell { background: #f0fff4; color: #1b5e20; font-weight: 600;
                    text-align: center; font-size: 11px; padding: 4px 5px; }

.btn-del { background: none; border: none; cursor: pointer; color: #bbb;
           font-size: 15px; padding: 2px 5px; border-radius: 3px; line-height: 1; }
.btn-del:hover { color: var(--red); background: #fef2f2; }
.btn-add { display: flex; align-items: center; justify-content: center; gap: 6px;
           width: 100%; margin-top: 7px; background: none;
           border: 1px dashed var(--border); border-radius: 6px;
           padding: 7px; font-size: 12px; color: var(--acc); cursor: pointer; transition: all .15s; }
.btn-add:hover { background: #f0fff4; border-color: var(--acc); }

.btn-lookup { background: none; border: 1px solid var(--border); border-radius: 6px;
              padding: 7px 10px; font-size: 12px; color: var(--acc); cursor: pointer;
              white-space: nowrap; transition: all .15s; height: 36px; align-self: flex-end; }
.btn-lookup:hover { background: #f0fff4; border-color: var(--acc); }

.info-box { background: #e8f5e9; border: 1px solid #a5d6a7; border-radius: 6px;
            padding: 8px 12px; font-size: 11px; color: #1b5e20; margin-top: 8px; }
.warn-box { background: #fff3e0; border: 1px solid #ffcc80; border-radius: 6px;
            padding: 8px 12px; font-size: 11px; color: #e65100; margin-top: 8px; }

.submit-area { display: flex; justify-content: flex-end; gap: 10px; align-items: stretch; padding: 4px 0; }
@media (max-width: 600px) {
  .submit-area { flex-wrap: wrap; }
  .submit-area .btn-load { order: -1; width: 100%; }
  .submit-area .btn-dl:not(.btn-load) { flex: 1 1 0; min-width: 0; }
}
.btn-dl { background: var(--acc); color: #fff; border: none; border-radius: 7px;
          padding: 10px 24px; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-dl:hover { background: var(--acc2); }
.hint { font-size: 10px; color: var(--muted); margin-top: 2px; }
.req  { color: var(--red); }
.hidden { display: none !important; }

.specs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr));
              gap: 6px; background: #f0fff4; border: 1px solid #a5d6a7;
              border-radius: 6px; padding: 10px; margin-top: 8px; }
.spec-item { font-size: 11px; }
.spec-item .spec-lbl { color: var(--muted); font-weight: 600; display: block; font-size: 10px; }
.spec-item .spec-val { color: #1b5e20; font-weight: 700; }

.catastro-results { display: none; background: #fff; border: 1px solid var(--border);
                    border-radius: 6px; padding: 10px; margin-top: 6px; max-height: 200px; overflow-y: auto; }
.catastro-item { padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 12px;
                 border-bottom: 1px solid var(--border); }
.catastro-item:last-child { border-bottom: none; }
.catastro-item:hover { background: #f0fff4; color: var(--acc); }
.catastro-ref { font-weight: 700; font-family: monospace; }

.muni-wrap { position: relative; }
.muni-results { display: none; position: absolute; z-index: 200; background: #fff;
                border: 1px solid var(--border); border-radius: 6px; margin-top: 2px;
                max-height: 260px; overflow-y: auto; width: 100%; box-shadow: var(--sh); }
.muni-item { padding: 6px 10px; cursor: pointer; font-size: 12px;
             border-bottom: 1px solid #f0f2f5; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.muni-item:last-child { border-bottom: none; }
.muni-item:hover { background: #f0fff4; }
.muni-nm { font-weight: 600; color: var(--text); }
.muni-comarca { color: var(--muted); font-size: 10px; white-space: nowrap; }
.muni-loading { padding: 10px; font-size: 12px; color: var(--muted); text-align: center; }

/* ── Inclination widget ── */
.inclinacio-map {
  position:relative; width:160px; height:160px; border-radius:8px;
  overflow:hidden; border:2px solid var(--border); cursor:crosshair;
  background:linear-gradient(160deg,#2c3e50 0%,#3d5a73 100%);
  box-shadow:0 1px 4px rgba(0,0,0,.15);
}
.inclinacio-map:active { cursor:crosshair; }
.inclinacio-svg { width:100%; height:100%; position:absolute; top:0; left:0; }

/* ── Compass widget ── */
.compass-wrap { display:flex; flex-direction:column; align-items:center; gap:6px; user-select:none; }
.compass-map {
  position:relative; width:160px; height:160px; border-radius:50%;
  overflow:hidden; border:2px solid var(--border); cursor:grab;
  background:#dde1e8 center/cover no-repeat;
  box-shadow:0 1px 4px rgba(0,0,0,.15);
}
.compass-map:active { cursor:grabbing; }
.compass-svg { width:100%; height:100%; position:absolute; top:0; left:0; }
.compass-readout { display:flex; align-items:center; gap:5px; }
.compass-deg-inp {
  width:58px !important; text-align:center;
  padding:4px 6px !important; font-size:12px !important;
}
.compass-unit { color:var(--muted); font-size:11px; }
.compass-ori-lbl { font-size:11px; font-weight:700; color:var(--acc); min-width:90px; }

/* ── Layout editor ── */
.layout-editor-wrap { margin-top:8px; }
.layout-editor { padding:10px; background:#f8faf8; border:1px solid #c8e6c9;
  border-radius:6px; min-height:80px; overflow:auto; }
.layout-editor-canvas { position:relative; }
.mod-btn { background:rgba(255,255,255,.85); border:1px solid rgba(0,0,0,.15); border-radius:3px;
  font-size:10px; cursor:pointer; padding:2px 4px; line-height:1.3; color:#333; }
.mod-btn:hover { background:#fff; }
.layout-dims { font-size:10px; color:var(--muted); margin-top:4px; font-style:italic; min-height:14px; }

/* Ghost outlines: always visible, pointer-events:none (never block mouse) */
.layout-ghost-outline {
  position:absolute; box-sizing:border-box; border-radius:3px; pointer-events:none;
  background:rgba(144,238,144,0.08); border:1.5px dashed rgba(76,175,80,0.22);
  transition:background .1s, border-color .1s, opacity .1s;
}
.layout-ghost-outline--active {
  background:rgba(200,230,200,0.65) !important;
  border:2px solid #4caf50 !important;
}
.layout-ghost-outline--dim { opacity:0.05 !important; }

/* Ghost badges: the actual interactive targets, always non-overlapping */
.layout-ghost-badge {
  position:absolute; box-sizing:border-box; border-radius:3px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  font-size:10px; font-weight:700; user-select:none; z-index:10;
  background:rgba(200,230,200,0.55); border:1.5px solid rgba(76,175,80,0.5);
  color:rgba(46,125,50,0.75);
  transition:background .08s, color .08s, border-color .08s, opacity .1s;
}
.layout-ghost-badge:hover {
  background:rgba(200,230,200,0.97); border-color:#2e7d32; color:#1b5e20; z-index:15;
}
.layout-ghost-badge--dim { opacity:0.12; pointer-events:none; }

/* ── Inclinació + Azimut same-row layout ── */
.incl-col { flex: 1; max-width: 34%; }
.az-col   { flex: 2; }
@media (max-width: 620px) {
  .incl-col, .az-col { flex: 1 1 100%; max-width: 100%; }
}

/* ── Azimut arrow overlay on Leaflet map ── */
.az-arrow-overlay {
  position: absolute;
  transform: translateX(-50%);
  pointer-events: none; z-index: 500;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.az-arrow-svg {
  pointer-events: none;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,0.8));
  transform-origin: 50% 50%;
}
.az-arrow-label {
  background: rgba(0,0,0,0.65); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
  pointer-events: none; white-space: nowrap;
}

/* ── Orientation Leaflet map ── */
.ori-map-outer { display:flex; flex-direction:column; gap:4px; }
.ori-map-container { height:400px; border-radius:8px; overflow:hidden;
  border:2px solid var(--border); }
.ori-map-container .leaflet-container { height:100%; }
.panel-center-marker { width:10px; height:10px; background:#2e7d32; border-radius:50%;
  border:2px solid #fff; box-shadow:0 0 4px rgba(0,0,0,.4); cursor:grab; }

/* ── Auth-state submit buttons ── */
.btn-google { display:flex; align-items:center; gap:9px; background:#fff; color:#3c4043;
              border:1px solid #dadce0; border-radius:7px; padding:10px 20px;
              font-size:14px; font-weight:600; cursor:pointer; transition:box-shadow .15s; align-self:stretch; }
.btn-google:hover { box-shadow:0 1px 6px rgba(0,0,0,.2); }
.btn-google svg { flex-shrink:0; }
.btn-wa { background:#25d366 !important; }
.btn-wa:hover { background:#1da851 !important; }
.contact-msg { display:flex; align-items:center; font-size:12px; color:var(--muted);
               text-align:right; line-height:1.4; padding-right:4px; }
/* Progress */
.progress-wrap { width:100%; display:flex; flex-direction:column; gap:10px; padding:12px 0; }
.progress-label { font-size:14px; font-weight:600; color:#2c3e50; text-align:center; }
.progress-bar-bg { width:100%; height:16px; background:#ccc; border-radius:8px; overflow:hidden; box-shadow:inset 0 1px 3px rgba(0,0,0,.2); }
.progress-bar-fill { height:100%; width:0%; background:linear-gradient(90deg, #1565c0, #42a5f5);
                     border-radius:8px; transition:width 0.25s ease-out; }
