*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.10);
  --border-md: rgba(0,0,0,0.18);
  --text: #1a1a18;
  --text-muted: #6b6a65;
  --accent: #4f6ce6;
  --accent-hover: #3a56d4;
  --danger: #d04040;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

body { font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 54px;
  background: var(--surface); border-bottom: 0.5px solid var(--border-md);
  position: sticky; top: 0; z-index: 100;
}
.brand { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; }
.brand em { font-style: normal; color: var(--accent); }
.nav-links { display: flex; gap: 8px; }
.nav-btn {
  text-decoration: none; color: var(--text-muted); font-size: 14px;
  padding: 6px 14px; border-radius: 20px; border: 0.5px solid transparent;
  transition: all .15s;
}
.nav-btn:hover { background: var(--bg); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }

/* ── Layout ── */
main { max-width: 960px; margin: 0 auto; padding: 28px 20px; }
.section { display: none; }
.section.active { display: block; }
.section-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-header h1 { font-size: 20px; font-weight: 600; flex: 1; }

/* ── Botones ── */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 8px 18px; border-radius: 8px; font-size: 14px;
  cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: transparent; color: var(--text); border: 0.5px solid var(--border-md);
  padding: 8px 18px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.btn-secondary:hover { background: var(--bg); }
.btn-danger-sm {
  background: transparent; color: var(--danger); border: 0.5px solid var(--danger);
  padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer;
}
.btn-danger-sm:hover { background: #fef2f2; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-back {
  background: none; border: none; color: var(--accent); font-size: 14px;
  cursor: pointer; padding: 0;
}
.btn-row { display: flex; gap: 10px; margin-top: 16px; }

/* ── Card / Form ── */
.card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-group label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.field-group input, .field-group textarea, .field-group select {
  border: 0.5px solid var(--border-md); border-radius: 8px;
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
.field-group input:focus, .field-group textarea:focus {
  outline: none; border-color: var(--accent);
}
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ── Artículos grid ── */
.articulos-grid { display: flex; flex-direction: column; gap: 10px; }
.articulo-card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; box-shadow: var(--shadow);
}
.articulo-card.inactivo { opacity: 0.55; }
.art-info { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.art-info strong { font-size: 15px; }
.art-info small { font-size: 12px; color: var(--text-muted); }
.art-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty-hint { color: var(--text-muted); font-size: 14px; padding: 12px 0; }
.badge { font-size: 11px; background: #e8edff; color: #3050b0;
  padding: 2px 8px; border-radius: 12px; }
.badge-warn { font-size: 11px; background: #fff3cd; color: #7a5000;
  padding: 2px 8px; border-radius: 12px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border-md); }
.tab {
  background: none; border: none; padding: 10px 20px; font-size: 14px;
  cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: all .15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* ── Upload area ── */
.imagen-upload-area {
  border: 1.5px dashed var(--border-md); border-radius: var(--radius);
  padding: 40px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; color: var(--text-muted);
  background: var(--bg); min-height: 180px;
}

/* ── Canvas viewer ── */
.imagen-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.canvas-wrap { position: relative; cursor: crosshair; display: inline-block; max-width: 100%; }
canvas { display: block; border-radius: var(--radius-sm); border: 0.5px solid var(--border); max-width: 100%; }
.canvas-hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ── Posiciones list ── */
.posiciones-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.posicion-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 0.5px solid var(--border-md);
  border-radius: 8px; padding: 6px 12px;
}
.pos-letra {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.pos-coords { font-size: 12px; color: var(--text-muted); }

/* ── Galería ── */
.galeria-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.galeria-card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.galeria-card img { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: var(--bg); display: block; }
.galeria-info { padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.galeria-info strong { font-size: 13px; }
.galeria-info small { font-size: 11px; color: var(--text-muted); }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1a1a18; color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 14px;
  opacity: 0; transform: translateY(8px);
  transition: all .2s; pointer-events: none; z-index: 999;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.btn-debug {
  background: transparent; color: #7a5fb5; border: 0.5px solid #7a5fb5;
  padding: 4px 10px; border-radius: 6px; font-size: 12px;
  text-decoration: none; cursor: pointer;
}
.btn-debug:hover { background: #f3eeff; }
