:root {
  /* Paleta extraída de MAPS.png */
  --brand: #4070b8;
  --brand-deep: #355f9c;
  --brand-soft: #d9e4f4;
  --gray: #c7c9cb;
  --gray-deep: #8b8e92;
  --ink: #1a1f26;
  --muted: #5c636b;
  --bg: #eef1f4;
  --bg2: #e2e6ea;
  --card: #f8f8f8;
  --line: #c7c9cb;
  --ok: #2f7d4a;
  --err: #b42318;
  --accent: #4070b8;
  --radius: 12px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --shadow: 0 12px 28px rgba(26, 31, 38, 0.08);
}

* { box-sizing: border-box; }

/* Obligatorio: display:flex en .flow-screen pisa el [hidden] del navegador */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 0% -10%, rgba(64, 112, 184, 0.18) 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(199, 201, 203, 0.55) 0%, transparent 50%),
    linear-gradient(180deg, #f4f6f8 0%, var(--bg) 100%);
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem calc(1rem + env(safe-area-inset-bottom, 0px));
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.75rem;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.brand-lockup img {
  height: 28px;
  width: auto;
  display: block;
}
.brand-sub {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-deep);
  white-space: nowrap;
}

.top-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  flex-shrink: 0;
}
.pill.ok { color: var(--ok); border-color: #a9d0b6; background: #f2faf5; }
.pill.bad { color: var(--err); border-color: #e0a8a8; background: #fff5f4; }
.pill.warn {
  color: #8a5a00;
  border-color: #e0c48a;
  background: #fff8e8;
}

.card-screen,
#view-home,
#view-list {
  background: color-mix(in srgb, var(--card) 94%, white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

/* Captura / edición / revisión: pantalla completa en el celular */
.flow-screen {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 4.5rem);
  background: color-mix(in srgb, var(--card) 94%, white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.flow-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.85rem 0.85rem 0.5rem;
  overscroll-behavior: contain;
}
.flow-footer {
  flex: 0 0 auto;
  padding: 0.65rem 0.85rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, #fff 88%, var(--brand-soft));
  box-shadow: 0 -6px 16px rgba(26, 31, 38, 0.06);
}
.flow-footer button {
  margin-top: 0;
}
.flow-footer .actions.stacked {
  margin: 0;
  gap: 0.4rem;
}

.flow-top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 0 0 auto;
  padding: 0.55rem 0.75rem;
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.flow-top-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}
.flow-top-text strong {
  font-size: 1rem;
  color: var(--brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-top .esp-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  max-width: 38%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.ghost.compact {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
  font-size: 1.15rem;
}

body.immersive .top {
  display: none;
}
body.immersive #app {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  height: 100dvh;
}
body.immersive .immersive-screen {
  max-height: none;
  height: 100dvh;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #f4f6f8;
}

.capture-scroll {
  padding: 0.65rem 0.75rem 1rem;
}
.modo-chip {
  margin: 0 0 0.65rem;
}
.linkish {
  background: none;
  border: none;
  color: var(--brand);
  font: inherit;
  font-weight: 700;
  padding: 0;
  margin: 0 0 0 0.35rem;
  width: auto;
  text-decoration: underline;
  cursor: pointer;
}
.linkish:hover { background: none; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}
.photo-grid figure {
  margin: 0;
  background: #1a1f26;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 3 / 4;
}
.photo-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-grid figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(26, 31, 38, 0.72);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.25rem 0.4rem;
}
.photo-remove {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.85rem;
  height: 1.85rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(26, 31, 38, 0.72);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.photo-remove:hover { background: var(--err); }
.photo-add-tile {
  margin: 0;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  border: 2px dashed color-mix(in srgb, var(--brand) 45%, var(--line));
  background: color-mix(in srgb, var(--brand-soft) 55%, #fff);
  color: var(--brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
}
.photo-add-tile span {
  font-size: 2.2rem;
  line-height: 1;
}
.photo-add-tile:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
}

.capture-footer {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.55rem;
  align-items: center;
}
.btn-plus {
  margin: 0;
  width: 3.2rem;
  height: 3.2rem;
  padding: 0;
  border-radius: 14px;
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.capture-footer #btn-enviar {
  margin: 0;
  height: 3.2rem;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet[hidden] { display: none !important; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 31, 38, 0.45);
}
.sheet-panel {
  position: relative;
  width: min(520px, 100%);
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 32px rgba(26, 31, 38, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.sheet-title {
  margin: 0 0 0.35rem;
  text-align: center;
  font-weight: 800;
  color: var(--ink);
}
.sheet-action {
  margin: 0;
}
.file-label {
  display: block;
  text-align: center;
  background: var(--brand);
  color: #fff;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-weight: 750;
  cursor: pointer;
}
.file-label:hover { background: var(--brand-deep); }
.sr-only-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}
.sheet-cancel {
  margin-top: 0.25rem;
  width: 100%;
}

.edit-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 21, 26, 0.82);
  color: #e8eef5;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  padding: 1rem;
}
.edit-loading[hidden] { display: none !important; }

.edit-layout {
  background: #12151a !important;
}
.edit-layout .flow-top {
  background: #1a1f26;
  border-bottom-color: #2a313a;
}
.edit-layout .flow-top-text strong { color: #fff; }
.edit-layout .flow-top-text .muted { color: #a8b0ba; }
.edit-layout .ghost {
  color: #d7e0ea;
  border-color: #3a4450;
}
.edit-layout .ghost:hover {
  background: #243040;
  border-color: var(--brand);
}
.edit-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  overflow: hidden;
}
.edit-footer {
  background: #1a1f26;
  border-top-color: #2a313a;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.edit-footer button {
  margin: 0;
  width: 100%;
}
.edit-bench {
  margin: 0;
  text-align: center;
  color: #8b939c !important;
}

.compact-tools {
  margin: 0;
  flex-wrap: wrap;
}
.compact-tools .ghost {
  padding: 0.5rem 0.35rem;
  font-size: 0.82rem;
  flex: 1 1 calc(25% - 0.35rem);
  min-width: 0;
}

.editor-wrap {
  position: relative;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  user-select: none;
  width: 100%;
  height: 100%;
  max-height: 100%;
}
.editor-wrap canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  background: #0d1014;
}

.review-box {
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d1014;
  border-radius: 10px;
  overflow: hidden;
  text-align: center;
}
.review-box img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #0d1014;
}

.login-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 0.2rem 0 1.1rem;
  gap: 0.65rem;
}
.login-hero img {
  width: min(240px, 78%);
  height: auto;
  display: block;
}
.login-hero .product {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.02em;
}

h1 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  color: var(--brand);
  letter-spacing: -0.02em;
}
h2 {
  margin: 1.2rem 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-deep);
  font-weight: 800;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--err); margin-top: 0.75rem; }

label { display: block; margin: 0.75rem 0; font-size: 0.9rem; font-weight: 600; }
label.inline { display: flex; flex-direction: column; gap: 0.35rem; }
input, select, button {
  font: inherit;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 45%, white);
  border-color: var(--brand);
}
button {
  background: var(--brand);
  color: #fff;
  border: none;
  font-weight: 750;
  cursor: pointer;
  margin-top: 0.9rem;
}
button:hover { background: var(--brand-deep); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost, .ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
  width: auto;
  margin-top: 0;
}
button.ghost:hover, .ghost:hover {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}
.file-btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-weight: 750;
  cursor: pointer;
  margin: 0;
}
.file-btn:hover { background: var(--brand-deep); }
.actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.8rem 0; }

.bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; gap: 0.5rem; }

.esp-badge-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 1rem;
}
.esp-badge {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-weight: 750;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}
.esp-badge.os-badge {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 650;
}

.bio-login-btn {
  width: 100%;
  margin-top: 0.65rem;
}

.bio-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.bio-row .ghost {
  width: auto;
  padding: 0.45rem 0.85rem;
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin: 0.5rem 0 1rem;
}
.dash-tile {
  margin: 0;
  width: 100%;
  text-align: left;
  padding: 1.05rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 4.6rem;
}
.dash-tile:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: var(--brand-soft);
}
.dash-tile:disabled {
  opacity: 0.45;
}
.dash-tile.dash-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.dash-tile.dash-primary:hover:not(:disabled) {
  background: var(--brand-deep);
}
.dash-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.dash-sub {
  font-size: 0.84rem;
  opacity: 0.85;
  font-weight: 600;
}

#view-list {
  background: color-mix(in srgb, var(--card) 94%, white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  cursor: pointer;
}
.list li:active { transform: scale(0.99); }
.badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  white-space: nowrap;
  font-weight: 700;
}
.muted-list li { cursor: default; opacity: 0.92; }

.actions.stacked {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}
.actions.stacked button,
.actions.stacked .ghost {
  width: 100%;
  margin-top: 0;
}
.row-actions {
  display: flex;
  gap: 0.45rem;
}
.row-actions .ghost {
  flex: 1;
  width: auto;
}

.corner-overlay {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}
.corner-svg {
  position: absolute;
  inset: 0;
  overflow: visible;
}
.corner-poly {
  fill: rgba(64, 112, 184, 0.2);
  stroke: var(--brand);
  stroke-width: 2;
}
.corner-handle {
  pointer-events: auto;
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--brand);
  box-shadow: 0 2px 8px rgba(26, 31, 38, 0.35);
  padding: 0;
  cursor: grab;
  touch-action: none;
}
.corner-handle:active { cursor: grabbing; }
