@font-face {
  font-family: 'Montserrat';
  src: url('assets/Montserrat-Bold.woff2') format('woff2');
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('assets/Inter-Regular.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #07225F;
  --navy-deep: #050D22;
  --navy-panel: #081533;
  --navy-card: #0E1F47;
  --navy-border: rgba(154, 179, 232, 0.2);
  --gold: #E5C00B;
  --gold-hover: #F5D227;
  --gold-soft: rgba(229, 192, 11, 0.16);
  --text: #F2F5FC;
  --text-muted: #A9B9D9;
  --ink-dark: #1A2744;
  --ink-muted: #4A5875;
  --radius: 10px;
  --shadow-sheet: 0 22px 60px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.08);

  /* Variables dinámicas de la lámina */
  --map-header-bg: #07225F;
  --map-header-accent: #E5C00B;
  --map-title-size: 15px;
  --map-subtitle-size: 10px;
  --map-north-primary: #07225F;
  --map-north-bg: #FFFFFF;
  --map-scale-primary: #07225F;
  --map-scale-bg: #FFFFFF;
  --map-scale-ink: #07225F;
  --map-legend-primary: #07225F;
  --map-legend-accent: #E5C00B;
  --map-legend-bg: #FFFFFF;
  --map-legend-ink: #1F2E4E;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--navy-deep);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13.5px;
  overflow: hidden;
}

/* TOPBAR */
.topbar {
  height: 56px;
  background: linear-gradient(90deg, #051640 0%, var(--navy) 55%, #0A2A70 100%);
  border-bottom: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 30;
  position: relative;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { height: 28px; width: auto; display: block; flex-shrink: 0; }
.brand-sep { width: 1px; height: 24px; background: rgba(255, 255, 255, 0.24); }
.brand-text h1 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: 14.5px; letter-spacing: 0.02em; color: #FFFFFF; line-height: 1.15; }
.brand-text span { display: block; font-size: 11px; color: #C9D4EC; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; padding: 7px 12px;
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-gold { background: var(--gold); color: #071947; box-shadow: 0 4px 14px rgba(229, 192, 11, 0.28); }
.btn-gold:hover:not(:disabled) { background: var(--gold-hover); }
.btn-ghost { background: rgba(255, 255, 255, 0.08); color: #F2F5FC; border-color: rgba(255, 255, 255, 0.14); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); border-color: rgba(229, 192, 11, 0.55); }
.btn-outline-gold { background: var(--gold-soft); color: var(--gold); border-color: rgba(229, 192, 11, 0.5); }
.btn-outline-gold:hover { background: rgba(229, 192, 11, 0.25); }
.btn-outline-light { background: rgba(255, 255, 255, 0.06); color: #FFFFFF; border-color: rgba(201, 212, 236, 0.35); }
.btn-outline-light:hover:not(:disabled) { background: rgba(255, 255, 255, 0.13); border-color: var(--gold); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-lg { width: 100%; flex-direction: column; align-items: flex-start; padding: 12px 14px; gap: 2px; }
.btn-lg small { font-weight: 400; font-size: 11px; opacity: 0.82; }

/* WORKSPACE */
.workspace {
  display: grid;
  grid-template-columns: 368px 1fr;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.studio-panel {
  background: var(--navy-panel);
  border-right: 1px solid var(--navy-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  z-index: 15;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #061028;
  border-bottom: 1px solid var(--navy-border);
  padding: 5px;
  gap: 4px;
}

.tab-btn {
  background: transparent; color: var(--text-muted); border: 1px solid transparent;
  border-radius: 6px; padding: 7px 3px; font-family: 'Montserrat', sans-serif;
  font-size: 10.5px; cursor: pointer; text-align: center;
}
.tab-btn:hover { color: #FFFFFF; background: rgba(255, 255, 255, 0.05); }
.tab-btn.active { background: var(--navy); color: #FFFFFF; border-color: rgba(229, 192, 11, 0.7); }

.tab-pane { display: none; flex: 1; overflow-y: auto; padding: 13px; }
.tab-pane.active { display: block; }
.tab-pane::-webkit-scrollbar { width: 6px; }
.tab-pane::-webkit-scrollbar-thumb { background: rgba(169, 185, 217, 0.25); border-radius: 99px; }

/* DROPZONE */
.dropzone {
  border: 1.5px dashed rgba(229, 192, 11, 0.55);
  background: linear-gradient(180deg, rgba(229, 192, 11, 0.08), rgba(7, 34, 95, 0.35));
  border-radius: var(--radius); padding: 14px 10px; text-align: center;
  cursor: pointer; margin-bottom: 13px;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--gold); background: rgba(229, 192, 11, 0.16); }
.dropzone-icon { font-size: 22px; color: var(--gold); line-height: 1; margin-bottom: 4px; }
.dropzone strong { display: block; font-size: 12.5px; color: #FFFFFF; margin-bottom: 2px; }
.dropzone span { display: block; font-size: 11px; color: var(--text-muted); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.section-head h2 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: #C9D4EC; }
.badge { background: rgba(229, 192, 11, 0.2); color: var(--gold); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.divider { height: 1px; background: var(--navy-border); margin: 13px 0; }

/* LAYERS */
.layer-list { display: flex; flex-direction: column; gap: 8px; }
.empty-layers { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--navy-border); border-radius: 8px; padding: 13px; text-align: center; }
.empty-layers p { margin: 0 0 9px; color: var(--text-muted); font-size: 12px; }
.layer-card { background: var(--navy-card); border: 1px solid var(--navy-border); border-radius: 9px; padding: 9px; display: flex; flex-direction: column; gap: 7px; }
.layer-card-top { display: flex; align-items: center; gap: 6px; }
.layer-card-top input[type="checkbox"] { accent-color: var(--gold); width: 15px; height: 15px; cursor: pointer; }
.layer-name-input { flex: 1; min-width: 0; background: rgba(5, 13, 34, 0.6); border: 1px solid rgba(255, 255, 255, 0.12); color: #FFFFFF; border-radius: 6px; padding: 4px 7px; font-size: 12px; font-weight: 600; }
.layer-name-input:focus { outline: none; border-color: var(--gold); }
.icon-btn { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--text-muted); border-radius: 6px; width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 11.5px; flex-shrink: 0; }
.icon-btn:hover { color: #FFFFFF; border-color: var(--gold); }
.icon-btn.danger:hover { color: #FF8E7B; border-color: #C8553D; }
.layer-meta-row { font-size: 10.5px; color: var(--text-muted); }
.layer-controls-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.swatch-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.color-dot { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.35); cursor: pointer; padding: 0; }
.color-dot.active { border-color: #FFFFFF; box-shadow: 0 0 0 2px rgba(229, 192, 11, 0.55); }
.color-picker-mini { width: 22px; height: 18px; border: none; background: transparent; padding: 0; cursor: pointer; }
.opacity-wrap { display: flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--text-muted); }
.opacity-wrap input[type="range"] { width: 64px; accent-color: var(--gold); }

/* BASEMAPS */
.basemap-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.bm-card { display: flex; align-items: center; gap: 7px; background: var(--navy-card); border: 1px solid var(--navy-border); border-radius: 8px; padding: 6px 7px; color: var(--text); font-size: 11.5px; cursor: pointer; text-align: left; }
.bm-card:hover { border-color: rgba(229, 192, 11, 0.6); }
.bm-card.active { border-color: var(--gold); background: rgba(229, 192, 11, 0.14); }
.bm-swatch { width: 22px; height: 22px; border-radius: 5px; flex-shrink: 0; border: 1px solid rgba(255, 255, 255, 0.25); }
.bm-hybrid { background: linear-gradient(135deg, #163829, #1f554c, #c8b878); }
.bm-sat { background: linear-gradient(135deg, #0c2620, #23473c, #4c6244); }
.bm-topo { background: linear-gradient(135deg, #d7e4cc, #ece8d5, #a9c7d9); }
.bm-streets { background: linear-gradient(135deg, #f1efe9, #f7d894, #c5d9e8); }
.bm-light { background: linear-gradient(135deg, #eef1f5, #d5dce6); }
.bm-dark { background: linear-gradient(135deg, #1b2230, #2f384a); }

/* FIELDS & COORD OPTIONS */
.tip-box { background: rgba(229, 192, 11, 0.11); border: 1px solid rgba(229, 192, 11, 0.35); border-radius: 8px; padding: 8px 10px; font-size: 11.5px; color: #F4E9B3; line-height: 1.4; margin-bottom: 11px; }
.field { margin-bottom: 9px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.field input[type="range"] { width: 100%; accent-color: var(--gold); }
.field input:not([type="range"]), .field select, .field textarea, .sub-field select {
  width: 100%; background: #061028; border: 1px solid rgba(169, 185, 217, 0.25);
  color: #FFFFFF; border-radius: 7px; padding: 6px 8px; font-family: inherit; font-size: 12px;
}
.field textarea { resize: vertical; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); }

.coord-options-box {
  background: var(--navy-card); border: 1px solid var(--navy-border); border-radius: 8px;
  padding: 8px 9px; margin-top: 4px;
}
.side-toggles {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 11px; color: #D9E4F5;
}
.side-toggles label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.side-toggles input { accent-color: var(--gold); }

.preset-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 10px; }
.preset-chip { background: var(--navy-card); border: 1px solid var(--navy-border); color: var(--text-muted); border-radius: 6px; padding: 5px 4px; font-size: 11px; font-weight: 600; cursor: pointer; }
.preset-chip:hover { color: #FFFFFF; border-color: rgba(229, 192, 11, 0.6); }
.preset-chip.active { background: rgba(229, 192, 11, 0.16); color: var(--gold); border-color: var(--gold); }

.color-matrix { display: flex; flex-direction: column; gap: 7px; }
.color-group { background: var(--navy-card); border: 1px solid var(--navy-border); border-radius: 8px; padding: 7px 9px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.color-group > span { font-size: 11.5px; font-weight: 600; color: #E8EEFA; }
.pickers { display: flex; align-items: center; gap: 8px; }
.pickers label { display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; }
.pickers input[type="color"] { width: 24px; height: 20px; border: 1px solid rgba(255,255,255,0.25); border-radius: 4px; background: transparent; padding: 0; cursor: pointer; }
.pickers small { font-size: 9.5px; color: var(--text-muted); }

.toggle-list { display: flex; flex-direction: column; gap: 7px; }
.toggle-item { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.toggle-item input[type="checkbox"] { accent-color: var(--gold); width: 14px; height: 14px; }
.sub-field { padding-left: 22px; margin-top: -2px; margin-bottom: 3px; }

/* PRO CARD */
.pro-card {
  background: linear-gradient(135deg, rgba(229, 192, 11, 0.12), rgba(7, 34, 95, 0.55));
  border: 1px solid rgba(229, 192, 11, 0.45);
  border-radius: 9px; padding: 10px;
}
.pro-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; font-weight: 700; font-size: 12px; color: #FFFFFF; }
.pro-badge { background: var(--gold); color: #071947; font-family: 'Montserrat', sans-serif; font-size: 9.5px; padding: 2px 7px; border-radius: 99px; }
.pro-card p { margin: 0 0 8px; font-size: 11px; color: #D9E4F5; line-height: 1.4; }

/* MEMBRETE EDITOR */
.small-help { font-size: 11px; color: var(--text-muted); margin: 0 0 10px; line-height: 1.35; }
.membrete-editor-list { display: flex; flex-direction: column; gap: 7px; }
.mb-card { background: var(--navy-card); border: 1px solid var(--navy-border); border-radius: 8px; padding: 7px 8px; display: flex; flex-direction: column; gap: 6px; }
.mb-row { display: flex; gap: 4px; align-items: center; }
.mb-row input { flex: 1; min-width: 0; background: #061028; border: 1px solid rgba(255,255,255,0.14); color: #FFFFFF; border-radius: 5px; padding: 4px 6px; font-size: 11.5px; }
.mb-row select { width: 62px; background: #061028; border: 1px solid rgba(255,255,255,0.14); color: #FFFFFF; border-radius: 5px; padding: 4px; font-size: 11px; }

/* AI TAB */
.key-input-row { display: flex; gap: 5px; align-items: center; }
.key-input-row input { flex: 1; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip-prompt { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(229, 192, 11, 0.35); color: #E8EEFA; border-radius: 99px; padding: 4px 9px; font-size: 11px; cursor: pointer; }
.chip-prompt:hover { background: rgba(229, 192, 11, 0.18); color: var(--gold); }
.ai-status { margin-top: 10px; font-size: 12px; color: var(--gold); line-height: 1.4; min-height: 20px; }

/* EXPORT TAB */
.export-cards { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.export-status { margin-top: 11px; font-size: 12px; color: var(--gold); min-height: 20px; }
.meta-note { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--navy-border); border-radius: 8px; padding: 10px; font-size: 11px; color: var(--text-muted); line-height: 1.45; }
.meta-note strong { display: block; color: #FFFFFF; margin-bottom: 4px; }
.meta-note p { margin: 0 0 5px; }
.meta-note code { font-family: Consolas, monospace; color: #E8EEFA; background: rgba(255,255,255,0.08); padding: 1px 4px; border-radius: 4px; }

/* RIGHT STAGE */
.stage {
  position: relative; display: flex; flex-direction: column;
  background-color: #050C1F;
  background-image: radial-gradient(rgba(169, 185, 217, 0.16) 1px, transparent 1px);
  background-size: 20px 20px; height: 100%; min-width: 0; overflow: hidden;
}
.stage-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 7px 16px; background: rgba(5, 13, 34, 0.85); border-bottom: 1px solid var(--navy-border); gap: 10px; z-index: 10; }
.toolbar-group { display: flex; align-items: center; gap: 6px; }
.tool-btn { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14); color: #FFFFFF; height: 27px; min-width: 27px; padding: 0 8px; border-radius: 6px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.tool-btn:hover { border-color: var(--gold); background: rgba(229, 192, 11, 0.15); }
.tool-btn-text { font-size: 11.5px; font-weight: 500; }
.toolbar-readout { font-family: Consolas, monospace; font-size: 11px; color: #C9D4EC; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-readout .sep { opacity: 0.4; }
.scale-control { display: inline-flex; align-items: center; gap: 5px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(169, 185, 217, 0.25); border-radius: 6px; padding: 2px 4px 2px 7px; }
.scale-control input { width: 92px; background: #050D22; border: 1px solid rgba(255, 255, 255, 0.14); color: #FFFFFF; border-radius: 4px; padding: 2px 5px; font-family: Consolas, monospace; font-size: 11px; }
.scale-control input:focus { outline: none; border-color: var(--gold); }
.tool-btn-apply { height: 22px; min-width: 26px; padding: 0 7px; font-size: 11px; background: var(--gold); color: #071947; border-color: var(--gold); }
.tool-btn-apply:hover { background: var(--gold-hover); color: #071947; }

.sheet-viewport { flex: 1; display: flex; align-items: center; justify-content: center; padding: 14px 18px 20px; overflow: auto; min-height: 0; }

/* PAPER SHEET */
.paper-sheet {
  background: #FFFFFF; color: var(--ink-dark); box-shadow: var(--shadow-sheet);
  border-radius: 3px; display: flex; flex-direction: column; overflow: hidden;
  position: relative; width: 920px; height: 650px; flex-shrink: 0;
}

.sheet-header {
  background: var(--map-header-bg); color: #FFFFFF; padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
}
.sheet-title-wrap { min-width: 0; flex: 1; }
.sheet-title-wrap h2 {
  margin: 0; font-family: 'Montserrat', sans-serif;
  font-size: var(--map-title-size); font-weight: 800; color: #FFFFFF;
  line-height: 1.18; white-space: normal; word-break: break-word;
}
.sheet-title-wrap p {
  margin: 2px 0 0; font-size: var(--map-subtitle-size); color: rgba(255, 255, 255, 0.85);
  line-height: 1.25; white-space: normal; word-break: break-word;
}
.sheet-logo { height: 26px; width: auto; max-width: 125px; object-fit: contain; flex-shrink: 0; }
.sheet-gold-rule { height: 3.5px; background: var(--map-header-accent); flex-shrink: 0; }

.sheet-main {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

/* LAYOUT MODES */
.paper-sheet.layout-sidebar .sheet-header,
.paper-sheet.layout-sidebar .sheet-gold-rule,
.paper-sheet.layout-sidebar .membrete-strip,
.paper-sheet.layout-sidebar .sheet-footer,
.paper-sheet.layout-sidebar-left .sheet-header,
.paper-sheet.layout-sidebar-left .sheet-gold-rule,
.paper-sheet.layout-sidebar-left .membrete-strip,
.paper-sheet.layout-sidebar-left .sheet-footer {
  display: none !important;
}
.paper-sheet.layout-sidebar-left .sheet-main {
  flex-direction: row-reverse;
}
.paper-sheet.layout-sidebar-left .sheet-sidebar {
  border-left: none;
  border-right: 1.5px solid var(--map-header-bg);
}
.paper-sheet.layout-clean .sheet-footer { display: none !important; }

.sheet-sidebar {
  width: 27%; min-width: 185px; max-width: 255px;
  border-left: 1.5px solid var(--map-header-bg); background: #F8FAFD;
  display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
}
.sheet-sidebar[hidden] { display: none !important; }
.sidebar-brand-box { background: var(--map-header-bg); padding: 9px 10px; display: flex; align-items: center; justify-content: center; }
.sidebar-logo { max-height: 26px; max-width: 100%; object-fit: contain; }
.sidebar-accent-bar { height: 3.5px; background: var(--map-header-accent); }
.sidebar-title-box { padding: 8px 10px; border-bottom: 1px solid #DCE2EE; background: #FFFFFF; }
.sidebar-title-box h2 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: var(--map-title-size); color: var(--map-header-bg); line-height: 1.2; word-break: break-word; }
.sidebar-title-box p { margin: 3px 0 0; font-size: var(--map-subtitle-size); color: var(--ink-muted); line-height: 1.28; word-break: break-word; }
.sidebar-drop-hint { margin: 6px 8px; padding: 6px; border: 1px dashed rgba(7, 34, 95, 0.2); border-radius: 5px; font-size: 8px; color: #7C8AA5; text-align: center; line-height: 1.3; }
.sidebar-source-box { margin-top: auto; padding: 7px 9px; border-top: 1px solid #DCE2EE; background: #F1F4FA; font-size: 8.5px; color: var(--ink-muted); line-height: 1.3; }

/* MEMBRETE GRID */
.membrete-strip { border-top: 1.5px solid var(--map-header-bg); background: #FFFFFF; padding: 4px 12px; flex-shrink: 0; }
.membrete-strip[hidden] { display: none !important; }
.membrete-grid { display: grid; gap: 3px; }
.membrete-grid.top-mode { grid-template-columns: repeat(6, 1fr); }
.membrete-grid.side-mode { grid-template-columns: repeat(2, 1fr); padding: 7px; gap: 4px; }
.mb-cell {
  border: 1px solid #C8D3E6; background: #FFFFFF; padding: 3px 5px; border-radius: 2px;
  min-width: 0; cursor: grab; transition: border-color 0.12s ease;
}
.mb-cell:hover { border-color: var(--gold); }
.mb-cell.span-2 { grid-column: span 2; }
.mb-cell-label { display: block; font-family: 'Montserrat', sans-serif; font-size: 7px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--map-header-bg); line-height: 1.1; }
.mb-cell-val { display: block; font-size: 8.8px; font-weight: 600; color: #1A2744; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* MAP BODY & CONFIGURABLE COORD MARGINS */
.sheet-body {
  position: relative; flex: 1; background: #FFFFFF; min-height: 0; min-width: 0; display: flex;
  padding-top: var(--pad-top, 18px);
  padding-bottom: var(--pad-bottom, 18px);
  padding-left: var(--pad-left, 20px);
  padding-right: var(--pad-right, 20px);
}
.sheet-body.no-grid .coord-margin, .sheet-body.no-grid .grid-lines { display: none; }

.coord-margin { position: absolute; pointer-events: none; font-family: Consolas, monospace; font-size: 8.2px; color: #4A5875; }
.coord-top { top: 3px; left: var(--pad-left, 20px); right: var(--pad-right, 20px); height: 13px; }
.coord-bottom { bottom: 3px; left: var(--pad-left, 20px); right: var(--pad-right, 20px); height: 13px; }
.coord-left { left: 2px; top: var(--pad-top, 18px); bottom: var(--pad-bottom, 18px); width: calc(var(--pad-left, 20px) - 4px); }
.coord-right { right: 2px; top: var(--pad-top, 18px); bottom: var(--pad-bottom, 18px); width: calc(var(--pad-right, 20px) - 4px); }

.coord-label-x { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.coord-label-y { position: absolute; transform: translateY(-50%); white-space: nowrap; width: 100%; text-align: center; }

/* Etiquetas laterales rotadas paralelas al mapa */
.sheet-body.rotate-sides .coord-left .coord-label-y {
  left: 50%; width: auto;
  transform: translate(-50%, -50%) rotate(-90deg);
}
.sheet-body.rotate-sides .coord-right .coord-label-y {
  left: 50%; width: auto;
  transform: translate(-50%, -50%) rotate(90deg);
}

.map-frame { position: relative; flex: 1; border: 1.5px solid var(--map-header-bg); overflow: hidden; background: #E8EEF5; }
#mapView { width: 100%; height: 100%; }
#mapView .esri-ui, #insetView .esri-ui { display: none !important; }
.grid-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

/* DRAGGABLE & RESIZABLE WIDGETS (OVER ENTIRE #sheetMain) */
.carto-widget {
  position: absolute; z-index: 16; cursor: grab; user-select: none; touch-action: none;
  outline: 1.5px solid transparent; outline-offset: 2px; border-radius: 6px;
  transform-origin: top left;
}
.carto-widget:hover { outline-color: var(--gold); box-shadow: 0 8px 22px rgba(7, 34, 95, 0.32); }
.carto-widget.dragging { cursor: grabbing; outline-color: var(--gold); z-index: 30; }
.carto-widget.hidden-widget { display: none !important; }

.drag-pill {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--gold); font-size: 9px; font-weight: 700;
  padding: 2px 7px; border-radius: 99px; border: 1px solid var(--gold);
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.14s ease;
}
.carto-widget:hover .drag-pill, .carto-widget.dragging .drag-pill { opacity: 1; }

.resize-handle {
  position: absolute; right: -4px; bottom: -4px; width: 13px; height: 13px;
  background: var(--gold); border: 1.5px solid var(--navy); border-radius: 3px;
  cursor: nwse-resize; opacity: 0; transition: opacity 0.14s ease; z-index: 5;
}
.carto-widget:hover .resize-handle, .carto-widget.dragging .resize-handle { opacity: 1; }

.widget-north {
  background: var(--map-north-bg); border: 1px solid var(--map-north-primary);
  padding: 5px 7px; width: 54px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}
.widget-north svg { width: 38px; height: 48px; display: block; }

.widget-scale {
  background: var(--map-scale-bg); border: 1px solid var(--map-scale-primary);
  padding: 6px 10px 5px; min-width: 144px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}
.scale-segments { display: grid; grid-template-columns: repeat(4, 1fr); height: 7px; border: 1px solid var(--map-scale-primary); width: 124px; }
.seg-dark { background: var(--map-scale-primary); }
.seg-light { background: var(--map-scale-bg); }
.scale-labels { display: flex; justify-content: space-between; font-size: 8.5px; font-weight: 700; color: var(--map-scale-ink); margin-top: 2px; width: 124px; }
.scale-ratio { text-align: center; font-size: 8.5px; color: var(--map-scale-ink); opacity: 0.82; margin-top: 2px; font-family: Consolas, monospace; }

.widget-legend {
  background: var(--map-legend-bg); border: 1px solid var(--map-legend-primary);
  padding: 7px 9px; min-width: 150px; max-width: 220px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
.legend-header { font-family: 'Montserrat', sans-serif; font-size: 9.5px; font-weight: 800; letter-spacing: 0.08em; color: var(--map-legend-primary); }
.legend-rule { height: 2px; width: 32px; background: var(--map-legend-accent); margin: 3px 0 6px; }
.legend-items { display: flex; flex-direction: column; gap: 5px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--map-legend-ink); line-height: 1.2; }
.legend-empty { font-size: 9.5px; color: var(--map-legend-ink); opacity: 0.65; font-style: italic; }
.legend-swatch-poly { width: 15px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-swatch-line { width: 15px; height: 3.5px; border-radius: 2px; flex-shrink: 0; }
.legend-swatch-point { width: 9px; height: 9px; border-radius: 50%; margin: 0 3px; flex-shrink: 0; border: 1.5px solid #FFFFFF; box-shadow: 0 0 0 1px rgba(7,34,95,0.5); }

.widget-inset { background: #FFFFFF; border: 1.5px solid var(--map-header-bg); width: 142px; overflow: visible; box-shadow: 0 4px 14px rgba(0,0,0,0.26); }
.inset-title { background: var(--map-header-bg); color: #FFFFFF; font-family: 'Montserrat', sans-serif; font-size: 8px; letter-spacing: 0.08em; padding: 3px 6px; border-bottom: 1.5px solid var(--map-header-accent); text-align: center; }
.inset-map-box { width: 139px; height: 90px; position: relative; pointer-events: none; overflow: hidden; }
#insetView { width: 100%; height: 100%; }

.sheet-footer {
  background: #F4F6FB; border-top: 1px solid #DCE2EE; padding: 5px 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 9px; color: var(--ink-muted); flex-shrink: 0;
}
.sheet-footer span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stage-status {
  position: absolute; bottom: 8px; right: 16px;
  background: rgba(7, 34, 95, 0.92); border: 1px solid rgba(229, 192, 11, 0.5);
  color: #E8EEFA; font-size: 11px; padding: 5px 10px; border-radius: 99px;
  z-index: 25; pointer-events: none; opacity: 0; transition: opacity 0.2s ease;
}
.stage-status.visible { opacity: 1; }

.modal-dialog {
  background: var(--navy-panel); color: var(--text); border: 1px solid rgba(229, 192, 11, 0.5);
  border-radius: 12px; padding: 18px 20px; max-width: 520px; width: calc(100% - 32px);
}
.modal-dialog::backdrop { background: rgba(3, 8, 22, 0.72); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-bottom: 9px; border-bottom: 2px solid var(--gold); }
.modal-head h2 { margin: 0; font-family: 'Montserrat', sans-serif; font-size: 15.5px; }
.guide-steps { margin: 0; padding-left: 18px; line-height: 1.55; color: #D9E2F5; }
.guide-steps li { margin-bottom: 7px; }

@media (max-width: 980px) {
  html, body { overflow: auto; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: calc(100vh - 56px); overflow: visible; }
  .studio-panel { border-right: none; border-bottom: 1px solid var(--navy-border); max-height: 48vh; }
  .stage { min-height: 540px; }
  .hide-sm { display: none; }
}
